diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index f5ce466d9051..e37f53240277 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -66,7 +66,7 @@ jobs: - mks_robin_lite_maple - mks_robin_pro_maple #- mks_robin_nano35_maple - #- STM32F103RET6_creality_maple + #- STM32F103RE_creality_maple - STM32F103VE_ZM3E4V2_USB_maple # STM32 (ST) Environments @@ -75,7 +75,7 @@ jobs: #- STM32F103RC_btt_USB - STM32F103RE_btt - STM32F103RE_btt_USB - - STM32F103RET6_creality + - STM32F103RE_creality - STM32F103VE_longer - STM32F407VE_black - STM32F401VE_STEVAL diff --git a/.gitignore b/.gitignore index a83bfa4265a6..0b852d767325 100755 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,10 @@ # Generated files _Version.h bdf2u8g +marlin_config.json +mczip.h +*.gen +*.sublime-workspace # # OS @@ -37,7 +41,6 @@ applet/ *.rej *.bak *.idea -*.s *.i *.ii *.swp @@ -137,20 +140,19 @@ __vm/ vc-fileutils.settings # Visual Studio Code -.vscode -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.vscode/*.db +.vscode/* +!.vscode/extensions.json #Simulation imgui.ini eeprom.dat +spi_flash.bin #cmake CMakeLists.txt src/CMakeLists.txt CMakeListsPrivate.txt +build/ # CLion cmake-build-* diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000000..f495d14f53e8 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,11 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "marlinfirmware.auto-build", + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2c53498d0272..c2d5dced283b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -94,6 +94,11 @@ // @section machine +// Choose the name from boards.h that matches your setup +#ifndef MOTHERBOARD + #define MOTHERBOARD BOARD_RAMPS_14_EFB +#endif + /** * Select the serial port on the board to use for communication with the host. * This allows the connection of wireless adapters (for instance) to non-default port pins. @@ -137,11 +142,6 @@ // Enable the Bluetooth serial interface on AT90USB devices //#define BLUETOOTH -// Choose the name from boards.h that matches your setup -#ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_RAMPS_14_EFB -#endif - // Name displayed in the LCD "Ready" message and Info menu //#define CUSTOM_MACHINE_NAME "3D Printer" @@ -371,8 +371,12 @@ //#define PS_OFF_SOUND // Beep 1s when power off #define PSU_ACTIVE_STATE LOW // Set 'LOW' for ATX, 'HIGH' for X-Box - //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 - //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power + //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 + //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power + //#define LED_POWEROFF_TIMEOUT 10000 // (ms) Turn off LEDs after power-off, with this amount of delay + + //#define POWER_OFF_TIMER // Enable M81 D to power off after a delay + //#define POWER_OFF_WAIT_FOR_COOLDOWN // Enable M81 S to power off only after cooldown //#define PSU_POWERUP_GCODE "M355 S1" // G-code to run after power-on (e.g., case light on) //#define PSU_POWEROFF_GCODE "M355 S0" // G-code to run before power-off (e.g., case light off) @@ -384,12 +388,14 @@ #define AUTO_POWER_CONTROLLERFAN #define AUTO_POWER_CHAMBER_FAN #define AUTO_POWER_COOLER_FAN - //#define AUTO_POWER_E_TEMP 50 // (°C) Turn on PSU if any extruder is over this temperature - //#define AUTO_POWER_CHAMBER_TEMP 30 // (°C) Turn on PSU if the chamber is over this temperature - //#define AUTO_POWER_COOLER_TEMP 26 // (°C) Turn on PSU if the cooler is over this temperature #define POWER_TIMEOUT 30 // (s) Turn off power if the machine is idle for this duration //#define POWER_OFF_DELAY 60 // (s) Delay of poweroff after M81 command. Useful to let fans run for extra time. #endif + #if EITHER(AUTO_POWER_CONTROL, POWER_OFF_WAIT_FOR_COOLDOWN) + //#define AUTO_POWER_E_TEMP 50 // (°C) PSU on if any extruder is over this temperature + //#define AUTO_POWER_CHAMBER_TEMP 30 // (°C) PSU on if the chamber is over this temperature + //#define AUTO_POWER_COOLER_TEMP 26 // (°C) PSU on if the cooler is over this temperature + #endif #endif //=========================================================================== @@ -431,6 +437,9 @@ * 5 : 100kΩ ATC Semitec 104GT-2/104NT-4-R025H42G - Used in ParCan, J-Head, and E3D, SliceEngineering 300°C * 501 : 100kΩ Zonestar - Tronxy X3A * 502 : 100kΩ Zonestar - used by hot bed in Zonestar Průša P802M + * 503 : 100kΩ Zonestar (Z8XM2) Heated Bed thermistor + * 504 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-B3950) Hotend Thermistor + * 505 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-3950) Bed Thermistor * 512 : 100kΩ RPW-Ultra hotend * 6 : 100kΩ EPCOS - Not as accurate as table #1 (created using a fluke thermocouple) * 7 : 100kΩ Honeywell 135-104LAG-J01 @@ -450,6 +459,7 @@ * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 * 66 : 4.7MΩ Dyze Design High Temperature Thermistor * 67 : 500kΩ SliceEngineering 450°C Thermistor + * 68 : PT100 amplifier board from Dyze Design * 70 : 100kΩ bq Hephestos 2 * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32 * 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor @@ -756,6 +766,7 @@ //#define COREZX //#define COREZY //#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042 +//#define MARKFORGED_YX // Enable for a belt style printer with endless "Z" motion //#define BELTPRINTER @@ -1088,6 +1099,17 @@ */ //#define BLTOUCH +/** + * MagLev V4 probe by MDD + * + * This probe is deployed and activated by powering a built-in electromagnet. + */ +//#define MAGLEV4 +#if ENABLED(MAGLEV4) + //#define MAGLEV_TRIGGER_PIN 11 // Set to the connected digital output + #define MAGLEV_TRIGGER_DELAY 15 // Changing this risks overheating the coil +#endif + /** * Touch-MI Probe by hotends.fr * @@ -1836,6 +1858,7 @@ #define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load #if ENABLED(EEPROM_SETTINGS) //#define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors. + //#define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build. #endif // @@ -1891,8 +1914,7 @@ #if ENABLED(NOZZLE_PARK_FEATURE) // Specify a park position as { X, Y, Z_raise } #define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MAX_POS - 10), 20 } - //#define NOZZLE_PARK_X_ONLY // X move only is required to park - //#define NOZZLE_PARK_Y_ONLY // Y move only is required to park + #define NOZZLE_PARK_MOVE 0 // Park motion: 0 = XY Move, 1 = X Only, 2 = Y Only, 3 = X before Y, 4 = Y before X #define NOZZLE_PARK_Z_RAISE_MIN 2 // (mm) Always raise Z by at least this distance #define NOZZLE_PARK_XY_FEEDRATE 100 // (mm/s) X and Y axes feedrate (also used for delta Z axis) #define NOZZLE_PARK_Z_FEEDRATE 5 // (mm/s) Z axis feedrate (not used for delta printers) @@ -2458,6 +2480,11 @@ //#define FYSETC_MINI_12864_2_1 // Type A/B. NeoPixel RGB Backlight //#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight. +// +// BigTreeTech Mini 12864 V1.0 is an alias for FYSETC_MINI_12864_2_1. Type A/B. NeoPixel RGB Backlight. +// +//#define BTT_MINI_12864_V1 + // // Factory display for Creality CR-10 // https://www.aliexpress.com/item/32833148327.html @@ -2780,7 +2807,7 @@ // Ender-3 v2 OEM display. A DWIN display with Rotary Encoder. // //#define DWIN_CREALITY_LCD // Creality UI -//#define DWIN_CREALITY_LCD_ENHANCED // Enhanced UI +//#define DWIN_LCD_PROUI // Pro UI by MRiscoC //#define DWIN_CREALITY_LCD_JYERSUI // Jyers UI by Jacob Myers //#define DWIN_MARLINUI_PORTRAIT // MarlinUI (portrait orientation) //#define DWIN_MARLINUI_LANDSCAPE // MarlinUI (landscape orientation) @@ -2793,7 +2820,7 @@ #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus - //#define TOUCH_IDLE_SLEEP 300 // (secs) Turn off the TFT backlight if set (5mn) + //#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn) #define TOUCH_SCREEN_CALIBRATION @@ -2819,6 +2846,11 @@ //#define REPRAPWORLD_KEYPAD //#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press +// +// EasyThreeD ET-4000+ with button input and status LED +// +//#define EASYTHREED_UI + //============================================================================= //=============================== Extra Features ============================== //============================================================================= @@ -2829,9 +2861,6 @@ // :[1,2,3,4,5,6,7,8] //#define NUM_M106_FANS 1 -// Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino -//#define FAST_PWM_FAN - // Use software PWM to drive the fan, as for the heaters. This uses a very low frequency // which is not as annoying as with the hardware PWM. On the other hand, if this frequency // is too low, you should also increment SOFT_PWM_SCALE. diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index fc9688edb76e..0a18e95ebcad 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -138,15 +138,21 @@ #endif /** - * Configuration options for MAX Thermocouples (-2, -3, -5). - * FORCE_HW_SPI: Ignore SCK/MOSI/MISO pins and just use the CS pin & default SPI bus. - * MAX31865_WIRES: Set the number of wires for the probe connected to a MAX31865 board, 2-4. Default: 2 - * MAX31865_50HZ: Enable 50Hz filter instead of the default 60Hz. + * Thermocouple Options — for MAX6675 (-2), MAX31855 (-3), and MAX31865 (-5). */ -//#define TEMP_SENSOR_FORCE_HW_SPI -//#define MAX31865_SENSOR_WIRES_0 2 +//#define TEMP_SENSOR_FORCE_HW_SPI // Ignore SCK/MOSI/MISO pins; use CS and the default SPI bus. +//#define MAX31865_SENSOR_WIRES_0 2 // (2-4) Number of wires for the probe connected to a MAX31865 board. //#define MAX31865_SENSOR_WIRES_1 2 -//#define MAX31865_50HZ_FILTER + +//#define MAX31865_50HZ_FILTER // Use a 50Hz filter instead of the default 60Hz. +//#define MAX31865_USE_READ_ERROR_DETECTION // Treat value spikes (20°C delta in under 1s) as read errors. + +//#define MAX31865_USE_AUTO_MODE // Read faster and more often than 1-shot; bias voltage always on; slight effect on RTD temperature. +//#define MAX31865_MIN_SAMPLING_TIME_MSEC 100 // (ms) 1-shot: minimum read interval. Reduces bias voltage effects by leaving sensor unpowered for longer intervals. +//#define MAX31865_IGNORE_INITIAL_FAULTY_READS 10 // Ignore some read faults (keeping the temperature reading) to work around a possible issue (#23439). + +//#define MAX31865_WIRE_OHMS_0 0.95f // For 2-wire, set the wire resistances for more accurate readings. +//#define MAX31865_WIRE_OHMS_1 0.0f /** * Hephestos 2 24V heated bed upgrade kit. @@ -186,7 +192,8 @@ //#define CHAMBER_FAN // Enable a fan on the chamber #if ENABLED(CHAMBER_FAN) - #define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve; 3=similar to 1 but fan is always on. + //#define CHAMBER_FAN_INDEX 2 // Index of a fan to repurpose as the chamber fan. (Default: first unused fan) + #define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve; 3=similar to 1 but fan is always on. #if CHAMBER_FAN_MODE == 0 #define CHAMBER_FAN_BASE 255 // Chamber fan PWM (0-255) #elif CHAMBER_FAN_MODE == 1 @@ -329,14 +336,22 @@ * Thermal Protection parameters for the laser cooler. */ #if ENABLED(THERMAL_PROTECTION_COOLER) - #define THERMAL_PROTECTION_COOLER_PERIOD 10 // Seconds - #define THERMAL_PROTECTION_COOLER_HYSTERESIS 3 // Degrees Celsius + #define THERMAL_PROTECTION_COOLER_PERIOD 10 // Seconds + #define THERMAL_PROTECTION_COOLER_HYSTERESIS 3 // Degrees Celsius /** * Laser cooling watch settings (M143/M193). */ - #define WATCH_COOLER_TEMP_PERIOD 60 // Seconds - #define WATCH_COOLER_TEMP_INCREASE 3 // Degrees Celsius + #define WATCH_COOLER_TEMP_PERIOD 60 // Seconds + #define WATCH_COOLER_TEMP_INCREASE 3 // Degrees Celsius +#endif + +#if ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_COOLER) + /** + * Thermal Protection Variance Monitor - EXPERIMENTAL. + * Kill the machine on a stuck temperature sensor. Disable if you get false positives. + */ + //#define THERMAL_PROTECTION_VARIANCE_MONITOR // Detect a sensor malfunction preventing temperature updates #endif #if ENABLED(PIDTEMP) @@ -539,30 +554,41 @@ //#define FAN_MAX_PWM 128 /** - * FAST PWM FAN Settings + * Fan Fast PWM * - * Use to change the FAST FAN PWM frequency (if enabled in Configuration.h) - * Combinations of PWM Modes, prescale values and TOP resolutions are used internally to produce a - * frequency as close as possible to the desired frequency. + * Combinations of PWM Modes, prescale values and TOP resolutions are used internally + * to produce a frequency as close as possible to the desired frequency. * - * FAST_PWM_FAN_FREQUENCY [undefined by default] + * FAST_PWM_FAN_FREQUENCY * Set this to your desired frequency. - * If left undefined this defaults to F = F_CPU/(2*255*1) - * i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers. - * These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required + * For AVR, if left undefined this defaults to F = F_CPU/(2*255*1) + * i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers. + * For non AVR, if left undefined this defaults to F = 1Khz. + * This F value is only to protect the hardware from an absence of configuration + * and not to complete it when users are not aware that the frequency must be specifically set to support the target board. + * * NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior. + * Setting very high frequencies can damage your hardware. * * USE_OCR2A_AS_TOP [undefined by default] * Boards that use TIMER2 for PWM have limitations resulting in only a few possible frequencies on TIMER2: - * 16MHz MCUs: [62.5KHz, 31.4KHz (default), 7.8KHz, 3.92KHz, 1.95KHz, 977Hz, 488Hz, 244Hz, 60Hz, 122Hz, 30Hz] - * 20MHz MCUs: [78.1KHz, 39.2KHz (default), 9.77KHz, 4.9KHz, 2.44KHz, 1.22KHz, 610Hz, 305Hz, 153Hz, 76Hz, 38Hz] + * 16MHz MCUs: [62.5kHz, 31.4kHz (default), 7.8kHz, 3.92kHz, 1.95kHz, 977Hz, 488Hz, 244Hz, 60Hz, 122Hz, 30Hz] + * 20MHz MCUs: [78.1kHz, 39.2kHz (default), 9.77kHz, 4.9kHz, 2.44kHz, 1.22kHz, 610Hz, 305Hz, 153Hz, 76Hz, 38Hz] * A greater range can be achieved by enabling USE_OCR2A_AS_TOP. But note that this option blocks the use of * PWM on pin OC2A. Only use this option if you don't need PWM on 0C2A. (Check your schematic.) * USE_OCR2A_AS_TOP sacrifices duty cycle control resolution to achieve this broader range of frequencies. */ +//#define FAST_PWM_FAN // Increase the fan PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino #if ENABLED(FAST_PWM_FAN) - //#define FAST_PWM_FAN_FREQUENCY 31400 + //#define FAST_PWM_FAN_FREQUENCY 31400 // Define here to override the defaults below //#define USE_OCR2A_AS_TOP + #ifndef FAST_PWM_FAN_FREQUENCY + #ifdef __AVR__ + #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) + #else + #define FAST_PWM_FAN_FREQUENCY 1000U + #endif + #endif #endif /** @@ -603,6 +629,40 @@ #define COOLER_AUTO_FAN_TEMPERATURE 18 #define COOLER_AUTO_FAN_SPEED 255 +/** + * Hotend Cooling Fans tachometers + * + * Define one or more tachometer pins to enable fan speed + * monitoring, and reporting of fan speeds with M123. + * + * NOTE: Only works with fans up to 7000 RPM. + */ +//#define FOURWIRES_FANS // Needed with AUTO_FAN when 4-wire PWM fans are installed +//#define E0_FAN_TACHO_PIN -1 +//#define E0_FAN_TACHO_PULLUP +//#define E0_FAN_TACHO_PULLDOWN +//#define E1_FAN_TACHO_PIN -1 +//#define E1_FAN_TACHO_PULLUP +//#define E1_FAN_TACHO_PULLDOWN +//#define E2_FAN_TACHO_PIN -1 +//#define E2_FAN_TACHO_PULLUP +//#define E2_FAN_TACHO_PULLDOWN +//#define E3_FAN_TACHO_PIN -1 +//#define E3_FAN_TACHO_PULLUP +//#define E3_FAN_TACHO_PULLDOWN +//#define E4_FAN_TACHO_PIN -1 +//#define E4_FAN_TACHO_PULLUP +//#define E4_FAN_TACHO_PULLDOWN +//#define E5_FAN_TACHO_PIN -1 +//#define E5_FAN_TACHO_PULLUP +//#define E5_FAN_TACHO_PULLDOWN +//#define E6_FAN_TACHO_PIN -1 +//#define E6_FAN_TACHO_PULLUP +//#define E6_FAN_TACHO_PULLDOWN +//#define E7_FAN_TACHO_PIN -1 +//#define E7_FAN_TACHO_PULLUP +//#define E7_FAN_TACHO_PULLDOWN + /** * Part-Cooling Fan Multiplexer * @@ -751,18 +811,17 @@ */ //#define DUAL_X_CARRIAGE #if ENABLED(DUAL_X_CARRIAGE) - #define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS - #define X1_MAX_POS X_BED_SIZE // Set a maximum so the first X-carriage can't hit the parked second X-carriage - #define X2_MIN_POS 80 // Set a minimum to ensure the second X-carriage can't hit the parked first X-carriage - #define X2_MAX_POS 353 // Set this to the distance between toolheads when both heads are homed - #define X2_HOME_DIR 1 // Set to 1. The second X-carriage always homes to the maximum endstop position - #define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS. - // However: In this mode the HOTEND_OFFSET_X value for the second extruder provides a software - // override for X2_HOME_POS. This also allow recalibration of the distance between the two endstops - // without modifying the firmware (through the "M218 T1 X???" command). - // Remember: you should set the second extruder x-offset to 0 in your slicer. - - // This is the default power-up mode which can be later using M605. + #define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS + #define X1_MAX_POS X_BED_SIZE // A max coordinate so the X1 carriage can't hit the parked X2 carriage + #define X2_MIN_POS 80 // A min coordinate so the X2 carriage can't hit the parked X1 carriage + #define X2_MAX_POS 353 // The max position of the X2 carriage, typically also the home position + #define X2_HOME_DIR 1 // Set to 1. The X2 carriage always homes to the max endstop position + #define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS. + // NOTE: For Dual X Carriage use M218 T1 Xn to override the X2_HOME_POS. + // This allows recalibration of endstops distance without a rebuild. + // Remember to set the second extruder's X-offset to 0 in your slicer. + + // This is the default power-up mode which can be changed later using M605 S. #define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE // Default x offset in duplication mode (typically set to half print bed width) @@ -853,12 +912,14 @@ //#define BLTOUCH_FORCE_MODE_SET /** - * Use "HIGH SPEED" mode for probing. + * Enable "HIGH SPEED" option for probing. * Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems. * This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians * might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM. + * + * Set the default state here, change with 'M401 S' or UI, use M500 to save, M502 to reset. */ - //#define BLTOUCH_HS_MODE + //#define BLTOUCH_HS_MODE true // Safety: Enable voltage mode settings in the LCD menu. //#define BLTOUCH_LCD_VOLTAGE_MENU @@ -901,15 +962,17 @@ //#define Z_STEPPERS_ORIENTATION 0 #endif - // Provide Z stepper positions for more rapid convergence in bed alignment. - // Requires triple stepper drivers (i.e., set NUM_Z_STEPPER_DRIVERS to 3) - //#define Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - // Define Stepper XY positions for Z1, Z2, Z3 corresponding to - // the Z screw positions in the bed carriage. - // Define one position per Z stepper in stepper driver order. - #define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } } - #else + /** + * Z Stepper positions for more rapid convergence in bed alignment. + * Requires NUM_Z_STEPPER_DRIVERS to be 3 or 4. + * + * Define Stepper XY positions for Z1, Z2, Z3... corresponding to the screw + * positions in the bed carriage, with one position per Z stepper in stepper + * driver order. + */ + //#define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } } + + #ifndef Z_STEPPER_ALIGN_STEPPER_XY // Amplification factor. Used to scale the correction step up or down in case // the stepper (spindle) position is farther out than the test point. #define Z_STEPPER_ALIGN_AMP 1.0 // Use a value > 1.0 NOTE: This may cause instability! @@ -1196,7 +1259,7 @@ // @section lcd -#if ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2) +#if HAS_MANUAL_MOVE_MENU #define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/min) Feedrates for manual moves along X, Y, Z, E from panel #define FINE_MANUAL_MOVE 0.025 // (mm) Smallest manual move (< 0.1mm) applying to Z on most machines #if IS_ULTIPANEL @@ -1219,21 +1282,41 @@ #define FEEDRATE_CHANGE_BEEP_FREQUENCY 440 #endif -#if HAS_LCD_MENU +// +// LCD Backlight Timeout +// +//#define LCD_BACKLIGHT_TIMEOUT 30 // (s) Timeout before turning off the backlight + +#if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI) + //#define PROBE_OFFSET_WIZARD // Add a Probe Z Offset calibration option to the LCD menu + #if ENABLED(PROBE_OFFSET_WIZARD) + /** + * Enable to init the Probe Z-Offset when starting the Wizard. + * Use a height slightly above the estimated nozzle-to-probe Z offset. + * For example, with an offset of -5, consider a starting height of -4. + */ + //#define PROBE_OFFSET_WIZARD_START_Z -4.0 + + // Set a convenient position to do the calibration (probing point and nozzle/bed-distance) + //#define PROBE_OFFSET_WIZARD_XY_POS { X_CENTER, Y_CENTER } + #endif +#endif + +#if HAS_MARLINUI_MENU - // Add Probe Z Offset calibration to the Z Probe Offsets menu #if HAS_BED_PROBE - //#define PROBE_OFFSET_WIZARD - #if ENABLED(PROBE_OFFSET_WIZARD) - // - // Enable to init the Probe Z-Offset when starting the Wizard. - // Use a height slightly above the estimated nozzle-to-probe Z offset. - // For example, with an offset of -5, consider a starting height of -4. - // - //#define PROBE_OFFSET_WIZARD_START_Z -4.0 - - // Set a convenient position to do the calibration (probing point and nozzle/bed-distance) - //#define PROBE_OFFSET_WIZARD_XY_POS { X_CENTER, Y_CENTER } + // Add calibration in the Probe Offsets menu to compensate for X-axis twist. + //#define X_AXIS_TWIST_COMPENSATION + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + /** + * Enable to init the Probe Z-Offset when starting the Wizard. + * Use a height slightly above the estimated nozzle-to-probe Z offset. + * For example, with an offset of -5, consider a starting height of -4. + */ + #define XATC_START_Z 0.0 + #define XATC_MAX_POINTS 3 // Number of points to probe in the wizard + #define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe + #define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points #endif #endif @@ -1246,8 +1329,37 @@ // BACK menu items keep the highlight at the top //#define TURBO_BACK_MENU_ITEM - // Add a mute option to the LCD menu - //#define SOUND_MENU_ITEM + // Insert a menu for preheating at the top level to allow for quick access + //#define PREHEAT_SHORTCUT_MENU_ITEM + +#endif // HAS_MARLINUI_MENU + +#if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + //#define SOUND_MENU_ITEM // Add a mute option to the LCD menu +#endif + +#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) + // The timeout (in ms) to return to the status screen from sub-menus + //#define LCD_TIMEOUT_TO_STATUS 15000 + + #if ENABLED(SHOW_BOOTSCREEN) + #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) + #if EITHER(HAS_MARLINUI_U8GLIB, TFT_COLOR_UI) + #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash) + #endif + #endif + + // Scroll a longer status message into view + //#define STATUS_MESSAGE_SCROLLING + + // On the Info Screen, display XY with one decimal place when possible + //#define LCD_DECIMAL_SMALL_XY + + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + + // Show the E position (filament used) during printing + //#define LCD_SHOW_E_TOTAL /** * LED Control Menu @@ -1275,33 +1387,6 @@ #endif #endif - // Insert a menu for preheating at the top level to allow for quick access - //#define PREHEAT_SHORTCUT_MENU_ITEM - -#endif // HAS_LCD_MENU - -#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) - // The timeout (in ms) to return to the status screen from sub-menus - //#define LCD_TIMEOUT_TO_STATUS 15000 - - #if ENABLED(SHOW_BOOTSCREEN) - #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) - #if EITHER(HAS_MARLINUI_U8GLIB, TFT_COLOR_UI) - #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash) - #endif - #endif - - // Scroll a longer status message into view - //#define STATUS_MESSAGE_SCROLLING - - // On the Info Screen, display XY with one decimal place when possible - //#define LCD_DECIMAL_SMALL_XY - - // Add an 'M73' G-code to set the current percentage - //#define LCD_SET_PROGRESS_MANUALLY - - // Show the E position (filament used) during printing - //#define LCD_SHOW_E_TOTAL #endif // LCD Print Progress options @@ -1448,33 +1533,23 @@ // LCD's font must contain the characters. Check your selected LCD language. //#define UTF_FILENAME_SUPPORT - // This allows hosts to request long names for files and folders with M33 - //#define LONG_FILENAME_HOST_SUPPORT + //#define LONG_FILENAME_HOST_SUPPORT // Get the long filename of a file/folder with 'M33 ' and list long filenames with 'M20 L' + //#define LONG_FILENAME_WRITE_SUPPORT // Create / delete files with long filenames via M28, M30, and Binary Transfer Protocol - // Enable this option to scroll long filenames in the SD card menu - //#define SCROLL_LONG_FILENAMES + //#define SCROLL_LONG_FILENAMES // Scroll long filenames in the SD card menu - // Leave the heaters on after Stop Print (not recommended!) - //#define SD_ABORT_NO_COOLDOWN + //#define SD_ABORT_NO_COOLDOWN // Leave the heaters on after Stop Print (not recommended!) /** - * This option allows you to abort SD printing when any endstop is triggered. - * This feature must be enabled with "M540 S1" or from the LCD menu. - * To have any effect, endstops must be enabled during SD printing. + * Abort SD printing when any endstop is triggered. + * This feature is enabled with 'M540 S1' or from the LCD menu. + * Endstops must be activated for this option to work. */ //#define SD_ABORT_ON_ENDSTOP_HIT - /** - * This option makes it easier to print the same SD Card file again. - * On print completion the LCD Menu will open with the file selected. - * You can just click to start the print, or navigate elsewhere. - */ - //#define SD_REPRINT_LAST_SELECTED_FILE + //#define SD_REPRINT_LAST_SELECTED_FILE // On print completion open the LCD Menu and select the same file - /** - * Auto-report SdCard status with M27 S - */ - //#define AUTO_REPORT_SD_STATUS + //#define AUTO_REPORT_SD_STATUS // Auto-report media status with 'M27 S' /** * Support for USB thumb drives using an Arduino USB Host Shield or @@ -1532,9 +1607,22 @@ #define SD_FIRMWARE_UPDATE_INACTIVE_VALUE 0xFF #endif + /** + * Enable this option if you have more than ~3K of unused flash space. + * Marlin will embed all settings in the firmware binary as compressed data. + * Use 'M503 C' to write the settings out to the SD Card as 'mc.zip'. + * See docs/ConfigEmbedding.md for details on how to use 'mc-apply.py'. + */ + //#define CONFIGURATION_EMBEDDING + // Add an optimized binary file transfer mode, initiated with 'M28 B1' //#define BINARY_FILE_TRANSFER + #if ENABLED(BINARY_FILE_TRANSFER) + // Include extra facilities (e.g., 'M20 F') supporting firmware upload via BINARY_FILE_TRANSFER + //#define CUSTOM_FIRMWARE_UPLOAD + #endif + /** * Set this option to one of the following (or the board's defaults apply): * @@ -1549,7 +1637,10 @@ // Enable if SD detect is rendered useless (e.g., by using an SD extender) //#define NO_SD_DETECT - // Multiple volume support - EXPERIMENTAL. + /** + * Multiple volume support - EXPERIMENTAL. + * Adds 'M21 Pm' / 'M21 S' / 'M21 U' to mount SD Card / USB Drive. + */ //#define MULTI_VOLUME #if ENABLED(MULTI_VOLUME) #define VOLUME_SD_ONBOARD @@ -1632,7 +1723,7 @@ //#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap //#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames //#define STATUS_HEAT_PERCENT // Show heating in a progress bar - //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~‭3260 (or ~940) bytes of PROGMEM. + //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of PROGMEM. // Frivolous Game Options //#define MARLIN_BRICKOUT @@ -2260,6 +2351,15 @@ // For serial echo, the number of digits after the decimal point //#define SERIAL_FLOAT_PRECISION 4 +/** + * Set the number of proportional font spaces required to fill up a typical character space. + * This can help to better align the output of commands like `G29 O` Mesh Output. + * + * For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0. + * Otherwise, adjust according to your client and font. + */ +#define PROPORTIONAL_FONT_RATIO 1.0 + // @section extras /** @@ -2340,26 +2440,26 @@ #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) // Load / Unload #define TOOLCHANGE_FS_LENGTH 12 // (mm) Load / Unload length - #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart, fine tune by LCD/Gcode) + #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart. Adjust with LCD or M217 B. #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/min) (Unloading) #define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/min) (On SINGLENOZZLE or Bowden loading must be slowed down) // Longer prime to clean out a SINGLENOZZLE #define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length #define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/min) Extra priming feedrate - #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm/min) Retract before cooling for less stringing, better wipe, etc. + #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Retract before cooling for less stringing, better wipe, etc. // Cool after prime to reduce stringing #define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip #define TOOLCHANGE_FS_FAN_SPEED 255 // 0-255 #define TOOLCHANGE_FS_FAN_TIME 10 // (seconds) - // Swap uninitialized extruder with TOOLCHANGE_FS_PRIME_SPEED for all lengths (recover + prime) + // Swap uninitialized extruder (using TOOLCHANGE_FS_PRIME_SPEED feedrate) // (May break filament if not retracted beforehand.) //#define TOOLCHANGE_FS_INIT_BEFORE_SWAP - // Prime on the first T0 (If other, TOOLCHANGE_FS_INIT_BEFORE_SWAP applied) - // Enable it (M217 V[0/1]) before printing, to avoid unwanted priming on host connect + // Prime on the first T0 (For other tools use TOOLCHANGE_FS_INIT_BEFORE_SWAP) + // Enable with M217 V1 before printing to avoid unwanted priming on host connect //#define TOOLCHANGE_FS_PRIME_FIRST_USED /** @@ -2608,6 +2708,7 @@ #define X_RSENSE 0.11 #define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ... //#define X_INTERPOLATE true // Enable to override 'INTERPOLATE' for the X axis + //#define X_HOLD_MULTIPLIER 0.5 // Enable to override 'HOLD_MULTIPLIER' for the X axis #endif #if AXIS_IS_TMC(X2) @@ -2617,6 +2718,7 @@ #define X2_RSENSE 0.11 #define X2_CHAIN_POS -1 //#define X2_INTERPOLATE true + //#define X2_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(Y) @@ -2626,6 +2728,7 @@ #define Y_RSENSE 0.11 #define Y_CHAIN_POS -1 //#define Y_INTERPOLATE true + //#define Y_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(Y2) @@ -2635,6 +2738,7 @@ #define Y2_RSENSE 0.11 #define Y2_CHAIN_POS -1 //#define Y2_INTERPOLATE true + //#define Y2_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(Z) @@ -2644,6 +2748,7 @@ #define Z_RSENSE 0.11 #define Z_CHAIN_POS -1 //#define Z_INTERPOLATE true + //#define Z_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(Z2) @@ -2653,6 +2758,7 @@ #define Z2_RSENSE 0.11 #define Z2_CHAIN_POS -1 //#define Z2_INTERPOLATE true + //#define Z2_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(Z3) @@ -2662,6 +2768,7 @@ #define Z3_RSENSE 0.11 #define Z3_CHAIN_POS -1 //#define Z3_INTERPOLATE true + //#define Z3_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(Z4) @@ -2671,6 +2778,7 @@ #define Z4_RSENSE 0.11 #define Z4_CHAIN_POS -1 //#define Z4_INTERPOLATE true + //#define Z4_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(I) @@ -2680,6 +2788,7 @@ #define I_RSENSE 0.11 #define I_CHAIN_POS -1 //#define I_INTERPOLATE true + //#define I_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(J) @@ -2689,6 +2798,7 @@ #define J_RSENSE 0.11 #define J_CHAIN_POS -1 //#define J_INTERPOLATE true + //#define J_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(K) @@ -2698,6 +2808,7 @@ #define K_RSENSE 0.11 #define K_CHAIN_POS -1 //#define K_INTERPOLATE true + //#define K_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(E0) @@ -2706,6 +2817,7 @@ #define E0_RSENSE 0.11 #define E0_CHAIN_POS -1 //#define E0_INTERPOLATE true + //#define E0_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(E1) @@ -2714,6 +2826,7 @@ #define E1_RSENSE 0.11 #define E1_CHAIN_POS -1 //#define E1_INTERPOLATE true + //#define E1_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(E2) @@ -2722,6 +2835,7 @@ #define E2_RSENSE 0.11 #define E2_CHAIN_POS -1 //#define E2_INTERPOLATE true + //#define E2_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(E3) @@ -2730,6 +2844,7 @@ #define E3_RSENSE 0.11 #define E3_CHAIN_POS -1 //#define E3_INTERPOLATE true + //#define E3_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(E4) @@ -2738,6 +2853,7 @@ #define E4_RSENSE 0.11 #define E4_CHAIN_POS -1 //#define E4_INTERPOLATE true + //#define E4_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(E5) @@ -2746,6 +2862,7 @@ #define E5_RSENSE 0.11 #define E5_CHAIN_POS -1 //#define E5_INTERPOLATE true + //#define E5_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(E6) @@ -2754,6 +2871,7 @@ #define E6_RSENSE 0.11 #define E6_CHAIN_POS -1 //#define E6_INTERPOLATE true + //#define E6_HOLD_MULTIPLIER 0.5 #endif #if AXIS_IS_TMC(E7) @@ -2762,6 +2880,7 @@ #define E7_RSENSE 0.11 #define E7_CHAIN_POS -1 //#define E7_INTERPOLATE true + //#define E7_HOLD_MULTIPLIER 0.5 #endif /** @@ -2874,6 +2993,9 @@ //#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z4 CHOPPER_TIMING_Z + //#define CHOPPER_TIMING_I CHOPPER_TIMING + //#define CHOPPER_TIMING_J CHOPPER_TIMING + //#define CHOPPER_TIMING_K CHOPPER_TIMING //#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below) //#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E @@ -3111,7 +3233,7 @@ #define Z4_SLEW_RATE 1 #endif - #if AXIS_DRIVER_TYPE_I(L6470) + #if AXIS_IS_L64XX(I) #define I_MICROSTEPS 128 #define I_OVERCURRENT 2000 #define I_STALLCURRENT 1500 @@ -3120,7 +3242,7 @@ #define I_SLEW_RATE 1 #endif - #if AXIS_DRIVER_TYPE_J(L6470) + #if AXIS_IS_L64XX(J) #define J_MICROSTEPS 128 #define J_OVERCURRENT 2000 #define J_STALLCURRENT 1500 @@ -3129,7 +3251,7 @@ #define J_SLEW_RATE 1 #endif - #if AXIS_DRIVER_TYPE_K(L6470) + #if AXIS_IS_L64XX(K) #define K_MICROSTEPS 128 #define K_OVERCURRENT 2000 #define K_STALLCURRENT 1500 @@ -3332,7 +3454,7 @@ * You'll need to select a pin for the ON/OFF function and optionally choose a 0-5V * hardware PWM pin for the speed control and a pin for the rotation direction. * - * See https://marlinfw.org/docs/configuration/laser_spindle.html for more config details. + * See https://marlinfw.org/docs/configuration/2.0.9/laser_spindle.html for more config details. */ //#define SPINDLE_FEATURE //#define LASER_FEATURE @@ -3342,7 +3464,7 @@ #define SPINDLE_LASER_USE_PWM // Enable if your controller supports setting the speed/power #if ENABLED(SPINDLE_LASER_USE_PWM) #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower - #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC) + #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32 and LPC) #endif //#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11 @@ -3606,6 +3728,12 @@ */ //#define CNC_COORDINATE_SYSTEMS +/** + * Auto-report fan speed with M123 S + * Requires fans with tachometer pins + */ +//#define AUTO_REPORT_FANS + /** * Auto-report temperatures with M155 S */ @@ -3675,15 +3803,6 @@ //#define REPORT_FAN_CHANGE // Report the new fan speed when changed by M106 (and others) -/** - * Set the number of proportional font spaces required to fill up a typical character space. - * This can help to better align the output of commands like `G29 O` Mesh Output. - * - * For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0. - * Otherwise, adjust according to your client and font. - */ -#define PROPORTIONAL_FONT_RATIO 1.0 - /** * Spend 28 bytes of SRAM to optimize the G-code parser */ @@ -3847,10 +3966,13 @@ */ //#define HOST_ACTION_COMMANDS #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_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down + //#define HOST_PAUSE_M76 // Tell the host to pause in response to M76 + //#define HOST_PROMPT_SUPPORT // Initiate host prompts to get user feedback + #if ENABLED(HOST_PROMPT_SUPPORT) + //#define HOST_STATUS_NOTIFICATIONS // Send some status messages to the host as notifications + #endif + //#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 /** diff --git a/Marlin/Makefile b/Marlin/Makefile index d09e5828f5b2..eee1403b537c 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -191,6 +191,134 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1034) # RAMPS Derivatives - ATmega1280, ATmega2560 # +# 3Drag Controller +else ifeq ($(HARDWARE_MOTHERBOARD),1100) +# Velleman K8200 Controller (derived from 3Drag Controller) +else ifeq ($(HARDWARE_MOTHERBOARD),1101) +# Velleman K8400 Controller (derived from 3Drag Controller) +else ifeq ($(HARDWARE_MOTHERBOARD),1102) +# Velleman K8600 Controller (Vertex Nano) +else ifeq ($(HARDWARE_MOTHERBOARD),1103) +# Velleman K8800 Controller (Vertex Delta) +else ifeq ($(HARDWARE_MOTHERBOARD),1104) +# 2PrintBeta BAM&DICE with STK drivers +else ifeq ($(HARDWARE_MOTHERBOARD),1105) +# 2PrintBeta BAM&DICE Due with STK drivers +else ifeq ($(HARDWARE_MOTHERBOARD),1106) +# MKS BASE v1.0 +else ifeq ($(HARDWARE_MOTHERBOARD),1107) +# MKS BASE v1.4 with Allegro A4982 stepper drivers +else ifeq ($(HARDWARE_MOTHERBOARD),1108) +# MKS BASE v1.5 with Allegro A4982 stepper drivers +else ifeq ($(HARDWARE_MOTHERBOARD),1109) +# MKS BASE v1.6 with Allegro A4982 stepper drivers +else ifeq ($(HARDWARE_MOTHERBOARD),1110) +# MKS BASE 1.0 with Heroic HR4982 stepper drivers +else ifeq ($(HARDWARE_MOTHERBOARD),1111) +# MKS GEN v1.3 or 1.4 +else ifeq ($(HARDWARE_MOTHERBOARD),1112) +# MKS GEN L +else ifeq ($(HARDWARE_MOTHERBOARD),1113) +# BigTreeTech or BIQU KFB2.0 +else ifeq ($(HARDWARE_MOTHERBOARD),1114) +# zrib V2.0 (Chinese RAMPS replica) +else ifeq ($(HARDWARE_MOTHERBOARD),1115) +# zrib V5.2 (Chinese RAMPS replica) +else ifeq ($(HARDWARE_MOTHERBOARD),1116) +# Felix 2.0+ Electronics Board (RAMPS like) +else ifeq ($(HARDWARE_MOTHERBOARD),1117) +# Invent-A-Part RigidBoard +else ifeq ($(HARDWARE_MOTHERBOARD),1118) +# Invent-A-Part RigidBoard V2 +else ifeq ($(HARDWARE_MOTHERBOARD),1119) +# Sainsmart 2-in-1 board +else ifeq ($(HARDWARE_MOTHERBOARD),1120) +# Ultimaker +else ifeq ($(HARDWARE_MOTHERBOARD),1121) +# Ultimaker (Older electronics. Pre 1.5.4. This is rare) +else ifeq ($(HARDWARE_MOTHERBOARD),1122) + MCU ?= atmega1280 + PROG_MCU ?= m1280 +# Azteeg X3 +else ifeq ($(HARDWARE_MOTHERBOARD),1123) +# Azteeg X3 Pro +else ifeq ($(HARDWARE_MOTHERBOARD),1124) +# Ultimainboard 2.x (Uses TEMP_SENSOR 20) +else ifeq ($(HARDWARE_MOTHERBOARD),1125) +# Rumba +else ifeq ($(HARDWARE_MOTHERBOARD),1126) +# Raise3D N series Rumba derivative +else ifeq ($(HARDWARE_MOTHERBOARD),1127) +# Rapide Lite 200 (v1, low-cost RUMBA clone with drv) +else ifeq ($(HARDWARE_MOTHERBOARD),1128) +# Formbot T-Rex 2 Plus +else ifeq ($(HARDWARE_MOTHERBOARD),1129) +# Formbot T-Rex 3 +else ifeq ($(HARDWARE_MOTHERBOARD),1130) +# Formbot Raptor +else ifeq ($(HARDWARE_MOTHERBOARD),1131) +# Formbot Raptor 2 +else ifeq ($(HARDWARE_MOTHERBOARD),1132) +# bq ZUM Mega 3D +else ifeq ($(HARDWARE_MOTHERBOARD),1133) +# MakeBoard Mini v2.1.2 by MicroMake +else ifeq ($(HARDWARE_MOTHERBOARD),1134) +# TriGorilla Anycubic version 1.3-based on RAMPS EFB +else ifeq ($(HARDWARE_MOTHERBOARD),1135) +# ... Ver 1.4 +else ifeq ($(HARDWARE_MOTHERBOARD),1136) +# ... Rev 1.1 (new servo pin order) +else ifeq ($(HARDWARE_MOTHERBOARD),1137) +# Creality: Ender-4, CR-8 +else ifeq ($(HARDWARE_MOTHERBOARD),1138) +# Creality: CR10S, CR20, CR-X +else ifeq ($(HARDWARE_MOTHERBOARD),1139) +# Dagoma F5 +else ifeq ($(HARDWARE_MOTHERBOARD),1140) +# FYSETC F6 1.3 +else ifeq ($(HARDWARE_MOTHERBOARD),1141) +# FYSETC F6 1.4 +else ifeq ($(HARDWARE_MOTHERBOARD),1142) +# Wanhao Duplicator i3 Plus +else ifeq ($(HARDWARE_MOTHERBOARD),1143) +# VORON Design +else ifeq ($(HARDWARE_MOTHERBOARD),1144) +# Tronxy TRONXY-V3-1.0 +else ifeq ($(HARDWARE_MOTHERBOARD),1145) +# Z-Bolt X Series +else ifeq ($(HARDWARE_MOTHERBOARD),1146) +# TT OSCAR +else ifeq ($(HARDWARE_MOTHERBOARD),1147) +# Overlord/Overlord Pro +else ifeq ($(HARDWARE_MOTHERBOARD),1148) +# ADIMLab Gantry v1 +else ifeq ($(HARDWARE_MOTHERBOARD),1149) +# ADIMLab Gantry v2 +else ifeq ($(HARDWARE_MOTHERBOARD),1150) +# BIQU Tango V1 +else ifeq ($(HARDWARE_MOTHERBOARD),1151) +# MKS GEN L V2 +else ifeq ($(HARDWARE_MOTHERBOARD),1152) +# MKS GEN L V2.1 +else ifeq ($(HARDWARE_MOTHERBOARD),1153) +# Copymaster 3D +else ifeq ($(HARDWARE_MOTHERBOARD),1154) +# Ortur 4 +else ifeq ($(HARDWARE_MOTHERBOARD),1155) +# Tenlog D3 Hero IDEX printer +else ifeq ($(HARDWARE_MOTHERBOARD),1156) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) +else ifeq ($(HARDWARE_MOTHERBOARD),1157) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) +else ifeq ($(HARDWARE_MOTHERBOARD),1158) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) +else ifeq ($(HARDWARE_MOTHERBOARD),1159) +# Longer LK1 PRO / Alfawise U20 Pro (PRO version) +else ifeq ($(HARDWARE_MOTHERBOARD),1160) +# Longer LKx PRO / Alfawise Uxx Pro (PRO version) +else ifeq ($(HARDWARE_MOTHERBOARD),1161) + + # 3Drag Controller else ifeq ($(HARDWARE_MOTHERBOARD),1100) # Velleman K8200 Controller (derived from 3Drag Controller) @@ -358,20 +486,38 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1311) else ifeq ($(HARDWARE_MOTHERBOARD),1312) # Mega controller else ifeq ($(HARDWARE_MOTHERBOARD),1313) -# Geeetech GT2560 Rev B for Mecreator2 +# Geeetech GT2560 Rev A else ifeq ($(HARDWARE_MOTHERBOARD),1314) -# Geeetech GT2560 Rev. A +# Geeetech GT2560 Rev A+ (with auto level probe) else ifeq ($(HARDWARE_MOTHERBOARD),1315) -# Geeetech GT2560 Rev. A+ (with auto level probe) +# Geeetech GT2560 Rev B else ifeq ($(HARDWARE_MOTHERBOARD),1316) -# Geeetech GT2560 Rev B for A10(M/D) +# Geeetech GT2560 Rev B for A10(M/T/D) else ifeq ($(HARDWARE_MOTHERBOARD),1317) -# Geeetech GT2560 Rev B for A20(M/D) +# Geeetech GT2560 Rev B for A10(M/T/D) else ifeq ($(HARDWARE_MOTHERBOARD),1318) -# Einstart retrofit +# Geeetech GT2560 Rev B for Mecreator2 else ifeq ($(HARDWARE_MOTHERBOARD),1319) -# Wanhao 0ne+ i3 Mini +# Geeetech GT2560 Rev B for A20(M/T/D) else ifeq ($(HARDWARE_MOTHERBOARD),1320) +# Einstart retrofit +else ifeq ($(HARDWARE_MOTHERBOARD),1321) +# Wanhao 0ne+ i3 Mini +else ifeq ($(HARDWARE_MOTHERBOARD),1322) +# Leapfrog Xeed 2015 +else ifeq ($(HARDWARE_MOTHERBOARD),1323) +# PICA Shield (original version) +else ifeq ($(HARDWARE_MOTHERBOARD),1324) +# PICA Shield (rev C or later) +else ifeq ($(HARDWARE_MOTHERBOARD),1325) +# Intamsys 4.0 (Funmat HT) +else ifeq ($(HARDWARE_MOTHERBOARD),1326) +# Malyan M180 Mainboard Version 2 (no display function, direct gcode only) +else ifeq ($(HARDWARE_MOTHERBOARD),1327) +# Geeetech GT2560 Rev B for A20(M/T/D) +else ifeq ($(HARDWARE_MOTHERBOARD),1328) +# Mega controller & Protoneer CNC Shield V3.00 +else ifeq ($(HARDWARE_MOTHERBOARD),1329) # # ATmega1281, ATmega2561 @@ -445,6 +591,11 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1510) HARDWARE_VARIANT ?= Sanguino MCU ?= atmega1284p PROG_MCU ?= m1284p +# ZoneStar ZMIB V2 +else ifeq ($(HARDWARE_MOTHERBOARD),1511) + HARDWARE_VARIANT ?= Sanguino + MCU ?= atmega1284p + PROG_MCU ?= m1284p # # Other ATmega644P, ATmega644, ATmega1284P diff --git a/Marlin/Version.h b/Marlin/Version.h index 1643741f4977..459bbc1b804a 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-11-12" +//#define STRING_DISTRIBUTION_DATE "2022-03-21" /** * 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 d7bf2a6f6fbb..7c39c5200b4d 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -36,7 +36,7 @@ // ------------------------ // Don't initialize/override variable (which would happen in .init4) -uint8_t reset_reason __attribute__((section(".noinit"))); +uint8_t MarlinHAL::reset_reason __attribute__((section(".noinit"))); // ------------------------ // Public functions @@ -45,22 +45,22 @@ uint8_t reset_reason __attribute__((section(".noinit"))); __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() { +void save_reset_reason() { #if ENABLED(OPTIBOOT_RESET_REASON) __asm__ __volatile__( A("STS %0, r2") - : "=m"(reset_reason) + : "=m"(hal.reset_reason) ); #else - reset_reason = MCUSR; + hal.reset_reason = MCUSR; #endif // Clear within 16ms since WDRF bit enables a 16ms watchdog timer -> Boot loop - MCUSR = 0; + hal.clear_reset_source(); wdt_disable(); } -void HAL_init() { +void MarlinHAL::init() { // Init Servo Pins #define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW) #if HAS_SERVO_0 @@ -75,9 +75,11 @@ void HAL_init() { #if HAS_SERVO_3 INIT_SERVO(3); #endif + + init_pwm_timers(); // Init user timers to default frequency - 1000HZ } -void HAL_reboot() { +void MarlinHAL::reboot() { #if ENABLED(USE_WATCHDOG) while (1) { /* run out the watchdog */ } #else @@ -93,20 +95,20 @@ void HAL_reboot() { #else // !SDSUPPORT -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; - - int freeMemory() { - int free_memory; - if ((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - return free_memory; + extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; + + int freeMemory() { + int free_memory; + if ((int)__brkval == 0) + free_memory = ((int)&free_memory) - ((int)&__bss_end); + else + free_memory = ((int)&free_memory) - ((int)__brkval); + return free_memory; + } } -} #endif // !SDSUPPORT diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 2217f239d64e..e825b4def3af 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -74,9 +74,9 @@ #define CRITICAL_SECTION_START() unsigned char _sreg = SREG; cli() #define CRITICAL_SECTION_END() SREG = _sreg #endif -#define ISRS_ENABLED() TEST(SREG, SREG_I) -#define ENABLE_ISRS() sei() -#define DISABLE_ISRS() cli() + +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment +#define PWM_FREQUENCY 1000 // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() // ------------------------ // Types @@ -84,16 +84,15 @@ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // ------------------------ -// Public Variables +// Serial ports // ------------------------ -extern uint8_t reset_reason; - -// Serial ports #ifdef USBCON #include "../../core/serial_hook.h" typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; @@ -142,20 +141,31 @@ extern uint8_t reset_reason; #endif #endif -// ------------------------ -// Public functions -// ------------------------ +// +// ADC +// +#define HAL_ADC_VREF 5.0 +#define HAL_ADC_RESOLUTION 10 -void HAL_init(); +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -//void cli(); +#define HAL_SENSITIVE_PINS 0, 1, -//void _delay_ms(const int delay); +#ifdef __AVR_AT90USB1286__ + #define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0) +#endif -inline void HAL_clear_reset_source() { } -inline uint8_t HAL_get_reset_source() { return reset_reason; } +// AVR compatibility +#define strtof strtod -void HAL_reboot(); +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -166,63 +176,96 @@ extern "C" int freeMemory(); #pragma GCC diagnostic pop -// ADC -#ifdef DIDR2 - #define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0) -#else - #define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind); -#endif +// ------------------------ +// MarlinHAL Class +// ------------------------ -inline void HAL_adc_init() { - ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07; - DIDR0 = 0; - #ifdef DIDR2 - DIDR2 = 0; - #endif -} +class MarlinHAL { +public: -#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC) -#ifdef MUX5 - #define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch) -#else - #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch) -#endif + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ADC_VREF 5.0 -#define HAL_ADC_RESOLUTION 10 -#define HAL_READ_ADC() ADC -#define HAL_ADC_READY() !TEST(ADCSRA, ADSC) + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Interrupts + static bool isr_state() { return TEST(SREG, SREG_I); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } -#define HAL_SENSITIVE_PINS 0, 1, + static void delay_ms(const int ms) { _delay_ms(ms); } -#ifdef __AVR_AT90USB1286__ - #define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0) -#endif + // Tasks, called from idle() + static void idletask() {} -// AVR compatibility -#define strtof strtod + // Reset + static uint8_t reset_reason; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() { MCUSR = 0; } -#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment + // Free SRAM + static int freeMemory() { return ::freeMemory(); } -/** - * set_pwm_frequency - * Sets the frequency of the timer corresponding to the provided pin - * as close as possible to the provided desired frequency. Internally - * calculates the required waveform generation mode, prescaler and - * resolution values required and sets the timer registers accordingly. - * NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B) - * NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST FAN PWM Settings) - */ -void set_pwm_frequency(const pin_t pin, int f_desired); + // + // ADC Methods + // -/** - * set_pwm_duty - * 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] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + // Called by Temperature::init once at startup + static void adc_init() { + ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07; + DIDR0 = 0; + #ifdef DIDR2 + DIDR2 = 0; + #endif + } + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) { + #ifdef DIDR2 + if (ch > 7) { SBI(DIDR2, ch & 0x07); return; } + #endif + SBI(DIDR0, ch); + } + + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch) { + #ifdef MUX5 + ADCSRB = ch > 7 ? _BV(MUX5) : 0; + #else + ADCSRB = 0; + #endif + ADMUX = _BV(REFS0) | (ch & 0x07); + SBI(ADCSRA, ADSC); + } + + // Is the ADC ready for reading? + static bool adc_ready() { return !TEST(ADCSRA, ADSC); } + + // The current value of the ADC register + static __typeof__(ADC) adc_value() { return ADC; } + + /** + * init_pwm_timers + * Set the default frequency for timers 2-5 to 1000HZ + */ + static void init_pwm_timers(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + + /** + * Set the frequency of the timer for the given pin as close as + * possible to the provided desired frequency. Internally calculate + * the required waveform generation mode, prescaler, and resolution + * values and set timer registers accordingly. + * NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B) + * NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST_PWM_FAN Settings) + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +}; diff --git a/Marlin/src/HAL/AVR/HAL_SPI.cpp b/Marlin/src/HAL/AVR/HAL_SPI.cpp index 8784bb07b30e..dc98f2f79e71 100644 --- a/Marlin/src/HAL/AVR/HAL_SPI.cpp +++ b/Marlin/src/HAL/AVR/HAL_SPI.cpp @@ -35,22 +35,20 @@ void spiBegin() { #if PIN_EXISTS(SD_SS) - OUT_WRITE(SD_SS_PIN, HIGH); + // Do not init HIGH for boards with pin 4 used as Fans or Heaters or otherwise, not likely to have multiple SPI devices anyway. + #if defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__) + // SS must be in output mode even it is not chip select + SET_OUTPUT(SD_SS_PIN); + #else + // set SS high - may be chip select for another SPI device + OUT_WRITE(SD_SS_PIN, HIGH); + #endif #endif SET_OUTPUT(SD_SCK_PIN); SET_INPUT(SD_MISO_PIN); SET_OUTPUT(SD_MOSI_PIN); - #if DISABLED(SOFTWARE_SPI) - // SS must be in output mode even it is not chip select - //SET_OUTPUT(SD_SS_PIN); - // set SS high - may be chip select for another SPI device - //#if SET_SPI_SS_HIGH - //WRITE(SD_SS_PIN, HIGH); - //#endif - // set a default rate - spiInit(1); - #endif + IF_DISABLED(SOFTWARE_SPI, spiInit(SPI_HALF_SPEED)); } #if NONE(SOFTWARE_SPI, FORCE_SOFT_SPI) diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index cd8bf5e6903b..986462437c8f 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -486,7 +486,7 @@ void MarlinSerial::write(const uint8_t c) { const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Make room by polling if it is possible to transmit, and do so! while (i == tx_buffer.tail) { @@ -534,7 +534,7 @@ void MarlinSerial::flushTX() { if (!_written) return; // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Wait until everything was transmitted - We must do polling, as interrupts are disabled while (tx_buffer.head != tx_buffer.tail || !B_TXC) { diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 0565c7b9db9e..7eb76000d66e 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -191,13 +191,13 @@ rx_framing_errors; static ring_buffer_pos_t rx_max_enqueued; - static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_head(); + FORCE_INLINE static ring_buffer_pos_t atomic_read_rx_head(); static volatile bool rx_tail_value_not_stable; static volatile uint16_t rx_tail_value_backup; - static FORCE_INLINE void atomic_set_rx_tail(ring_buffer_pos_t value); - static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_tail(); + FORCE_INLINE static void atomic_set_rx_tail(ring_buffer_pos_t value); + FORCE_INLINE static ring_buffer_pos_t atomic_read_rx_tail(); public: FORCE_INLINE static void store_rxd_char(); @@ -217,7 +217,7 @@ #endif enum { HasEmergencyParser = Cfg::EMERGENCYPARSER }; - static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } + static bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } diff --git a/Marlin/src/HAL/AVR/endstop_interrupts.h b/Marlin/src/HAL/AVR/endstop_interrupts.h index 50f29c3356ce..0ce8574c53d9 100644 --- a/Marlin/src/HAL/AVR/endstop_interrupts.h +++ b/Marlin/src/HAL/AVR/endstop_interrupts.h @@ -301,5 +301,6 @@ void setup_endstop_interrupts() { pciSetup(Z_MIN_PROBE_PIN); #endif #endif + // If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI. } diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp index 2556fa044121..0a384172c32a 100644 --- a/Marlin/src/HAL/AVR/fast_pwm.cpp +++ b/Marlin/src/HAL/AVR/fast_pwm.cpp @@ -21,10 +21,7 @@ */ #ifdef __AVR__ -#include "../../inc/MarlinConfigPre.h" -#include "HAL.h" - -#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM +#include "../../inc/MarlinConfig.h" struct Timer { volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer @@ -32,249 +29,194 @@ struct Timer { volatile uint16_t* ICRn; // max 1 ICR register per timer uint8_t n; // the timer number [0->5] uint8_t q; // the timer output [0->2] (A->C) + bool isPWM; // True if pin is a "hardware timer" + bool isProtected; // True if timer is protected }; +// Macros for the Timer structure +#define _SET_WGMnQ(T, V) do{ \ + *(T.TCCRnQ)[0] = (*(T.TCCRnQ)[0] & ~(0x3 << 0)) | (( int(V) & 0x3) << 0); \ + *(T.TCCRnQ)[1] = (*(T.TCCRnQ)[1] & ~(0x3 << 3)) | (((int(V) >> 2) & 0x3) << 3); \ + }while(0) + +// Set TCCR CS bits +#define _SET_CSn(T, V) (*(T.TCCRnQ)[1] = (*(T.TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0)) + +// Set TCCR COM bits +#define _SET_COMnQ(T, Q, V) (*(T.TCCRnQ)[0] = (*(T.TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q)))) + +// Set OCRnQ register +#define _SET_OCRnQ(T, Q, V) (*(T.OCRnQ)[Q] = int(V) & 0xFFFF) + +// Set ICRn register (one per timer) +#define _SET_ICRn(T, V) (*(T.ICRn) = int(V) & 0xFFFF) + /** - * get_pwm_timer - * Get the timer information and register of the provided pin. - * Return a Timer struct containing this information. - * Used by set_pwm_frequency, set_pwm_duty + * Return a Timer struct describing a pin's timer. */ -Timer get_pwm_timer(const pin_t pin) { +const Timer get_pwm_timer(const pin_t pin) { + uint8_t q = 0; + switch (digitalPinToTimer(pin)) { - // Protect reserved timers (TIMER0 & TIMER1) #ifdef TCCR0A - #if !AVR_AT90USB1286_FAMILY - case TIMER0A: - #endif - case TIMER0B: + IF_DISABLED(AVR_AT90USB1286_FAMILY, case TIMER0A:) #endif #ifdef TCCR1A case TIMER1A: case TIMER1B: #endif - break; - #if defined(TCCR2) || defined(TCCR2A) - #ifdef TCCR2 - case TIMER2: { - Timer timer = { - /*TCCRnQ*/ { &TCCR2, nullptr, nullptr }, - /*OCRnQ*/ { (uint16_t*)&OCR2, nullptr, nullptr }, - /*ICRn*/ nullptr, - /*n, q*/ 2, 0 - }; - } - #elif defined(TCCR2A) - #if ENABLED(USE_OCR2A_AS_TOP) - case TIMER2A: break; // protect TIMER2A - case TIMER2B: { - Timer timer = { - /*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr }, - /*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr }, - /*ICRn*/ nullptr, - /*n, q*/ 2, 1 - }; - return timer; - } - #else - case TIMER2B: ++q; - case TIMER2A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr }, - /*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr }, - /*ICRn*/ nullptr, - 2, q - }; - return timer; - } - #endif - #endif + + break; // Protect reserved timers (TIMER0 & TIMER1) + + #ifdef TCCR0A + case TIMER0B: // Protected timer, but allow setting the duty cycle on OCR0B for pin D4 only + return Timer({ { &TCCR0A, nullptr, nullptr }, { (uint16_t*)&OCR0A, (uint16_t*)&OCR0B, nullptr }, nullptr, 0, 1, true, true }); #endif + + #if HAS_TCCR2 + case TIMER2: + return Timer({ { &TCCR2, nullptr, nullptr }, { (uint16_t*)&OCR2, nullptr, nullptr }, nullptr, 2, 0, true, false }); + #elif ENABLED(USE_OCR2A_AS_TOP) + case TIMER2A: break; // Protect TIMER2A since its OCR is used by TIMER2B + case TIMER2B: + return Timer({ { &TCCR2A, &TCCR2B, nullptr }, { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr }, nullptr, 2, 1, true, false }); + #elif defined(TCCR2A) + case TIMER2B: ++q; case TIMER2A: + return Timer({ { &TCCR2A, &TCCR2B, nullptr }, { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr }, nullptr, 2, q, true, false }); + #endif + #ifdef OCR3C - case TIMER3C: ++q; - case TIMER3B: ++q; - case TIMER3A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR3A, &TCCR3B, &TCCR3C }, - /*OCRnQ*/ { &OCR3A, &OCR3B, &OCR3C }, - /*ICRn*/ &ICR3, - /*n, q*/ 3, q - }; - return timer; - } + case TIMER3C: ++q; case TIMER3B: ++q; case TIMER3A: + return Timer({ { &TCCR3A, &TCCR3B, &TCCR3C }, { &OCR3A, &OCR3B, &OCR3C }, &ICR3, 3, q, true, false }); #elif defined(OCR3B) - case TIMER3B: ++q; - case TIMER3A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR3A, &TCCR3B, nullptr }, - /*OCRnQ*/ { &OCR3A, &OCR3B, nullptr }, - /*ICRn*/ &ICR3, - /*n, q*/ 3, q - }; - return timer; - } + case TIMER3B: ++q; case TIMER3A: + return Timer({ { &TCCR3A, &TCCR3B, nullptr }, { &OCR3A, &OCR3B, nullptr }, &ICR3, 3, q, true, false }); #endif + #ifdef TCCR4A - case TIMER4C: ++q; - case TIMER4B: ++q; - case TIMER4A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR4A, &TCCR4B, &TCCR4C }, - /*OCRnQ*/ { &OCR4A, &OCR4B, &OCR4C }, - /*ICRn*/ &ICR4, - /*n, q*/ 4, q - }; - return timer; - } + case TIMER4C: ++q; case TIMER4B: ++q; case TIMER4A: + return Timer({ { &TCCR4A, &TCCR4B, &TCCR4C }, { &OCR4A, &OCR4B, &OCR4C }, &ICR4, 4, q, true, false }); #endif + #ifdef TCCR5A - case TIMER5C: ++q; - case TIMER5B: ++q; - case TIMER5A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR5A, &TCCR5B, &TCCR5C }, - /*OCRnQ*/ { &OCR5A, &OCR5B, &OCR5C }, - /*ICRn*/ &ICR5, - /*n, q*/ 5, q - }; - return timer; - } + case TIMER5C: ++q; case TIMER5B: ++q; case TIMER5A: + return Timer({ { &TCCR5A, &TCCR5B, &TCCR5C }, { &OCR5A, &OCR5B, &OCR5C }, &ICR5, 5, q, true, false }); #endif } - Timer timer = { - /*TCCRnQ*/ { nullptr, nullptr, nullptr }, - /*OCRnQ*/ { nullptr, nullptr, nullptr }, - /*ICRn*/ nullptr, - 0, 0 - }; - return timer; + + return Timer(); } -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 recognized - uint16_t size; - if (timer.n == 2) size = 255; else size = 65535; +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { + const Timer timer = get_pwm_timer(pin); + if (timer.isProtected || !timer.isPWM) return; // Don't proceed if protected timer or not recognized - uint16_t res = 255; // resolution (TOP value) - uint8_t j = 0; // prescaler index - uint8_t wgm = 1; // waveform generation mode + const bool is_timer2 = timer.n == 2; + const uint16_t maxtop = is_timer2 ? 0xFF : 0xFFFF; + + uint16_t res = 0xFF; // resolution (TOP value) + uint8_t j = CS_NONE; // prescaler index + uint8_t wgm = WGM_PWM_PC_8; // waveform generation mode // Calculating the prescaler and resolution to use to achieve closest frequency if (f_desired != 0) { - int f = (F_CPU) / (2 * 1024 * size) + 1; // Initialize frequency as lowest (non-zero) achievable - uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 }; - - // loop over prescaler values - LOOP_S_L_N(i, 1, 8) { - uint16_t res_temp_fast = 255, res_temp_phase_correct = 255; - if (timer.n == 2) { - // No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP - #if ENABLED(USE_OCR2A_AS_TOP) - const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired); - res_temp_fast = rtf - 1; - res_temp_phase_correct = rtf / 2; + constexpr uint16_t prescaler[] = { 1, 8, (32), 64, (128), 256, 1024 }; // (*) are Timer 2 only + uint16_t f = (F_CPU) / (2 * 1024 * maxtop) + 1; // Start with the lowest non-zero frequency achievable (1 or 31) + + LOOP_L_N(i, COUNT(prescaler)) { // Loop through all prescaler values + const uint16_t p = prescaler[i]; + uint16_t res_fast_temp, res_pc_temp; + if (is_timer2) { + #if ENABLED(USE_OCR2A_AS_TOP) // No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP + const uint16_t rft = (F_CPU) / (p * f_desired); + res_fast_temp = rft - 1; + res_pc_temp = rft / 2; + #else + res_fast_temp = res_pc_temp = maxtop; #endif } else { - // Skip TIMER2 specific prescalers when not TIMER2 - if (i == 3 || i == 5) continue; - const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired); - res_temp_fast = rtf - 1; - res_temp_phase_correct = rtf / 2; + if (p == 32 || p == 128) continue; // Skip TIMER2 specific prescalers when not TIMER2 + const uint16_t rft = (F_CPU) / (p * f_desired); + res_fast_temp = rft - 1; + res_pc_temp = rft / 2; } - LIMIT(res_temp_fast, 1U, size); - LIMIT(res_temp_phase_correct, 1U, size); + LIMIT(res_fast_temp, 1U, maxtop); + LIMIT(res_pc_temp, 1U, maxtop); + // Calculate frequencies of test prescaler and resolution values - const int f_temp_fast = (F_CPU) / (prescaler[i] * (1 + res_temp_fast)), - f_temp_phase_correct = (F_CPU) / (2 * prescaler[i] * res_temp_phase_correct), - f_diff = ABS(f - f_desired), - f_fast_diff = ABS(f_temp_fast - f_desired), - f_phase_diff = ABS(f_temp_phase_correct - f_desired); + const uint32_t f_diff = _MAX(f, f_desired) - _MIN(f, f_desired), + f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), + f_fast_diff = _MAX(f_fast_temp, f_desired) - _MIN(f_fast_temp, f_desired), + f_pc_temp = (F_CPU) / (2 * p * res_pc_temp), + f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired); - // If FAST values are closest to desired f - if (f_fast_diff < f_diff && f_fast_diff <= f_phase_diff) { - // Remember this combination - f = f_temp_fast; - res = res_temp_fast; - j = i; + if (f_fast_diff < f_diff && f_fast_diff <= f_pc_diff) { // FAST values are closest to desired f // Set the Wave Generation Mode to FAST PWM - if (timer.n == 2) { - wgm = ( - #if ENABLED(USE_OCR2A_AS_TOP) - WGM2_FAST_PWM_OCR2A - #else - WGM2_FAST_PWM - #endif - ); - } - else wgm = WGM_FAST_PWM_ICRn; + wgm = is_timer2 ? uint8_t(TERN(USE_OCR2A_AS_TOP, WGM2_FAST_PWM_OCR2A, WGM2_FAST_PWM)) : uint8_t(WGM_FAST_PWM_ICRn); + // Remember this combination + f = f_fast_temp; res = res_fast_temp; j = i + 1; } - // If PHASE CORRECT values are closes to desired f - else if (f_phase_diff < f_diff) { - f = f_temp_phase_correct; - res = res_temp_phase_correct; - j = i; + else if (f_pc_diff < f_diff) { // PHASE CORRECT values are closes to desired f // Set the Wave Generation Mode to PWM PHASE CORRECT - if (timer.n == 2) { - wgm = ( - #if ENABLED(USE_OCR2A_AS_TOP) - WGM2_PWM_PC_OCR2A - #else - WGM2_PWM_PC - #endif - ); - } - else wgm = WGM_PWM_PC_ICRn; + wgm = is_timer2 ? uint8_t(TERN(USE_OCR2A_AS_TOP, WGM2_PWM_PC_OCR2A, WGM2_PWM_PC)) : uint8_t(WGM_PWM_PC_ICRn); + f = f_pc_temp; res = res_pc_temp; j = i + 1; } } } - _SET_WGMnQ(timer.TCCRnQ, wgm); - _SET_CSn(timer.TCCRnQ, j); - if (timer.n == 2) { - #if ENABLED(USE_OCR2A_AS_TOP) - _SET_OCRnQ(timer.OCRnQ, 0, res); // Set OCR2A value (TOP) = res - #endif + _SET_WGMnQ(timer, wgm); + _SET_CSn(timer, j); + + if (is_timer2) { + TERN_(USE_OCR2A_AS_TOP, _SET_OCRnQ(timer, 0, res)); // Set OCR2A value (TOP) = res } else - _SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res + _SET_ICRn(timer, 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 NEEDS_HARDWARE_PWM - - // 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 - ); - - 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 +void MarlinHAL::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 { + const Timer timer = get_pwm_timer(pin); + if (timer.isPWM) { + if (timer.n == 0) { + _SET_COMnQ(timer, timer.q, COM_CLEAR_SET); // Only allow a TIMER0B select... + _SET_OCRnQ(timer, timer.q, v); // ...and OCR0B duty update. For output pin D4 no frequency changes are permitted. + } + else if (!timer.isProtected) { + const uint16_t top = timer.n == 2 ? TERN(USE_OCR2A_AS_TOP, *timer.OCRnQ[0], 255) : *timer.ICRn; + _SET_COMnQ(timer, SUM_TERN(HAS_TCCR2, timer.q, timer.q == 2), COM_CLEAR_SET + invert); // COM20 is on bit 4 of TCCR2, so +1 for q==2 + _SET_OCRnQ(timer, timer.q, uint16_t(uint32_t(v) * top / v_size)); // Scale 8/16-bit v to top value + } } + else + digitalWrite(pin, v < v_size / 2 ? LOW : HIGH); + } +} - #else - - analogWrite(pin, v); - UNUSED(v_size); - UNUSED(invert); +void MarlinHAL::init_pwm_timers() { + // Init some timer frequencies to a default 1KHz + const pin_t pwm_pin[] = { + #ifdef __AVR_ATmega2560__ + 10, 5, 6, 46 + #elif defined(__AVR_ATmega1280__) + 12, 31 + #elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284__) + 15, 6 + #elif defined(__AVR_AT90USB1286__) || defined(__AVR_mega64) || defined(__AVR_mega128) + 16, 24 + #endif + }; - #endif + LOOP_L_N(i, COUNT(pwm_pin)) + set_pwm_frequency(pwm_pin[i], 1000); } #endif // __AVR__ diff --git a/Marlin/src/HAL/AVR/fastio.cpp b/Marlin/src/HAL/AVR/fastio.cpp index 8af3ef805efa..5c6ef1891512 100644 --- a/Marlin/src/HAL/AVR/fastio.cpp +++ b/Marlin/src/HAL/AVR/fastio.cpp @@ -245,7 +245,7 @@ uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb float count = 0; if (hz > 0 && (dca || dcb || dcc)) { count = float(F_CPU) / hz; // 1x prescaler, TOP for 16MHz base freq. - uint16_t prescaler; // Range of 30.5Hz (65535) 64.5KHz (>31) + uint16_t prescaler; // Range of 30.5Hz (65535) 64.5kHz (>31) if (count >= 255. * 256.) { prescaler = 1024; SET_CS(5, PRESCALER_1024); } else if (count >= 255. * 64.) { prescaler = 256; SET_CS(5, PRESCALER_256); } @@ -257,7 +257,7 @@ uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb const float pwm_top = round(count); // Get the rounded count ICR5 = (uint16_t)pwm_top - 1; // Subtract 1 for TOP - OCR5A = pwm_top * ABS(dca); // Update and scale DCs + OCR5A = pwm_top * ABS(dca); // Update and scale DCs OCR5B = pwm_top * ABS(dcb); OCR5C = pwm_top * ABS(dcc); _SET_COM(5, A, dca ? (dca < 0 ? COM_SET_CLEAR : COM_CLEAR_SET) : COM_NORMAL); // Set compare modes @@ -277,7 +277,7 @@ uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb // Restore the default for Timer 5 SET_WGM(5, PWM_PC_8); // PWM 8-bit (Phase Correct) SET_COMS(5, NORMAL, NORMAL, NORMAL); // Do nothing - SET_CS(5, PRESCALER_64); // 16MHz / 64 = 250KHz + SET_CS(5, PRESCALER_64); // 16MHz / 64 = 250kHz OCR5A = OCR5B = OCR5C = 0; } return round(count); diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h index f77d4f666c7d..51d3b311ee9d 100644 --- a/Marlin/src/HAL/AVR/fastio.h +++ b/Marlin/src/HAL/AVR/fastio.h @@ -118,7 +118,7 @@ */ // Waveform Generation Modes -enum WaveGenMode : char { +enum WaveGenMode : uint8_t { WGM_NORMAL, // 0 WGM_PWM_PC_8, // 1 WGM_PWM_PC_9, // 2 @@ -138,19 +138,19 @@ enum WaveGenMode : char { }; // Wavefore Generation Modes (Timer 2 only) -enum WaveGenMode2 : char { - WGM2_NORMAL, // 0 - WGM2_PWM_PC, // 1 - WGM2_CTC_OCR2A, // 2 - WGM2_FAST_PWM, // 3 - WGM2_reserved_1, // 4 - WGM2_PWM_PC_OCR2A, // 5 - WGM2_reserved_2, // 6 - WGM2_FAST_PWM_OCR2A, // 7 +enum WaveGenMode2 : uint8_t { + WGM2_NORMAL, // 0 + WGM2_PWM_PC, // 1 + WGM2_CTC_OCR2A, // 2 + WGM2_FAST_PWM, // 3 + WGM2_reserved_1, // 4 + WGM2_PWM_PC_OCR2A, // 5 + WGM2_reserved_2, // 6 + WGM2_FAST_PWM_OCR2A, // 7 }; // Compare Modes -enum CompareMode : char { +enum CompareMode : uint8_t { COM_NORMAL, // 0 COM_TOGGLE, // 1 Non-PWM: OCnx ... Both PWM (WGM 9,11,14,15): OCnA only ... else NORMAL COM_CLEAR_SET, // 2 Non-PWM: OCnx ... Fast PWM: OCnx/Bottom ... PF-FC: OCnx Up/Down @@ -158,7 +158,7 @@ enum CompareMode : char { }; // Clock Sources -enum ClockSource : char { +enum ClockSource : uint8_t { CS_NONE, // 0 CS_PRESCALER_1, // 1 CS_PRESCALER_8, // 2 @@ -170,7 +170,7 @@ enum ClockSource : char { }; // Clock Sources (Timer 2 only) -enum ClockSource2 : char { +enum ClockSource2 : uint8_t { CS2_NONE, // 0 CS2_PRESCALER_1, // 1 CS2_PRESCALER_8, // 2 @@ -203,40 +203,33 @@ enum ClockSource2 : char { TCCR##T##B = (TCCR##T##B & ~(0x3 << WGM##T##2)) | (((int(V) >> 2) & 0x3) << WGM##T##2); \ }while(0) #define SET_WGM(T,V) _SET_WGM(T,WGM_##V) -// Runtime (see set_pwm_frequency): -#define _SET_WGMnQ(TCCRnQ, V) do{ \ - *(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << 0)) | (( int(V) & 0x3) << 0); \ - *(TCCRnQ)[1] = (*(TCCRnQ)[1] & ~(0x3 << 3)) | (((int(V) >> 2) & 0x3) << 3); \ - }while(0) // Set Clock Select bits // Ex: SET_CS3(PRESCALER_64); +#ifdef TCCR2 + #define HAS_TCCR2 1 +#endif #define _SET_CS(T,V) (TCCR##T##B = (TCCR##T##B & ~(0x7 << CS##T##0)) | ((int(V) & 0x7) << CS##T##0)) #define _SET_CS0(V) _SET_CS(0,V) #define _SET_CS1(V) _SET_CS(1,V) -#ifdef TCCR2 - #define _SET_CS2(V) (TCCR2 = (TCCR2 & ~(0x7 << CS20)) | (int(V) << CS20)) -#else - #define _SET_CS2(V) _SET_CS(2,V) -#endif #define _SET_CS3(V) _SET_CS(3,V) #define _SET_CS4(V) _SET_CS(4,V) #define _SET_CS5(V) _SET_CS(5,V) #define SET_CS0(V) _SET_CS0(CS_##V) #define SET_CS1(V) _SET_CS1(CS_##V) -#ifdef TCCR2 + +#if HAS_TCCR2 + #define _SET_CS2(V) (TCCR2 = (TCCR2 & ~(0x7 << CS20)) | (int(V) << CS20)) #define SET_CS2(V) _SET_CS2(CS2_##V) #else + #define _SET_CS2(V) _SET_CS(2,V) #define SET_CS2(V) _SET_CS2(CS_##V) #endif + #define SET_CS3(V) _SET_CS3(CS_##V) #define SET_CS4(V) _SET_CS4(CS_##V) #define SET_CS5(V) _SET_CS5(CS_##V) #define SET_CS(T,V) SET_CS##T(V) -// Runtime (see set_pwm_frequency) -#define _SET_CSn(TCCRnQ, V) do{ \ - (*(TCCRnQ)[1] = (*(TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0)); \ - }while(0) // Set Compare Mode bits // Ex: SET_COMS(4,CLEAR_SET,CLEAR_SET,CLEAR_SET); @@ -246,22 +239,6 @@ enum ClockSource2 : char { #define SET_COMB(T,V) SET_COM(T,B,V) #define SET_COMC(T,V) SET_COM(T,C,V) #define SET_COMS(T,V1,V2,V3) do{ SET_COMA(T,V1); SET_COMB(T,V2); SET_COMC(T,V3); }while(0) -// Runtime (see set_pwm_duty) -#define _SET_COMnQ(TCCRnQ, Q, V) do{ \ - (*(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q)))); \ - }while(0) - -// Set OCRnQ register -// Runtime (see set_pwm_duty): -#define _SET_OCRnQ(OCRnQ, Q, V) do{ \ - (*(OCRnQ)[(Q)] = (0x0000) | (int(V) & 0xFFFF)); \ - }while(0) - -// Set ICRn register (one per timer) -// Runtime (see set_pwm_frequency) -#define _SET_ICRn(ICRn, V) do{ \ - (*(ICRn) = (0x0000) | (int(V) & 0xFFFF)); \ - }while(0) // Set Noise Canceler bit // Ex: SET_ICNC(2,1) diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index 79809b8f618d..5c1f01a8f477 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -28,8 +28,16 @@ /** * Checks for FAST PWM */ -#if ENABLED(FAST_PWM_FAN) && (ENABLED(USE_OCR2A_AS_TOP) && defined(TCCR2)) - #error "USE_OCR2A_AS_TOP does not apply to devices with a single output TIMER2" +#if ALL(FAST_PWM_FAN, USE_OCR2A_AS_TOP, HAS_TCCR2) + #error "USE_OCR2A_AS_TOP does not apply to devices with a single output TIMER2." +#endif + +/** + * Checks for SOFT PWM + */ +#if HAS_FAN0 && FAN_PIN == 9 && DISABLED(FAN_SOFT_PWM) && ENABLED(SPEAKER) + #error "FAN_PIN 9 Hardware PWM uses Timer 2 which conflicts with Arduino AVR Tone Timer (for SPEAKER)." + #error "Disable SPEAKER or enable FAN_SOFT_PWM." #endif /** @@ -42,7 +50,7 @@ #elif NUM_SERVOS > 0 && defined(_useTimer3) && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system." #endif -#elif defined(SPINDLE_LASER_FREQUENCY) +#elif SPINDLE_LASER_FREQUENCY #error "SPINDLE_LASER_FREQUENCY requires SPINDLE_LASER_USE_PWM." #endif diff --git a/Marlin/src/HAL/AVR/math.h b/Marlin/src/HAL/AVR/math.h index 7ede4accc09e..7dd1018ff199 100644 --- a/Marlin/src/HAL/AVR/math.h +++ b/Marlin/src/HAL/AVR/math.h @@ -35,7 +35,7 @@ // C B A is longIn1 // D C B A is longIn2 // -static FORCE_INLINE uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) { +FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) { uint8_t tmp1; uint8_t tmp2; uint16_t intRes; @@ -89,7 +89,7 @@ static FORCE_INLINE uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2 // uses: // r26 to store 0 // r27 to store the byte 1 of the 24 bit result -static FORCE_INLINE uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) { +FORCE_INLINE static uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) { uint8_t tmp; uint16_t intRes; __asm__ __volatile__ ( diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index fcbb7af3e17e..0f564df987f3 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -102,7 +102,7 @@ void PRINT_ARRAY_NAME(uint8_t x) { return true; \ } else return false - +#define ABTEST(N) defined(TCCR##N##A) && defined(COM##N##A1) /** * Print a pin's PWM status. @@ -113,7 +113,7 @@ static bool pwm_status(uint8_t pin) { switch (digitalPinToTimer_DEBUG(pin)) { - #if defined(TCCR0A) && defined(COM0A1) + #if ABTEST(0) #ifdef TIMER0A #if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs PWM_CASE(0, A); @@ -122,20 +122,20 @@ static bool pwm_status(uint8_t pin) { PWM_CASE(0, B); #endif - #if defined(TCCR1A) && defined(COM1A1) + #if ABTEST(1) PWM_CASE(1, A); PWM_CASE(1, B); - #if defined(COM1C1) && defined(TIMER1C) - PWM_CASE(1, C); - #endif + #if defined(COM1C1) && defined(TIMER1C) + PWM_CASE(1, C); + #endif #endif - #if defined(TCCR2A) && defined(COM2A1) + #if ABTEST(2) PWM_CASE(2, A); PWM_CASE(2, B); #endif - #if defined(TCCR3A) && defined(COM3A1) + #if ABTEST(3) PWM_CASE(3, A); PWM_CASE(3, B); #ifdef COM3C1 @@ -149,7 +149,7 @@ static bool pwm_status(uint8_t pin) { PWM_CASE(4, C); #endif - #if defined(TCCR5A) && defined(COM5A1) + #if ABTEST(5) PWM_CASE(5, A); PWM_CASE(5, B); PWM_CASE(5, C); @@ -166,16 +166,16 @@ static bool pwm_status(uint8_t pin) { const volatile uint8_t* const PWM_other[][3] PROGMEM = { { &TCCR0A, &TCCR0B, &TIMSK0 }, { &TCCR1A, &TCCR1B, &TIMSK1 }, - #if defined(TCCR2A) && defined(COM2A1) + #if ABTEST(2) { &TCCR2A, &TCCR2B, &TIMSK2 }, #endif - #if defined(TCCR3A) && defined(COM3A1) + #if ABTEST(3) { &TCCR3A, &TCCR3B, &TIMSK3 }, #endif #ifdef TCCR4A { &TCCR4A, &TCCR4B, &TIMSK4 }, #endif - #if defined(TCCR5A) && defined(COM5A1) + #if ABTEST(5) { &TCCR5A, &TCCR5B, &TIMSK5 }, #endif }; @@ -195,11 +195,11 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = { { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, 0 }, #endif - #if defined(TCCR2A) && defined(COM2A1) + #if ABTEST(2) { &OCR2A, &OCR2B, 0 }, #endif - #if defined(TCCR3A) && defined(COM3A1) + #if ABTEST(3) #ifdef COM3C1 { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C }, #else @@ -211,7 +211,7 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = { { (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C }, #endif - #if defined(TCCR5A) && defined(COM5A1) + #if ABTEST(5) { (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C }, #endif }; @@ -281,7 +281,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - static void pwm_details(uint8_t pin) { switch (digitalPinToTimer_DEBUG(pin)) { - #if defined(TCCR0A) && defined(COM0A1) + #if ABTEST(0) #ifdef TIMER0A #if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs case TIMER0A: timer_prefix(0, 'A', 3); break; @@ -290,7 +290,7 @@ static void pwm_details(uint8_t pin) { case TIMER0B: timer_prefix(0, 'B', 3); break; #endif - #if defined(TCCR1A) && defined(COM1A1) + #if ABTEST(1) case TIMER1A: timer_prefix(1, 'A', 4); break; case TIMER1B: timer_prefix(1, 'B', 4); break; #if defined(COM1C1) && defined(TIMER1C) @@ -298,12 +298,12 @@ static void pwm_details(uint8_t pin) { #endif #endif - #if defined(TCCR2A) && defined(COM2A1) + #if ABTEST(2) case TIMER2A: timer_prefix(2, 'A', 3); break; case TIMER2B: timer_prefix(2, 'B', 3); break; #endif - #if defined(TCCR3A) && defined(COM3A1) + #if ABTEST(3) case TIMER3A: timer_prefix(3, 'A', 4); break; case TIMER3B: timer_prefix(3, 'B', 4); break; #ifdef COM3C1 @@ -317,7 +317,7 @@ static void pwm_details(uint8_t pin) { case TIMER4C: timer_prefix(4, 'C', 4); break; #endif - #if defined(TCCR5A) && defined(COM5A1) + #if ABTEST(5) case TIMER5A: timer_prefix(5, 'A', 4); break; case TIMER5B: timer_prefix(5, 'B', 4); break; case TIMER5C: timer_prefix(5, 'C', 4); break; @@ -351,7 +351,6 @@ static void pwm_details(uint8_t pin) { #endif } // pwm_details - #ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs int digitalRead_mod(const int8_t pin) { // same as digitalRead except the PWM stop section has been removed const uint8_t port = digitalPinToPort_DEBUG(pin); @@ -397,3 +396,5 @@ static void pwm_details(uint8_t pin) { #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) + +#undef ABTEST diff --git a/Marlin/src/HAL/AVR/timers.h b/Marlin/src/HAL/AVR/timers.h index 82eb8b14b161..33c3880b6b99 100644 --- a/Marlin/src/HAL/AVR/timers.h +++ b/Marlin/src/HAL/AVR/timers.h @@ -34,14 +34,14 @@ typedef uint16_t hal_timer_t; #define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 1 +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 1 #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 0 +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 0 #endif #define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0) @@ -58,13 +58,13 @@ typedef uint16_t hal_timer_t; #define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A) #define STEPPER_ISR_ENABLED() TEST(TIMSK1, OCIE1A) -#define ENABLE_TEMPERATURE_INTERRUPT() SBI(TIMSK0, OCIE0B) -#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B) -#define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0B) +#define ENABLE_TEMPERATURE_INTERRUPT() SBI(TIMSK0, OCIE0A) +#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0A) +#define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0A) FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) { switch (timer_num) { - case STEP_TIMER_NUM: + case MF_TIMER_STEP: // waveform generation = 0100 = CTC SET_WGM(1, CTC_OCRnA); @@ -84,10 +84,10 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) { TCNT1 = 0; break; - case TEMP_TIMER_NUM: + case MF_TIMER_TEMP: // Use timer0 for temperature measurement // Interleave temperature interrupt with millies interrupt - OCR0B = 128; + OCR0A = 128; break; } } @@ -109,12 +109,12 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) { * (otherwise, characters will be lost due to UART overflow). * Then: Stepper, Endstops, Temperature, and -finally- all others. */ -#define HAL_timer_isr_prologue(TIMER_NUM) -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP -/* 18 cycles maximum latency */ #ifndef HAL_STEP_TIMER_ISR +/* 18 cycles maximum latency */ #define HAL_STEP_TIMER_ISR() \ extern "C" void TIMER1_COMPA_vect() __attribute__ ((signal, naked, used, externally_visible)); \ extern "C" void TIMER1_COMPA_vect_bottom() asm ("TIMER1_COMPA_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \ @@ -180,7 +180,7 @@ void TIMER1_COMPA_vect() { \ : \ : [timsk0] "i" ((uint16_t)&TIMSK0), \ [timsk1] "i" ((uint16_t)&TIMSK1), \ - [msk0] "M" ((uint8_t)(1<RSTC_SR >> 8) & 0x07) { case 0: return RST_POWER_ON; case 1: return RST_BACKUP; @@ -77,12 +70,7 @@ uint8_t HAL_get_reset_source() { } } -void HAL_reboot() { rstc_start_software_reset(RSTC); } - -void _delay_ms(const int delay_ms) { - // Todo: port for Due? - delay(delay_ms); -} +void MarlinHAL::reboot() { rstc_start_software_reset(RSTC); } extern "C" { extern unsigned int _ebss; // end of bss section @@ -94,19 +82,6 @@ int freeMemory() { return (int)&free_memory - (heap_end ?: (int)&_ebss); } -// ------------------------ -// ADC -// ------------------------ - -void HAL_adc_start_conversion(const uint8_t ch) { - HAL_adc_result = analogRead(ch); -} - -uint16_t HAL_adc_get_result() { - // nop - return HAL_adc_result; -} - // Forward the default serial ports #if USING_HW_SERIAL0 DefaultSerial1 MSerial0(false, Serial); diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 96ab5d9808ac..9a02c9a0dcf5 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -38,6 +38,10 @@ #include "../../core/serial_hook.h" +// ------------------------ +// Serial ports +// ------------------------ + typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; @@ -97,60 +101,38 @@ extern DefaultSerial4 MSerial3; #include "MarlinSerial.h" #include "MarlinSerialUSB.h" -// On AVR this is in math.h? -#define square(x) ((x)*(x)) +// ------------------------ +// Types +// ------------------------ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() - -void cli(); // Disable interrupts -void sei(); // Enable interrupts +#define sei() noInterrupts() +#define cli() interrupts() -void HAL_clear_reset_source(); // clear reset reason -uint8_t HAL_get_reset_source(); // get reset reason - -void HAL_reboot(); +#define CRITICAL_SECTION_START() const bool _irqon = hal.isr_state(); hal.isr_off() +#define CRITICAL_SECTION_END() if (_irqon) hal.isr_on() // // ADC // -extern uint16_t HAL_adc_result; // result of last ADC conversion +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 #ifndef analogInputToDigitalPin #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) #endif -#define HAL_ANALOG_SELECT(ch) - -inline void HAL_adc_init() {}//todo - -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true - -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 +// Pin Mapping for M42, M43, M226 // #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin @@ -159,27 +141,18 @@ inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -void HAL_idletask(); -void HAL_init(); - -// -// Utility functions -// -void _delay_ms(const int delay); +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" #endif -int freeMemory(); - #pragma GCC diagnostic pop #ifdef __cplusplus @@ -189,3 +162,69 @@ char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s #ifdef __cplusplus } #endif + +// Return free RAM between end of heap (or end bss) and whatever is current +int freeMemory(); + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board(); // Called less early in setup() + static void reboot(); // Software reset + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } + + static void delay_ms(const int ms) { delay(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init() {} + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) {} + + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); } + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * No inverting the duty cycle in this HAL. + * No changing the maximum size of the provided value to enable finer PWM duty control in this HAL. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/DUE/MarlinSerial.cpp b/Marlin/src/HAL/DUE/MarlinSerial.cpp index fe62ff5607d5..638f7a100722 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerial.cpp @@ -406,7 +406,7 @@ size_t MarlinSerial::write(const uint8_t c) { const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Make room by polling if it is possible to transmit, and do so! while (i == tx_buffer.tail) { @@ -454,7 +454,7 @@ void MarlinSerial::flushTX() { if (!_written) return; // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Wait until everything was transmitted - We must do polling, as interrupts are disabled while (tx_buffer.head != tx_buffer.tail || !(HWUART->UART_SR & UART_SR_TXEMPTY)) { diff --git a/Marlin/src/HAL/DUE/MarlinSerial.h b/Marlin/src/HAL/DUE/MarlinSerial.h index 4a62e2834f7f..5a61bffee0da 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.h +++ b/Marlin/src/HAL/DUE/MarlinSerial.h @@ -118,7 +118,7 @@ class MarlinSerial { static size_t write(const uint8_t c); static void flushTX(); - static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } + static bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } diff --git a/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp index 67c597da80c4..8de2dc7924a0 100644 --- a/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp @@ -41,7 +41,7 @@ extern "C" { int udi_cdc_getc(); bool udi_cdc_is_tx_ready(); int udi_cdc_putc(int value); -}; +} // Pending character static int pending_char = -1; diff --git a/Marlin/src/HAL/DUE/Tone.cpp b/Marlin/src/HAL/DUE/Tone.cpp index 9beb6022237f..4bc8142aba27 100644 --- a/Marlin/src/HAL/DUE/Tone.cpp +++ b/Marlin/src/HAL/DUE/Tone.cpp @@ -35,20 +35,20 @@ static pin_t tone_pin; volatile static int32_t toggles; -void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) { +void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration/*=0*/) { tone_pin = _pin; toggles = 2 * frequency * duration / 1000; - HAL_timer_start(TONE_TIMER_NUM, 2 * frequency); + HAL_timer_start(MF_TIMER_TONE, 2 * frequency); } void noTone(const pin_t _pin) { - HAL_timer_disable_interrupt(TONE_TIMER_NUM); + HAL_timer_disable_interrupt(MF_TIMER_TONE); extDigitalWrite(_pin, LOW); } HAL_TONE_TIMER_ISR() { static uint8_t pin_state = 0; - HAL_timer_isr_prologue(TONE_TIMER_NUM); + HAL_timer_isr_prologue(MF_TIMER_TONE); if (toggles) { toggles--; diff --git a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp index d9fbabce2148..800915ff692b 100644 --- a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp +++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp @@ -25,7 +25,7 @@ * is NOT used to directly toggle pins. The ISR writes to the pin assigned to * that interrupt. * - * All PWMs use the same repetition rate. The G2 needs about 10KHz min in order to + * All PWMs use the same repetition rate. The G2 needs about 10kHz min in order to * not have obvious ripple on the Vref signals. * * The data structures are setup to minimize the computation done by the ISR which diff --git a/Marlin/src/HAL/DUE/pinsDebug.h b/Marlin/src/HAL/DUE/pinsDebug.h index f01c53c8ce06..6c08585974fd 100644 --- a/Marlin/src/HAL/DUE/pinsDebug.h +++ b/Marlin/src/HAL/DUE/pinsDebug.h @@ -53,7 +53,7 @@ * The net result is that both the g_pinStatus[pin] array and the PIO_OSR register * needs to be looked at when determining if a pin is an input or an output. * - * b) Due has only pins 6, 7, 8 & 9 enabled for PWMs. FYI - they run at 1KHz + * b) Due has only pins 6, 7, 8 & 9 enabled for PWMs. FYI - they run at 1kHz * * c) NUM_DIGITAL_PINS does not include the analog pins * diff --git a/Marlin/src/HAL/DUE/timers.cpp b/Marlin/src/HAL/DUE/timers.cpp index 65073c510d7c..a7bf7fbd6d85 100644 --- a/Marlin/src/HAL/DUE/timers.cpp +++ b/Marlin/src/HAL/DUE/timers.cpp @@ -42,7 +42,7 @@ // Private Variables // ------------------------ -const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = { +const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = { { TC0, 0, TC0_IRQn, 3}, // 0 - [servo timer5] { TC0, 1, TC1_IRQn, 0}, // 1 { TC0, 2, TC2_IRQn, 2}, // 2 - stepper @@ -66,9 +66,9 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = { */ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { - Tc *tc = TimerConfig[timer_num].pTimerRegs; - IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; - uint32_t channel = TimerConfig[timer_num].channel; + Tc *tc = timer_config[timer_num].pTimerRegs; + IRQn_Type irq = timer_config[timer_num].IRQ_Id; + uint32_t channel = timer_config[timer_num].channel; // Disable interrupt, just in case it was already enabled NVIC_DisableIRQ(irq); @@ -86,7 +86,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { pmc_set_writeprotect(false); pmc_enable_periph_clk((uint32_t)irq); - NVIC_SetPriority(irq, TimerConfig [timer_num].priority); + NVIC_SetPriority(irq, timer_config[timer_num].priority); // wave mode, reset counter on match with RC, TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1); @@ -105,12 +105,12 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { } void HAL_timer_enable_interrupt(const uint8_t timer_num) { - IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + IRQn_Type irq = timer_config[timer_num].IRQ_Id; NVIC_EnableIRQ(irq); } void HAL_timer_disable_interrupt(const uint8_t timer_num) { - IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + IRQn_Type irq = timer_config[timer_num].IRQ_Id; NVIC_DisableIRQ(irq); // We NEED memory barriers to ensure Interrupts are actually disabled! @@ -125,7 +125,7 @@ static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) { } bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { - IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + IRQn_Type irq = timer_config[timer_num].IRQ_Id; return NVIC_GetEnabledIRQ(irq); } diff --git a/Marlin/src/HAL/DUE/timers.h b/Marlin/src/HAL/DUE/timers.h index 0e1ea07cc2e4..bcfd07e268c5 100644 --- a/Marlin/src/HAL/DUE/timers.h +++ b/Marlin/src/HAL/DUE/timers.h @@ -37,35 +37,35 @@ typedef uint32_t hal_timer_t; #define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 2 // Timer Index for Stepper +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 2 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 4 // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 4 // Timer Index for Temperature #endif -#ifndef TONE_TIMER_NUM - #define TONE_TIMER_NUM 6 // index of timer to use for beeper tones +#ifndef MF_TIMER_TONE + #define MF_TIMER_TONE 6 // index of timer to use for beeper tones #endif #define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency -#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs -#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR #define HAL_STEP_TIMER_ISR() void TC2_Handler() @@ -92,7 +92,7 @@ typedef struct { // Public Variables // ------------------------ -extern const tTimerConfig TimerConfig[]; +extern const tTimerConfig timer_config[]; // ------------------------ // Public functions @@ -101,17 +101,17 @@ extern const tTimerConfig TimerConfig[]; void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { - const tTimerConfig * const pConfig = &TimerConfig[timer_num]; + const tTimerConfig * const pConfig = &timer_config[timer_num]; pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = compare; } FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { - const tTimerConfig * const pConfig = &TimerConfig[timer_num]; + const tTimerConfig * const pConfig = &timer_config[timer_num]; return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC; } FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { - const tTimerConfig * const pConfig = &TimerConfig[timer_num]; + const tTimerConfig * const pConfig = &timer_config[timer_num]; return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV; } @@ -120,9 +120,9 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { - const tTimerConfig * const pConfig = &TimerConfig[timer_num]; + const tTimerConfig * const pConfig = &timer_config[timer_num]; // Reading the status register clears the interrupt flag pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR; } -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp index 3dcbbaecd28f..34cc256b30ff 100644 --- a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp +++ b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp @@ -10,7 +10,7 @@ #include "../../../sd/cardreader.h" extern "C" { -#include "sd_mmc_spi_mem.h" + #include "sd_mmc_spi_mem.h" } #define SD_MMC_BLOCK_SIZE 512 diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 6a66d519b33c..44be0b540afe 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -52,7 +52,7 @@ // Externs // ------------------------ -portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; +portMUX_TYPE MarlinHAL::spinlock = portMUX_INITIALIZER_UNLOCKED; // ------------------------ // Local defines @@ -64,7 +64,7 @@ portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; // Public Variables // ------------------------ -uint16_t HAL_adc_result; +uint16_t MarlinHAL::adc_result; // ------------------------ // Private Variables @@ -73,9 +73,16 @@ uint16_t HAL_adc_result; esp_adc_cal_characteristics_t characteristics[ADC_ATTEN_MAX]; adc_atten_t attenuations[ADC1_CHANNEL_MAX] = {}; uint32_t thresholds[ADC_ATTEN_MAX]; -volatile int numPWMUsed = 0, - pwmPins[MAX_PWM_PINS], - pwmValues[MAX_PWM_PINS]; + +volatile int numPWMUsed = 0; +volatile struct { pin_t pin; int value; } pwmState[MAX_PWM_PINS]; + +pin_t chan_pin[CHANNEL_MAX_NUM + 1] = { 0 }; // PWM capable IOpins - not 0 or >33 on ESP32 + +struct { + uint32_t freq; // ledcReadFreq doesn't work if a duty hasn't been set yet! + uint16_t res; +} pwmInfo[(CHANNEL_MAX_NUM + 1) / 2]; // ------------------------ // Public functions @@ -95,20 +102,22 @@ volatile int numPWMUsed = 0, #endif #if ENABLED(USE_ESP32_EXIO) + HardwareSerial YSerial2(2); void Write_EXIO(uint8_t IO, uint8_t v) { - if (ISRS_ENABLED()) { - DISABLE_ISRS(); + if (hal.isr_state()) { + hal.isr_off(); YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100)); - ENABLE_ISRS(); + hal.isr_on(); } else YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100)); } + #endif -void HAL_init_board() { +void MarlinHAL::init_board() { #if ENABLED(USE_ESP32_TASK_WDT) esp_task_wdt_init(10, true); #endif @@ -154,27 +163,26 @@ void HAL_init_board() { #endif } -void HAL_idletask() { +void MarlinHAL::idletask() { #if BOTH(WIFISUPPORT, OTASUPPORT) OTA_handle(); #endif TERN_(ESP3D_WIFISUPPORT, esp3dlib.idletask()); } -void HAL_clear_reset_source() { } - -uint8_t HAL_get_reset_source() { return rtc_get_reset_reason(1); } +uint8_t MarlinHAL::get_reset_source() { return rtc_get_reset_reason(1); } -void HAL_reboot() { ESP.restart(); } +void MarlinHAL::reboot() { ESP.restart(); } void _delay_ms(int delay_ms) { delay(delay_ms); } // return free memory between end of heap (or end bss) and whatever is current -int freeMemory() { return ESP.getFreeHeap(); } +int MarlinHAL::freeMemory() { return ESP.getFreeHeap(); } // ------------------------ // ADC // ------------------------ + #define ADC1_CHANNEL(pin) ADC1_GPIO ## pin ## _CHANNEL adc1_channel_t get_channel(int pin) { @@ -196,7 +204,7 @@ void adc1_set_attenuation(adc1_channel_t chan, adc_atten_t atten) { } } -void HAL_adc_init() { +void MarlinHAL::adc_init() { // Configure ADC adc1_config_width(ADC_WIDTH_12Bit); @@ -211,7 +219,9 @@ void HAL_adc_init() { TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db)); TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db)); TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_PROBE, adc1_set_attenuation(get_channel(TEMP_PROBE_PIN), ADC_ATTEN_11db)); TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_BOARD, adc1_set_attenuation(get_channel(TEMP_BOARD_PIN), ADC_ATTEN_11db)); TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db)); // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail. @@ -226,11 +236,15 @@ void HAL_adc_init() { } } -void HAL_adc_start_conversion(const uint8_t adc_pin) { - const adc1_channel_t chan = get_channel(adc_pin); +#ifndef ADC_REFERENCE_VOLTAGE + #define ADC_REFERENCE_VOLTAGE 3.3 +#endif + +void MarlinHAL::adc_start(const pin_t pin) { + const adc1_channel_t chan = get_channel(pin); uint32_t mv; esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv); - HAL_adc_result = mv * 1023.0 / 3300.0; + adc_result = mv * 1023.0f / float(ADC_REFERENCE_VOLTAGE) / 1000.0f; // Change the attenuation level based on the new reading adc_atten_t atten; @@ -247,25 +261,81 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { adc1_set_attenuation(chan, atten); } -void analogWrite(pin_t pin, int value) { - // Use ledc hardware for internal pins - if (pin < 34) { - static int cnt_channel = 1, pin_to_channel[40] = { 0 }; - if (pin_to_channel[pin] == 0) { - ledcAttachPin(pin, cnt_channel); - ledcSetup(cnt_channel, 490, 8); - ledcWrite(cnt_channel, value); - pin_to_channel[pin] = cnt_channel++; +// ------------------------ +// PWM +// ------------------------ + +int8_t channel_for_pin(const uint8_t pin) { + for (int i = 0; i <= CHANNEL_MAX_NUM; i++) + if (chan_pin[i] == pin) return i; + return -1; +} + +// get PWM channel for pin - if none then attach a new one +// return -1 if fail or invalid pin#, channel # (0-15) if success +int8_t get_pwm_channel(const pin_t pin, const uint32_t freq, const uint16_t res) { + if (!WITHIN(pin, 1, MAX_PWM_IOPIN)) return -1; // Not a hardware PWM pin! + int8_t cid = channel_for_pin(pin); + if (cid >= 0) return cid; + + // Find an empty adjacent channel (same timer & freq/res) + for (int i = 0; i <= CHANNEL_MAX_NUM; i++) { + if (chan_pin[i] == 0) { + if (chan_pin[i ^ 0x1] != 0) { + if (pwmInfo[i / 2].freq == freq && pwmInfo[i / 2].res == res) { + chan_pin[i] = pin; // Allocate PWM to this channel + ledcAttachPin(pin, i); + return i; + } + } + else if (cid == -1) // Pair of empty channels? + cid = i & 0xFE; // Save lower channel number } - ledcWrite(pin_to_channel[pin], value); + } + // not attached, is an empty timer slot avail? + if (cid >= 0) { + chan_pin[cid] = pin; + pwmInfo[cid / 2].freq = freq; + pwmInfo[cid / 2].res = res; + ledcSetup(cid, freq, res); + ledcAttachPin(pin, cid); + } + return cid; // -1 if no channel avail +} + +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=_BV(PWM_RESOLUTION)-1*/, const bool invert/*=false*/) { + const int8_t cid = get_pwm_channel(pin, PWM_FREQUENCY, PWM_RESOLUTION); + if (cid >= 0) { + uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, _BV(PWM_RESOLUTION)-1); + ledcWrite(cid, duty); + } +} + +int8_t MarlinHAL::set_pwm_frequency(const pin_t pin, const uint32_t f_desired) { + const int8_t cid = channel_for_pin(pin); + if (cid >= 0) { + if (f_desired == ledcReadFreq(cid)) return cid; // no freq change + ledcDetachPin(chan_pin[cid]); + chan_pin[cid] = 0; // remove old freq channel + } + return get_pwm_channel(pin, f_desired, PWM_RESOLUTION); // try for new one +} + +// use hardware PWM if avail, if not then ISR +void analogWrite(const pin_t pin, const uint16_t value, const uint32_t freq/*=PWM_FREQUENCY*/, const uint16_t res/*=8*/) { // always 8 bit resolution! + // Use ledc hardware for internal pins + const int8_t cid = get_pwm_channel(pin, freq, res); + if (cid >= 0) { + ledcWrite(cid, value); // set duty value return; } + // not a hardware PWM pin OR no PWM channels available int idx = -1; // Search Pin for (int i = 0; i < numPWMUsed; ++i) - if (pwmPins[i] == pin) { idx = i; break; } + if (pwmState[i].pin == pin) { idx = i; break; } // not found ? if (idx < 0) { @@ -274,34 +344,34 @@ void analogWrite(pin_t pin, int value) { // Take new slot for pin idx = numPWMUsed; - pwmPins[idx] = pin; + pwmState[idx].pin = pin; // Start timer on first use - if (idx == 0) HAL_timer_start(PWM_TIMER_NUM, PWM_TIMER_FREQUENCY); + if (idx == 0) HAL_timer_start(MF_TIMER_PWM, PWM_TIMER_FREQUENCY); ++numPWMUsed; } // Use 7bit internal value - add 1 to have 100% high at 255 - pwmValues[idx] = (value + 1) / 2; + pwmState[idx].value = (value + 1) / 2; } // Handle PWM timer interrupt HAL_PWM_TIMER_ISR() { - HAL_timer_isr_prologue(PWM_TIMER_NUM); + HAL_timer_isr_prologue(MF_TIMER_PWM); static uint8_t count = 0; for (int i = 0; i < numPWMUsed; ++i) { if (count == 0) // Start of interval - WRITE(pwmPins[i], pwmValues[i] ? HIGH : LOW); - else if (pwmValues[i] == count) // End of duration - WRITE(pwmPins[i], LOW); + digitalWrite(pwmState[i].pin, pwmState[i].value ? HIGH : LOW); + else if (pwmState[i].value == count) // End of duration + digitalWrite(pwmState[i].pin, LOW); } // 128 for 7 Bit resolution count = (count + 1) & 0x7F; - HAL_timer_isr_epilogue(PWM_TIMER_NUM); + HAL_timer_isr_epilogue(MF_TIMER_PWM); } #endif // ARDUINO_ARCH_ESP32 diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 8473e3c4e469..8b26c3471d39 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -49,8 +49,6 @@ // Defines // ------------------------ -extern portMUX_TYPE spinlock; - #define MYSERIAL1 flushableSerial #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) @@ -65,9 +63,12 @@ extern portMUX_TYPE spinlock; #define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) #define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock) -#define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL) -#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock) -#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock) + +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment +#define PWM_FREQUENCY 1000u // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() +#define PWM_RESOLUTION 10u // Default PWM bit resolution +#define CHANNEL_MAX_NUM 15u // max PWM channel # to allocate (7 to only use low speed, 15 to use low & high) +#define MAX_PWM_IOPIN 33u // hardware pwm pins < 34 // ------------------------ // Types @@ -75,14 +76,8 @@ extern portMUX_TYPE spinlock; typedef int16_t pin_t; -#define HAL_SERVO_LIB Servo - -// ------------------------ -// Public Variables -// ------------------------ - -/** result of last ADC conversion */ -extern uint16_t HAL_adc_result; +class Servo; +typedef Servo hal_servo_t; // ------------------------ // Public functions @@ -91,59 +86,18 @@ extern uint16_t HAL_adc_result; // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -// clear reset reason -void HAL_clear_reset_source(); - -// reset reason -uint8_t HAL_get_reset_source(); - -void HAL_reboot(); - -void _delay_ms(int delay); - -#pragma GCC diagnostic push -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic ignored "-Wunused-function" -#endif - -int freeMemory(); - -#pragma GCC diagnostic pop +void analogWrite(const pin_t pin, const uint16_t value, const uint32_t freq=PWM_FREQUENCY, const uint16_t res=8); -void analogWrite(pin_t pin, int value); - -// ADC -#define HAL_ANALOG_SELECT(pin) - -void HAL_adc_init(); - -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true - -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 +// +// Pin Mapping for M42, M43, M226 +// #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -#define BOARD_INIT() HAL_init_board(); -void HAL_idletask(); -inline void HAL_init() {} -void HAL_init_board(); - #if ENABLED(USE_ESP32_EXIO) void Write_EXIO(uint8_t IO, uint8_t v); #endif @@ -188,3 +142,90 @@ FORCE_INLINE static void DELAY_CYCLES(uint32_t x) { } } + +// ------------------------ +// Class Utilities +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +int freeMemory(); + +#pragma GCC diagnostic pop + +void _delay_ms(const int ms); + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init() {} // Called early in setup() + static void init_board(); // Called less early in setup() + static void reboot(); // Restart the firmware + + // Interrupts + static portMUX_TYPE spinlock; + static bool isr_state() { return spinlock.owner == portMUX_FREE_VAL; } + static void isr_on() { if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock); } + static void isr_off() { portENTER_CRITICAL(&spinlock); } + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory(); + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * If not already allocated, allocate a hardware PWM channel + * to the pin and set the duty cycle.. + * Optionally invert the duty cycle [default = false] + * Optionally change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + + /** + * Allocate and set the frequency of a hardware PWM pin + * Returns -1 if no pin available. + */ + static int8_t set_pwm_frequency(const pin_t pin, const uint32_t f_desired); + +}; diff --git a/Marlin/src/HAL/ESP32/Servo.cpp b/Marlin/src/HAL/ESP32/Servo.cpp index fcf58485819e..ca3950d07f75 100644 --- a/Marlin/src/HAL/ESP32/Servo.cpp +++ b/Marlin/src/HAL/ESP32/Servo.cpp @@ -31,20 +31,18 @@ // so we only allocate servo channels up high to avoid side effects with regards to analogWrite (fans, leds, laser pwm etc.) int Servo::channel_next_free = 12; -Servo::Servo() { - channel = channel_next_free++; -} +Servo::Servo() {} int8_t Servo::attach(const int inPin) { - if (channel >= CHANNEL_MAX_NUM) return -1; if (inPin > 0) pin = inPin; - - ledcSetup(channel, 50, 16); // channel X, 50 Hz, 16-bit depth - ledcAttachPin(pin, channel); - return true; + channel = get_pwm_channel(pin, 50u, 16u); + return channel; // -1 if no PWM avail. } -void Servo::detach() { ledcDetachPin(pin); } +// leave channel connected to servo - set duty to zero +void Servo::detach() { + if (channel >= 0) ledcWrite(channel, 0); +} int Servo::read() { return degrees; } @@ -52,7 +50,7 @@ void Servo::write(int inDegrees) { degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE); int us = map(degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE); - ledcWrite(channel, duty); + if (channel >= 0) ledcWrite(channel, duty); // don't save duty for servos! } void Servo::move(const int value) { diff --git a/Marlin/src/HAL/ESP32/Servo.h b/Marlin/src/HAL/ESP32/Servo.h index 8542092d66ea..1dbb416a8317 100644 --- a/Marlin/src/HAL/ESP32/Servo.h +++ b/Marlin/src/HAL/ESP32/Servo.h @@ -30,8 +30,7 @@ class Servo { MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo TAU_MSEC = 20, TAU_USEC = (TAU_MSEC * 1000), - MAX_COMPARE = _BV(16) - 1, // 65535 - CHANNEL_MAX_NUM = 16; + MAX_COMPARE = _BV(16) - 1; // 65535 public: Servo(); diff --git a/Marlin/src/HAL/ESP32/Tone.cpp b/Marlin/src/HAL/ESP32/Tone.cpp index 376c0f32e129..839c612b6a87 100644 --- a/Marlin/src/HAL/ESP32/Tone.cpp +++ b/Marlin/src/HAL/ESP32/Tone.cpp @@ -35,19 +35,19 @@ static pin_t tone_pin; volatile static int32_t toggles; -void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) { +void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration/*=0*/) { tone_pin = _pin; toggles = 2 * frequency * duration / 1000; - HAL_timer_start(TONE_TIMER_NUM, 2 * frequency); + HAL_timer_start(MF_TIMER_TONE, 2 * frequency); } void noTone(const pin_t _pin) { - HAL_timer_disable_interrupt(TONE_TIMER_NUM); + HAL_timer_disable_interrupt(MF_TIMER_TONE); WRITE(_pin, LOW); } HAL_TONE_TIMER_ISR() { - HAL_timer_isr_prologue(TONE_TIMER_NUM); + HAL_timer_isr_prologue(MF_TIMER_TONE); if (toggles) { toggles--; diff --git a/Marlin/src/HAL/ESP32/inc/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h index 8bbc68d8715b..052c7e9d12fe 100644 --- a/Marlin/src/HAL/ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h @@ -25,8 +25,8 @@ #error "EMERGENCY_PARSER is not yet implemented for ESP32. Disable EMERGENCY_PARSER to continue." #endif -#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on ESP32." +#if (ENABLED(SPINDLE_LASER_USE_PWM) && SPINDLE_LASER_FREQUENCY > 78125) || (ENABLED(FAST_PWM_FAN_FREQUENCY) && FAST_PWM_FAN_FREQUENCY > 78125) + #error "SPINDLE_LASER_FREQUENCY and FAST_PWM_FREQUENCY maximum value is 78125Hz for ESP32." #endif #if HAS_TMC_SW_SERIAL @@ -40,3 +40,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not yet supported on ESP32." #endif + +#if MB(MKS_TINYBEE) && ENABLED(FAST_PWM_FAN) + #error "FAST_PWM_FAN is not available on TinyBee." +#endif diff --git a/Marlin/src/HAL/ESP32/timers.cpp b/Marlin/src/HAL/ESP32/timers.cpp index 57662a665882..c37ad2430cb2 100644 --- a/Marlin/src/HAL/ESP32/timers.cpp +++ b/Marlin/src/HAL/ESP32/timers.cpp @@ -41,7 +41,7 @@ static timg_dev_t *TG[2] = {&TIMERG0, &TIMERG1}; -const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = { +const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = { { TIMER_GROUP_0, TIMER_0, STEPPER_TIMER_PRESCALE, stepTC_Handler }, // 0 - Stepper { TIMER_GROUP_0, TIMER_1, TEMP_TIMER_PRESCALE, tempTC_Handler }, // 1 - Temperature { TIMER_GROUP_1, TIMER_0, PWM_TIMER_PRESCALE, pwmTC_Handler }, // 2 - PWM @@ -53,7 +53,7 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = { // ------------------------ void IRAM_ATTR timer_isr(void *para) { - const tTimerConfig& timer = TimerConfig[(int)para]; + const tTimerConfig& timer = timer_config[(int)para]; // Retrieve the interrupt status and the counter value // from the timer that reported the interrupt @@ -81,8 +81,8 @@ void IRAM_ATTR timer_isr(void *para) { * @param timer_num timer number to initialize * @param frequency frequency of the timer */ -void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) { - const tTimerConfig timer = TimerConfig[timer_num]; +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { + const tTimerConfig timer = timer_config[timer_num]; timer_config_t config; config.divider = timer.divider; @@ -115,7 +115,7 @@ void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) { * @param count threshold at which the interrupt is triggered */ void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t count) { - const tTimerConfig timer = TimerConfig[timer_num]; + const tTimerConfig timer = timer_config[timer_num]; timer_set_alarm_value(timer.group, timer.idx, count); } @@ -125,7 +125,7 @@ void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t count) { * @return the timer current threshold for the alarm to be triggered */ hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { - const tTimerConfig timer = TimerConfig[timer_num]; + const tTimerConfig timer = timer_config[timer_num]; uint64_t alarm_value; timer_get_alarm_value(timer.group, timer.idx, &alarm_value); @@ -139,7 +139,7 @@ hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { * @return the current counter of the alarm */ hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { - const tTimerConfig timer = TimerConfig[timer_num]; + const tTimerConfig timer = timer_config[timer_num]; uint64_t counter_value; timer_get_counter_value(timer.group, timer.idx, &counter_value); return counter_value; @@ -150,7 +150,7 @@ hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { * @param timer_num timer number to enable interrupts on */ void HAL_timer_enable_interrupt(const uint8_t timer_num) { - //const tTimerConfig timer = TimerConfig[timer_num]; + //const tTimerConfig timer = timer_config[timer_num]; //timer_enable_intr(timer.group, timer.idx); } @@ -159,12 +159,12 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num) { * @param timer_num timer number to disable interrupts on */ void HAL_timer_disable_interrupt(const uint8_t timer_num) { - //const tTimerConfig timer = TimerConfig[timer_num]; + //const tTimerConfig timer = timer_config[timer_num]; //timer_disable_intr(timer.group, timer.idx); } bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { - const tTimerConfig timer = TimerConfig[timer_num]; + const tTimerConfig timer = timer_config[timer_num]; return TG[timer.group]->int_ena.val | BIT(timer_num); } diff --git a/Marlin/src/HAL/ESP32/timers.h b/Marlin/src/HAL/ESP32/timers.h index a47697113d5d..aa4e1551f066 100644 --- a/Marlin/src/HAL/ESP32/timers.h +++ b/Marlin/src/HAL/ESP32/timers.h @@ -32,20 +32,20 @@ typedef uint64_t hal_timer_t; #define HAL_TIMER_TYPE_MAX 0xFFFFFFFFFFFFFFFFULL -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 1 // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 1 // Timer Index for Temperature #endif -#ifndef PWM_TIMER_NUM - #define PWM_TIMER_NUM 2 // index of timer to use for PWM outputs +#ifndef MF_TIMER_PWM + #define MF_TIMER_PWM 2 // index of timer to use for PWM outputs #endif -#ifndef TONE_TIMER_NUM - #define TONE_TIMER_NUM 3 // index of timer for beeper tones +#ifndef MF_TIMER_TONE + #define MF_TIMER_TONE 3 // index of timer for beeper tones #endif #define HAL_TIMER_RATE APB_CLK_FREQ // frequency of timer peripherals @@ -79,12 +79,12 @@ typedef uint64_t hal_timer_t; #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_TEMP_TIMER_ISR #define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler() @@ -121,13 +121,13 @@ typedef struct { // Public Variables // ------------------------ -extern const tTimerConfig TimerConfig[]; +extern const tTimerConfig timer_config[]; // ------------------------ // Public functions // ------------------------ -void HAL_timer_start (const uint8_t timer_num, uint32_t frequency); +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t count); hal_timer_t HAL_timer_get_compare(const uint8_t timer_num); hal_timer_t HAL_timer_get_count(const uint8_t timer_num); @@ -136,5 +136,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num); void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); -#define HAL_timer_isr_prologue(TIMER_NUM) -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp new file mode 100644 index 000000000000..0aa66ed2cf0d --- /dev/null +++ b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp @@ -0,0 +1,100 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * Copypaste of SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 . + * + */ +#ifdef ARDUINO_ARCH_ESP32 + +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(FYSETC_MINI_12864_2_1) + +#include +#include "Arduino.h" +#include "../shared/HAL_SPI.h" +#include "HAL.h" +#include "SPI.h" + +static SPISettings spiConfig; + +#define MDOGLCD_MOSI 23 +#define MDOGLCD_SCK 18 +#define MLCD_RESET_PIN 0 +#define MLCD_PINS_DC 4 +#define MDOGLCD_CS 21 +#define MDOGLCD_A0 4 + +#ifndef LCD_SPI_SPEED + #ifdef SD_SPI_SPEED + #define LCD_SPI_SPEED SD_SPI_SPEED // Assume SPI speed shared with SD + #else + #define LCD_SPI_SPEED SPI_FULL_SPEED // Use full speed if SD speed is not supplied + #endif +#endif + +uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT + if (msgInitCount) { + if (msg == U8G_COM_MSG_INIT) msgInitCount--; + if (msgInitCount) return -1; + } + + switch (msg) { + case U8G_COM_MSG_STOP: break; + + case U8G_COM_MSG_INIT: + OUT_WRITE(MDOGLCD_CS, HIGH); + OUT_WRITE(MDOGLCD_A0, HIGH); + OUT_WRITE(MLCD_RESET_PIN, HIGH); + u8g_Delay(5); + spiBegin(); + spiInit(LCD_SPI_SPEED); + break; + + case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ + WRITE(MDOGLCD_A0, arg_val ? HIGH : LOW); + break; + + case U8G_COM_MSG_CHIP_SELECT: /* arg_val == 0 means HIGH level of U8G_PI_CS */ + WRITE(MDOGLCD_CS, arg_val ? LOW : HIGH); + break; + + case U8G_COM_MSG_RESET: + WRITE(MLCD_RESET_PIN, arg_val); + break; + + case U8G_COM_MSG_WRITE_BYTE: + spiSend((uint8_t)arg_val); + break; + + case U8G_COM_MSG_WRITE_SEQ: + uint8_t *ptr = (uint8_t*) arg_ptr; + while (arg_val > 0) { + spiSend(*ptr++); + arg_val--; + } + break; + } + return 1; +} + +#endif // FYSETC_MINI_12864_2_1 +#endif // ARDUINO_ARCH_ESP32 diff --git a/Marlin/src/HAL/LINUX/HAL.cpp b/Marlin/src/HAL/LINUX/HAL.cpp index 0b679170ef17..db43f42eaafd 100644 --- a/Marlin/src/HAL/LINUX/HAL.cpp +++ b/Marlin/src/HAL/LINUX/HAL.cpp @@ -24,6 +24,10 @@ #include "../../inc/MarlinConfig.h" #include "../shared/Delay.h" +// ------------------------ +// Serial ports +// ------------------------ + MSerialT usb_serial(TERN0(EMERGENCY_PARSER, true)); // U8glib required functions @@ -37,42 +41,21 @@ extern "C" { //************************// // return free heap space -int freeMemory() { - return 0; -} +int freeMemory() { return 0; } // ------------------------ // ADC // ------------------------ -void HAL_adc_init() { - -} - -void HAL_adc_enable_channel(const uint8_t ch) { - -} - -uint8_t active_ch = 0; -void HAL_adc_start_conversion(const uint8_t ch) { - active_ch = ch; -} - -bool HAL_adc_finished() { - return true; -} +uint8_t MarlinHAL::active_ch = 0; -uint16_t HAL_adc_get_result() { - pin_t pin = analogInputToDigitalPin(active_ch); +uint16_t MarlinHAL::adc_value() { + const pin_t pin = analogInputToDigitalPin(active_ch); if (!VALID_PIN(pin)) return 0; - uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF); + const uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF); return data; // return 10bit value as Marlin expects } -void HAL_pwm_init() { - -} - -void HAL_reboot() { /* Reset the application state and GPIO */ } +void MarlinHAL::reboot() { /* Reset the application state and GPIO */ } #endif // __PLAT_LINUX__ diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index d7d3a92b73b9..43899c632de5 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -21,25 +21,42 @@ */ #pragma once -#define CPU_32_BIT - -#define F_CPU 100000000UL -#define SystemCoreClock F_CPU #include #include #include - #undef min #undef max - #include -void _printf (const char *format, ...); +#include "hardware/Clock.h" + +#include "../shared/Marduino.h" +#include "../shared/math_32bit.h" +#include "../shared/HAL_SPI.h" +#include "fastio.h" +#include "watchdog.h" +#include "serial.h" + +// ------------------------ +// Defines +// ------------------------ + +#define CPU_32_BIT +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +#define F_CPU 100000000UL +#define SystemCoreClock F_CPU + +#define DELAY_CYCLES(x) Clock::delayCycles(x) + +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +void _printf(const char *format, ...); void _putc(uint8_t c); uint8_t _getc(); -//extern "C" volatile uint32_t _millis; - //arduino: Print.h #define DEC 10 #define HEX 16 @@ -49,36 +66,27 @@ uint8_t _getc(); #define B01 1 #define B10 2 -#include "hardware/Clock.h" - -#include "../shared/Marduino.h" -#include "../shared/math_32bit.h" -#include "../shared/HAL_SPI.h" -#include "fastio.h" -#include "watchdog.h" -#include "serial.h" - -#define SHARED_SERVOS HAS_SERVOS +// ------------------------ +// Serial ports +// ------------------------ extern MSerialT usb_serial; #define MYSERIAL1 usb_serial -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - // // Interrupts // #define CRITICAL_SECTION_START() #define CRITICAL_SECTION_END() -#define ISRS_ENABLED() -#define ENABLE_ISRS() -#define DISABLE_ISRS() -inline void HAL_init() {} +// ADC +#define HAL_ADC_VREF 5.0 +#define HAL_ADC_RESOLUTION 10 + +// ------------------------ +// Class Utilities +// ------------------------ -// Utility functions #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" @@ -88,29 +96,66 @@ int freeMemory(); #pragma GCC diagnostic pop -// ADC -#define HAL_ADC_VREF 5.0 -#define HAL_ADC_RESOLUTION 10 -#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Reset the application state and GPIO + + // Interrupts + static bool isr_state() { return true; } + static void isr_on() {} + static void isr_off() {} + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask() {} + + // Reset + static constexpr uint8_t reset_reason = RST_POWER_ON; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint8_t active_ch; + + // Called by Temperature::init once at startup + static void adc_init() {} + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t) {} -void HAL_adc_init(); -void HAL_adc_enable_channel(const uint8_t ch); -void HAL_adc_start_conversion(const uint8_t ch); -uint16_t HAL_adc_get_result(); + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch) { active_ch = ch; } -// PWM -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Is the ADC ready for reading? + static bool adc_ready() { return true; } -// Reset source -inline void HAL_clear_reset_source(void) {} -inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } + // The current value of the ADC register + static uint16_t adc_value(); -void HAL_reboot(); // Reset the application state and GPIO + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to change the resolution or invert the duty cycle. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } -/* ---------------- Delay in cycles */ -FORCE_INLINE static void DELAY_CYCLES(uint64_t x) { - Clock::delayCycles(x); -} + static void set_pwm_frequency(const pin_t, int) {} +}; diff --git a/Marlin/src/HAL/LINUX/arduino.cpp b/Marlin/src/HAL/LINUX/arduino.cpp index 4b56d02a389c..075b4ccde2f4 100644 --- a/Marlin/src/HAL/LINUX/arduino.cpp +++ b/Marlin/src/HAL/LINUX/arduino.cpp @@ -31,9 +31,7 @@ void cli() { } // Disable void sei() { } // Enable // Time functions -void _delay_ms(const int delay_ms) { - delay(delay_ms); -} +void _delay_ms(const int ms) { delay(ms); } uint32_t millis() { return (uint32_t)Clock::millis(); diff --git a/Marlin/src/HAL/LINUX/include/Arduino.h b/Marlin/src/HAL/LINUX/include/Arduino.h index d4086e259a2f..f05aaed88083 100644 --- a/Marlin/src/HAL/LINUX/include/Arduino.h +++ b/Marlin/src/HAL/LINUX/include/Arduino.h @@ -59,10 +59,9 @@ typedef uint8_t byte; #endif #define sq(v) ((v) * (v)) -#define square(v) sq(v) #define constrain(value, arg_min, arg_max) ((value) < (arg_min) ? (arg_min) :((value) > (arg_max) ? (arg_max) : (value))) -//Interrupts +// Interrupts void cli(); // Disable void sei(); // Enable void attachInterrupt(uint32_t pin, void (*callback)(), uint32_t mode); @@ -74,8 +73,8 @@ extern "C" { } // Time functions -extern "C" void delay(const int milis); -void _delay_ms(const int delay); +extern "C" void delay(const int ms); +void _delay_ms(const int ms); void delayMicroseconds(unsigned long); uint32_t millis(); diff --git a/Marlin/src/HAL/LINUX/timers.h b/Marlin/src/HAL/LINUX/timers.h index 1beaea95abc6..2d2a95774c1b 100644 --- a/Marlin/src/HAL/LINUX/timers.h +++ b/Marlin/src/HAL/LINUX/timers.h @@ -37,14 +37,14 @@ typedef uint32_t hal_timer_t; #define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 1 // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 1 // Timer Index for Temperature #endif #define TEMP_TIMER_RATE 1000000 @@ -58,12 +58,12 @@ typedef uint32_t hal_timer_t; #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR #define HAL_STEP_TIMER_ISR() extern "C" void TIMER0_IRQHandler() @@ -77,7 +77,6 @@ typedef uint32_t hal_timer_t; #define HAL_PWM_TIMER_ISR() extern "C" void TIMER3_IRQHandler() #define HAL_PWM_TIMER_IRQn - void HAL_timer_init(); void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); @@ -93,5 +92,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num); void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); -#define HAL_timer_isr_prologue(TIMER_NUM) -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index cee9cfc5f744..541848b08acc 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -31,7 +31,7 @@ DefaultSerial1 USBSerial(false, UsbSerial); -uint32_t HAL_adc_reading = 0; +uint32_t MarlinHAL::adc_result = 0; // U8glib required functions extern "C" { @@ -41,8 +41,6 @@ extern "C" { void u8g_Delay(uint16_t val) { delay(val); } } -//************************// - // return free heap space int freeMemory() { char stack_end; @@ -54,33 +52,33 @@ int freeMemory() { return result; } -// scan command line for code -// return index into pin map array if found and the pin is valid. -// return dval if not found or not a valid pin. -int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { - const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100; - const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2; - return ind > -1 ? ind : dval; +void MarlinHAL::reboot() { NVIC_SystemReset(); } + +uint8_t MarlinHAL::get_reset_source() { + #if ENABLED(USE_WATCHDOG) + if (watchdog_timed_out()) return RST_WATCHDOG; + #endif + return RST_POWER_ON; +} + +void MarlinHAL::clear_reset_source() { + TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag()); } void flashFirmware(const int16_t) { delay(500); // Give OS time to disconnect USB_Connect(false); // USB clear connection delay(1000); // Give OS time to notice - HAL_reboot(); + hal.reboot(); } -void HAL_clear_reset_source(void) { - TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag()); -} - -uint8_t HAL_get_reset_source(void) { - #if ENABLED(USE_WATCHDOG) - if (watchdog_timed_out()) return RST_WATCHDOG; - #endif - return RST_POWER_ON; +// For M42/M43, scan command line for pin code +// return index into pin map array if found and the pin is valid. +// return dval if not found or not a valid pin. +int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { + const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100; + const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2; + return ind > -1 ? ind : dval; } -void HAL_reboot() { NVIC_SystemReset(); } - #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 348ea6b21a04..eefacae99549 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -28,8 +28,6 @@ #define CPU_32_BIT -void HAL_init(); - #include #include #include @@ -47,12 +45,9 @@ extern "C" volatile uint32_t _millis; #include #include -// -// Default graphical display delays -// -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 +// ------------------------ +// Serial ports +// ------------------------ typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1; extern DefaultSerial1 USBSerial; @@ -114,26 +109,12 @@ extern DefaultSerial1 USBSerial; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() - -// -// Utility functions -// -#pragma GCC diagnostic push -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic ignored "-Wunused-function" -#endif -int freeMemory(); - -#pragma GCC diagnostic pop +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() // -// ADC API +// ADC // #define ADC_MEDIAN_FILTER_SIZE (23) // Higher values increase step delay (phase shift), @@ -152,20 +133,9 @@ int freeMemory(); #define HAL_ADC_RESOLUTION 12 // 15 bit maximum, raw temperature is stored as int16_t #define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL -using FilteredADC = LPC176x::ADC; -extern uint32_t HAL_adc_reading; -[[gnu::always_inline]] inline void HAL_adc_start_conversion(const pin_t pin) { - HAL_adc_reading = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits -} -[[gnu::always_inline]] inline uint16_t HAL_adc_get_result() { - return HAL_adc_reading; -} - -#define HAL_adc_init() -#define HAL_ANALOG_SELECT(pin) FilteredADC::enable_channel(pin) -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() (true) +// +// Pin Mapping for M42, M43, M226 +// // Test whether the pin is valid constexpr bool VALID_PIN(const pin_t pin) { @@ -192,32 +162,101 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval); // P0.6 thru P0.9 are for the onboard SD card #define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, -#define HAL_IDLETASK 1 -void HAL_idletask(); +// ------------------------ +// Defines +// ------------------------ #define PLATFORM_M997_SUPPORT void flashFirmware(const int16_t); #define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Hardware PWM pins run at the same frequency and all - * Software PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, int f_desired); +// Default graphical display delays +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 -/** - * set_pwm_duty - * 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] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); +// ------------------------ +// Class Utilities +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +int freeMemory(); + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source(); + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + using FilteredADC = LPC176x::ADC; + + // Called by Temperature::init once at startup + static void adc_init() {} + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) { + FilteredADC::enable_channel(pin); + } + + // Begin ADC sampling on the given pin + static uint32_t adc_result; + static void adc_start(const pin_t pin) { + adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits + } + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return uint16_t(adc_result); } -// Reset source -void HAL_clear_reset_source(void); -uint8_t HAL_get_reset_source(void); + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); -void HAL_reboot(); + /** + * Set the frequency of the timer corresponding to the provided pin + * All Hardware PWM pins will run at the same frequency and + * All Software PWM pins will run at the same frequency + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +}; diff --git a/Marlin/src/HAL/LPC1768/Servo.h b/Marlin/src/HAL/LPC1768/Servo.h index eb12fd20f4d8..f02f503a67da 100644 --- a/Marlin/src/HAL/LPC1768/Servo.h +++ b/Marlin/src/HAL/LPC1768/Servo.h @@ -65,4 +65,5 @@ class libServo: public Servo { } }; -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; diff --git a/Marlin/src/HAL/LPC1768/fast_pwm.cpp b/Marlin/src/HAL/LPC1768/fast_pwm.cpp index 70fc0e333d11..6d2b1a9002c1 100644 --- a/Marlin/src/HAL/LPC1768/fast_pwm.cpp +++ b/Marlin/src/HAL/LPC1768/fast_pwm.cpp @@ -21,19 +21,17 @@ */ #ifdef TARGET_LPC1768 -#include "../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfig.h" #include -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); +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { + if (!LPC176x::pin_is_valid(pin)) return; + if (LPC176x::pwm_attach_pin(pin)) + LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range } -#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 +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { + LPC176x::pwm_set_frequency(pin, f_desired); +} #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 3ea054589ec3..8265d58a6e8f 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -113,7 +113,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #define _IS_RX1_1 IS_RX1 #if IS_TX1(TMC_SW_SCK) #error "Serial port pins (1) conflict with other pins!" - #elif HAS_WIRED_LCD + #elif HAS_ROTARY_ENCODER #if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1) #error "Serial port pins (1) conflict with Encoder Buttons!" #elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK_PIN) \ diff --git a/Marlin/src/HAL/LPC1768/include/SPI.h b/Marlin/src/HAL/LPC1768/include/SPI.h index ecd91f6a3b73..24f4759315bd 100644 --- a/Marlin/src/HAL/LPC1768/include/SPI.h +++ b/Marlin/src/HAL/LPC1768/include/SPI.h @@ -77,7 +77,7 @@ class SPISettings { //uint32_t spiRate() const { return spi_speed; } - static inline uint32_t spiRate2Clock(uint32_t spiRate) { + static uint32_t spiRate2Clock(uint32_t spiRate) { uint32_t Marlin_speed[7]; // CPSR is always 2 Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED diff --git a/Marlin/src/HAL/LPC1768/main.cpp b/Marlin/src/HAL/LPC1768/main.cpp index ef0dc42c78ca..419c99793fb8 100644 --- a/Marlin/src/HAL/LPC1768/main.cpp +++ b/Marlin/src/HAL/LPC1768/main.cpp @@ -48,7 +48,7 @@ void SysTick_Callback() { disk_timerproc(); } TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); -void HAL_init() { +void MarlinHAL::init() { // Init LEDs #if PIN_EXISTS(LED) @@ -130,7 +130,7 @@ void HAL_init() { const millis_t usb_timeout = millis() + 2000; while (!USB_Configuration && PENDING(millis(), usb_timeout)) { delay(50); - HAL_idletask(); + idletask(); #if PIN_EXISTS(LED) TOGGLE(LED_PIN); // Flash quickly during USB initialization #endif @@ -142,7 +142,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // If Marlin is using the SD card we need to lock it to prevent access from // a PC via USB. diff --git a/Marlin/src/HAL/LPC1768/tft/xpt2046.h b/Marlin/src/HAL/LPC1768/tft/xpt2046.h index aba0799e445f..7c456cf00e1b 100644 --- a/Marlin/src/HAL/LPC1768/tft/xpt2046.h +++ b/Marlin/src/HAL/LPC1768/tft/xpt2046.h @@ -65,8 +65,8 @@ class XPT2046 { static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); - static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; - static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; + static void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; + static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; #if ENABLED(TOUCH_BUTTONS_HW_SPI) static uint16_t HardwareIO(uint16_t data); #endif diff --git a/Marlin/src/HAL/LPC1768/timers.cpp b/Marlin/src/HAL/LPC1768/timers.cpp index a7a40584dabc..bbb13f81da05 100644 --- a/Marlin/src/HAL/LPC1768/timers.cpp +++ b/Marlin/src/HAL/LPC1768/timers.cpp @@ -40,7 +40,7 @@ void HAL_timer_init() { void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { switch (timer_num) { - case 0: + case MF_TIMER_STEP: LPC_TIM0->MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them LPC_TIM0->MR0 = uint32_t(STEPPER_TIMER_RATE) / frequency; // Match value (period) to set frequency LPC_TIM0->TCR = _BV(SBIT_CNTEN); // Counter Enable @@ -49,7 +49,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { NVIC_EnableIRQ(TIMER0_IRQn); break; - case 1: + case MF_TIMER_TEMP: LPC_TIM1->MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them LPC_TIM1->MR0 = uint32_t(TEMP_TIMER_RATE) / frequency; LPC_TIM1->TCR = _BV(SBIT_CNTEN); // Counter Enable diff --git a/Marlin/src/HAL/LPC1768/timers.h b/Marlin/src/HAL/LPC1768/timers.h index 4b638546856f..c6d7bc632e2e 100644 --- a/Marlin/src/HAL/LPC1768/timers.h +++ b/Marlin/src/HAL/LPC1768/timers.h @@ -60,17 +60,17 @@ typedef uint32_t hal_timer_t; #define HAL_TIMER_RATE ((F_CPU) / 4) // frequency of timers peripherals -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 1 // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 1 // Timer Index for Temperature #endif -#ifndef PWM_TIMER_NUM - #define PWM_TIMER_NUM 3 // Timer Index for PWM +#ifndef MF_TIMER_PWM + #define MF_TIMER_PWM 3 // Timer Index for PWM #endif #define TEMP_TIMER_RATE 1000000 @@ -84,23 +84,23 @@ typedef uint32_t hal_timer_t; #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR - #define HAL_STEP_TIMER_ISR() _HAL_TIMER_ISR(STEP_TIMER_NUM) + #define HAL_STEP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_STEP) #endif #ifndef HAL_TEMP_TIMER_ISR - #define HAL_TEMP_TIMER_ISR() _HAL_TIMER_ISR(TEMP_TIMER_NUM) + #define HAL_TEMP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_TEMP) #endif // Timer references by index -#define STEP_TIMER_PTR _HAL_TIMER(STEP_TIMER_NUM) -#define TEMP_TIMER_PTR _HAL_TIMER(TEMP_TIMER_NUM) +#define STEP_TIMER_PTR _HAL_TIMER(MF_TIMER_STEP) +#define TEMP_TIMER_PTR _HAL_TIMER(MF_TIMER_TEMP) // ------------------------ // Public functions @@ -110,38 +110,38 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { switch (timer_num) { - case 0: STEP_TIMER_PTR->MR0 = compare; break; // Stepper Timer Match Register 0 - case 1: TEMP_TIMER_PTR->MR0 = compare; break; // Temp Timer Match Register 0 + case MF_TIMER_STEP: STEP_TIMER_PTR->MR0 = compare; break; // Stepper Timer Match Register 0 + case MF_TIMER_TEMP: TEMP_TIMER_PTR->MR0 = compare; break; // Temp Timer Match Register 0 } } FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { switch (timer_num) { - case 0: return STEP_TIMER_PTR->MR0; // Stepper Timer Match Register 0 - case 1: return TEMP_TIMER_PTR->MR0; // Temp Timer Match Register 0 + case MF_TIMER_STEP: return STEP_TIMER_PTR->MR0; // Stepper Timer Match Register 0 + case MF_TIMER_TEMP: return TEMP_TIMER_PTR->MR0; // Temp Timer Match Register 0 } return 0; } FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { switch (timer_num) { - case 0: return STEP_TIMER_PTR->TC; // Stepper Timer Count - case 1: return TEMP_TIMER_PTR->TC; // Temp Timer Count + case MF_TIMER_STEP: return STEP_TIMER_PTR->TC; // Stepper Timer Count + case MF_TIMER_TEMP: return TEMP_TIMER_PTR->TC; // Temp Timer Count } return 0; } FORCE_INLINE static void HAL_timer_enable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case 0: NVIC_EnableIRQ(TIMER0_IRQn); break; // Enable interrupt handler - case 1: NVIC_EnableIRQ(TIMER1_IRQn); break; // Enable interrupt handler + case MF_TIMER_STEP: NVIC_EnableIRQ(TIMER0_IRQn); break; // Enable interrupt handler + case MF_TIMER_TEMP: NVIC_EnableIRQ(TIMER1_IRQn); break; // Enable interrupt handler } } FORCE_INLINE static void HAL_timer_disable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case 0: NVIC_DisableIRQ(TIMER0_IRQn); break; // Disable interrupt handler - case 1: NVIC_DisableIRQ(TIMER1_IRQn); break; // Disable interrupt handler + case MF_TIMER_STEP: NVIC_DisableIRQ(TIMER0_IRQn); break; // Disable interrupt handler + case MF_TIMER_TEMP: NVIC_DisableIRQ(TIMER1_IRQn); break; // Disable interrupt handler } // We NEED memory barriers to ensure Interrupts are actually disabled! @@ -157,17 +157,17 @@ FORCE_INLINE static bool NVIC_GetEnableIRQ(IRQn_Type IRQn) { FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { switch (timer_num) { - case 0: return NVIC_GetEnableIRQ(TIMER0_IRQn); // Check if interrupt is enabled or not - case 1: return NVIC_GetEnableIRQ(TIMER1_IRQn); // Check if interrupt is enabled or not + case MF_TIMER_STEP: return NVIC_GetEnableIRQ(TIMER0_IRQn); // Check if interrupt is enabled or not + case MF_TIMER_TEMP: return NVIC_GetEnableIRQ(TIMER1_IRQn); // Check if interrupt is enabled or not } return false; } FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { switch (timer_num) { - case 0: SBI(STEP_TIMER_PTR->IR, SBIT_CNTEN); break; - case 1: SBI(TEMP_TIMER_PTR->IR, SBIT_CNTEN); break; + case MF_TIMER_STEP: SBI(STEP_TIMER_PTR->IR, SBIT_CNTEN); break; + case MF_TIMER_TEMP: SBI(TEMP_TIMER_PTR->IR, SBIT_CNTEN); break; } } -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index 915339468b2c..ee2e31fc7fa4 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -21,18 +21,10 @@ */ #pragma once -#define CPU_32_BIT -#define HAL_IDLETASK -void HAL_idletask(); - -#define F_CPU 100000000 -#define SystemCoreClock F_CPU #include #include - #undef min #undef max - #include #include "pinmapping.h" @@ -40,8 +32,6 @@ void _printf (const char *format, ...); void _putc(uint8_t c); uint8_t _getc(); -//extern "C" volatile uint32_t _millis; - //arduino: Print.h #define DEC 10 #define HEX 16 @@ -58,7 +48,23 @@ uint8_t _getc(); #include "watchdog.h" #include "serial.h" -#define SHARED_SERVOS HAS_SERVOS +// ------------------------ +// Defines +// ------------------------ + +#define CPU_32_BIT +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +#define F_CPU 100000000 +#define SystemCoreClock F_CPU + +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +// ------------------------ +// Serial ports +// ------------------------ extern MSerialT serial_stream_0; extern MSerialT serial_stream_1; @@ -98,47 +104,19 @@ extern MSerialT serial_stream_3; #endif #endif - -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - -// +// ------------------------ // Interrupts -// +// ------------------------ + #define CRITICAL_SECTION_START() #define CRITICAL_SECTION_END() -#define ISRS_ENABLED() -#define ENABLE_ISRS() -#define DISABLE_ISRS() - -inline void HAL_init() {} - -// Utility functions -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" -int freeMemory(); -#pragma GCC diagnostic pop +// ------------------------ // ADC +// ------------------------ + #define HAL_ADC_VREF 5.0 #define HAL_ADC_RESOLUTION 10 -#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true - -void HAL_adc_init(); -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; } /* ---------------- Delay in cycles */ @@ -157,29 +135,22 @@ constexpr inline std::size_t strlen_constexpr(const char* str) { // https://github.com/gcc-mirror/gcc/blob/5c7634a0e5f202935aa6c11b6ea953b8bf80a00a/libstdc%2B%2B-v3/include/bits/char_traits.h#L329 if (str != nullptr) { std::size_t i = 0; - while (str[i] != '\0') { - ++i; - } - + while (str[i] != '\0') ++i; return i; } - return 0; } constexpr inline int strncmp_constexpr(const char* lhs, const char* rhs, std::size_t count) { // https://github.com/gcc-mirror/gcc/blob/13b9cbfc32fe3ac4c81c4dd9c42d141c8fb95db4/libstdc%2B%2B-v3/include/bits/char_traits.h#L655 - if (lhs == nullptr || rhs == nullptr) { + if (lhs == nullptr || rhs == nullptr) return rhs != nullptr ? -1 : 1; - } - for (std::size_t i = 0; i < count; ++i) { - if (lhs[i] != rhs[i]) { + for (std::size_t i = 0; i < count; ++i) + if (lhs[i] != rhs[i]) return lhs[i] < rhs[i] ? -1 : 1; - } else if (lhs[i] == '\0') { + else if (lhs[i] == '\0') return 0; - } - } return 0; } @@ -191,14 +162,11 @@ constexpr inline const char* strstr_constexpr(const char* str, const char* targe do { char sc = {}; do { - if ((sc = *str++) == '\0') { - return nullptr; - } + if ((sc = *str++) == '\0') return nullptr; } while (sc != c); } while (strncmp_constexpr(str, target, len) != 0); --str; } - return str; } @@ -209,12 +177,87 @@ constexpr inline char* strstr_constexpr(char* str, const char* target) { do { char sc = {}; do { - if ((sc = *str++) == '\0') { - return nullptr; - } + if ((sc = *str++) == '\0') return nullptr; } while (sc != c); } while (strncmp_constexpr(str, target, len) != 0); --str; } return str; } + +// ------------------------ +// Class Utilities +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +int freeMemory(); + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return true; } + static void isr_on() {} + static void isr_off() {} + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static constexpr uint8_t reset_reason = RST_POWER_ON; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint8_t active_ch; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch); + + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch); + + // Is the ADC ready for reading? + static bool adc_ready(); + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h index 9ef1816c7b16..b131853643a8 100644 --- a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h +++ b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h @@ -62,8 +62,8 @@ class XPT2046 { static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); - static inline void DataTransferBegin(); - static inline void DataTransferEnd(); + static void DataTransferBegin(); + static void DataTransferEnd(); #if ENABLED(TOUCH_BUTTONS_HW_SPI) static uint16_t HardwareIO(uint16_t data); #endif diff --git a/Marlin/src/HAL/NATIVE_SIM/timers.h b/Marlin/src/HAL/NATIVE_SIM/timers.h index c61eb29e76cf..be38d583b686 100644 --- a/Marlin/src/HAL/NATIVE_SIM/timers.h +++ b/Marlin/src/HAL/NATIVE_SIM/timers.h @@ -37,17 +37,17 @@ typedef uint64_t hal_timer_t; #define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 1 // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 1 // Timer Index for Temperature #endif -#ifndef SYSTICK_TIMER_NUM - #define SYSTICK_TIMER_NUM 2 // Timer Index for Systick +#ifndef MF_TIMER_SYSTICK + #define MF_TIMER_SYSTICK 2 // Timer Index for Systick #endif #define SYSTICK_TIMER_FREQUENCY 1000 @@ -62,12 +62,12 @@ typedef uint64_t hal_timer_t; #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR #define HAL_STEP_TIMER_ISR() extern "C" void TIMER0_IRQHandler() @@ -87,5 +87,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num); void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); -#define HAL_timer_isr_prologue(TIMER_NUM) -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp index 7fd335d62eba..7be84580b133 100644 --- a/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp @@ -208,8 +208,11 @@ uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_pt } #endif -#elif !ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI, HAS_MARLINUI_HD44780) && HAS_MARLINUI_U8GLIB +#elif NONE(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI, HAS_MARLINUI_HD44780) && HAS_MARLINUI_U8GLIB + #include uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {return 0;} + #endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920 + #endif // __PLAT_NATIVE_SIM__ diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index 8baad31bc751..14b6a437dccc 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -42,10 +42,6 @@ #endif #endif -// ------------------------ -// Local defines -// ------------------------ - #define GET_TEMP_0_ADC() TERN(HAS_TEMP_ADC_0, PIN_TO_ADC(TEMP_0_PIN), -1) #define GET_TEMP_1_ADC() TERN(HAS_TEMP_ADC_1, PIN_TO_ADC(TEMP_1_PIN), -1) #define GET_TEMP_2_ADC() TERN(HAS_TEMP_ADC_2, PIN_TO_ADC(TEMP_2_PIN), -1) @@ -54,22 +50,28 @@ #define GET_TEMP_5_ADC() TERN(HAS_TEMP_ADC_5, PIN_TO_ADC(TEMP_5_PIN), -1) #define GET_TEMP_6_ADC() TERN(HAS_TEMP_ADC_6, PIN_TO_ADC(TEMP_6_PIN), -1) #define GET_TEMP_7_ADC() TERN(HAS_TEMP_ADC_7, PIN_TO_ADC(TEMP_7_PIN), -1) -#define GET_PROBE_ADC() TERN(HAS_TEMP_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1) #define GET_BED_ADC() TERN(HAS_TEMP_ADC_BED, PIN_TO_ADC(TEMP_BED_PIN), -1) #define GET_CHAMBER_ADC() TERN(HAS_TEMP_ADC_CHAMBER, PIN_TO_ADC(TEMP_CHAMBER_PIN), -1) +#define GET_PROBE_ADC() TERN(HAS_TEMP_ADC_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1) #define GET_COOLER_ADC() TERN(HAS_TEMP_ADC_COOLER, PIN_TO_ADC(TEMP_COOLER_PIN), -1) +#define GET_BOARD_ADC() TERN(HAS_TEMP_ADC_BOARD, PIN_TO_ADC(TEMP_BOARD_PIN), -1) #define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1) #define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1) +#define GET_JOY_ADC_X() TERN(HAS_JOY_ADC_X, PIN_TO_ADC(JOY_X_PIN), -1) +#define GET_JOY_ADC_Y() TERN(HAS_JOY_ADC_Y, PIN_TO_ADC(JOY_Y_PIN), -1) +#define GET_JOY_ADC_Z() TERN(HAS_JOY_ADC_Z, PIN_TO_ADC(JOY_Z_PIN), -1) #define IS_ADC_REQUIRED(n) ( \ GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \ || GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \ - || GET_PROBE_ADC() == n \ - || GET_BED_ADC() == n \ - || GET_CHAMBER_ADC() == n \ - || GET_COOLER_ADC() == n \ + || GET_BED_ADC() == n \ + || GET_CHAMBER_ADC() == n \ + || GET_PROBE_ADC() == n \ + || GET_COOLER_ADC() == n \ + || GET_BOARD_ADC() == n \ || GET_FILAMENT_WIDTH_ADC() == n \ - || GET_BUTTONS_ADC() == n \ + || GET_BUTTONS_ADC() == n \ + || GET_JOY_ADC_X() == n || GET_JOY_ADC_Y() == n || GET_JOY_ADC_Z() == n \ ) #if IS_ADC_REQUIRED(0) @@ -89,6 +91,118 @@ #define DMA_IS_REQUIRED 1 #endif +enum ADCIndex { + #if GET_TEMP_0_ADC() == 0 + TEMP_0, + #endif + #if GET_TEMP_1_ADC() == 0 + TEMP_1, + #endif + #if GET_TEMP_2_ADC() == 0 + TEMP_2, + #endif + #if GET_TEMP_3_ADC() == 0 + TEMP_3, + #endif + #if GET_TEMP_4_ADC() == 0 + TEMP_4, + #endif + #if GET_TEMP_5_ADC() == 0 + TEMP_5, + #endif + #if GET_TEMP_6_ADC() == 0 + TEMP_6, + #endif + #if GET_TEMP_7_ADC() == 0 + TEMP_7, + #endif + #if GET_BED_ADC() == 0 + TEMP_BED, + #endif + #if GET_CHAMBER_ADC() == 0 + TEMP_CHAMBER, + #endif + #if GET_PROBE_ADC() == 0 + TEMP_PROBE, + #endif + #if GET_COOLER_ADC() == 0 + TEMP_COOLER, + #endif + #if GET_BOARD_ADC() == 0 + TEMP_BOARD, + #endif + #if GET_FILAMENT_WIDTH_ADC() == 0 + FILWIDTH, + #endif + #if GET_BUTTONS_ADC() == 0 + ADC_KEY, + #endif + #if GET_JOY_ADC_X() == 0 + JOY_X, + #endif + #if GET_JOY_ADC_Y() == 0 + JOY_Y, + #endif + #if GET_JOY_ADC_Z() == 0 + JOY_Z, + #endif + #if GET_TEMP_0_ADC() == 1 + TEMP_0, + #endif + #if GET_TEMP_1_ADC() == 1 + TEMP_1, + #endif + #if GET_TEMP_2_ADC() == 1 + TEMP_2, + #endif + #if GET_TEMP_3_ADC() == 1 + TEMP_3, + #endif + #if GET_TEMP_4_ADC() == 1 + TEMP_4, + #endif + #if GET_TEMP_5_ADC() == 1 + TEMP_5, + #endif + #if GET_TEMP_6_ADC() == 1 + TEMP_6, + #endif + #if GET_TEMP_7_ADC() == 1 + TEMP_7, + #endif + #if GET_BED_ADC() == 1 + TEMP_BED, + #endif + #if GET_CHAMBER_ADC() == 1 + TEMP_CHAMBER, + #endif + #if GET_PROBE_ADC() == 1 + TEMP_PROBE, + #endif + #if GET_COOLER_ADC() == 1 + TEMP_COOLER, + #endif + #if GET_BOARD_ADC() == 1 + TEMP_BOARD, + #endif + #if GET_FILAMENT_WIDTH_ADC() == 1 + FILWIDTH, + #endif + #if GET_BUTTONS_ADC() == 1 + ADC_KEY, + #endif + #if GET_JOY_ADC_X() == 1 + JOY_X, + #endif + #if GET_JOY_ADC_Y() == 1 + JOY_Y, + #endif + #if GET_JOY_ADC_Z() == 1 + JOY_Z, + #endif + ADC_COUNT +}; + // ------------------------ // Types // ------------------------ @@ -106,12 +220,10 @@ // Private Variables // ------------------------ -uint16_t HAL_adc_result; - #if ADC_IS_REQUIRED // Pins used by ADC inputs. Order must be ADC0 inputs first then ADC1 - const uint8_t adc_pins[] = { + static constexpr uint8_t adc_pins[ADC_COUNT] = { // ADC0 pins #if GET_TEMP_0_ADC() == 0 TEMP_0_PIN, @@ -137,24 +249,36 @@ uint16_t HAL_adc_result; #if GET_TEMP_7_ADC() == 0 TEMP_7_PIN, #endif - #if GET_PROBE_ADC() == 0 - TEMP_PROBE_PIN, - #endif #if GET_BED_ADC() == 0 TEMP_BED_PIN, #endif #if GET_CHAMBER_ADC() == 0 TEMP_CHAMBER_PIN, #endif + #if GET_PROBE_ADC() == 0 + TEMP_PROBE_PIN, + #endif #if GET_COOLER_ADC() == 0 TEMP_COOLER_PIN, #endif + #if GET_BOARD_ADC() == 0 + TEMP_BOARD_PIN, + #endif #if GET_FILAMENT_WIDTH_ADC() == 0 FILWIDTH_PIN, #endif #if GET_BUTTONS_ADC() == 0 ADC_KEYPAD_PIN, #endif + #if GET_JOY_ADC_X() == 0 + JOY_X_PIN, + #endif + #if GET_JOY_ADC_Y() == 0 + JOY_Y_PIN, + #endif + #if GET_JOY_ADC_Z() == 0 + JOY_Z_PIN, + #endif // ADC1 pins #if GET_TEMP_0_ADC() == 1 TEMP_0_PIN, @@ -180,33 +304,44 @@ uint16_t HAL_adc_result; #if GET_TEMP_7_ADC() == 1 TEMP_7_PIN, #endif - #if GET_PROBE_ADC() == 1 - TEMP_PROBE_PIN, - #endif #if GET_BED_ADC() == 1 TEMP_BED_PIN, #endif #if GET_CHAMBER_ADC() == 1 TEMP_CHAMBER_PIN, #endif + #if GET_PROBE_ADC() == 1 + TEMP_PROBE_PIN, + #endif #if GET_COOLER_ADC() == 1 TEMP_COOLER_PIN, #endif + #if GET_BOARD_ADC() == 1 + TEMP_BOARD_PIN, + #endif #if GET_FILAMENT_WIDTH_ADC() == 1 FILWIDTH_PIN, #endif #if GET_BUTTONS_ADC() == 1 ADC_KEYPAD_PIN, #endif + #if GET_JOY_ADC_X() == 1 + JOY_X_PIN, + #endif + #if GET_JOY_ADC_Y() == 1 + JOY_Y_PIN, + #endif + #if GET_JOY_ADC_Z() == 1 + JOY_Z_PIN, + #endif }; - uint16_t HAL_adc_results[COUNT(adc_pins)]; + static uint16_t adc_results[ADC_COUNT]; #if ADC0_IS_REQUIRED - Adafruit_ZeroDMA adc0DMAProgram, - adc0DMARead; + Adafruit_ZeroDMA adc0DMAProgram, adc0DMARead; - const HAL_DMA_DAC_Registers adc0_dma_regs_list[] = { + static constexpr HAL_DMA_DAC_Registers adc0_dma_regs_list[ADC_COUNT] = { #if GET_TEMP_0_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_0_PIN) }, #endif @@ -231,34 +366,45 @@ uint16_t HAL_adc_result; #if GET_TEMP_7_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_7_PIN) }, #endif - #if GET_PROBE_ADC() == 0 - { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) }, - #endif #if GET_BED_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_BED_PIN) }, #endif #if GET_CHAMBER_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) }, #endif + #if GET_PROBE_ADC() == 0 + { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) }, + #endif #if GET_COOLER_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) }, #endif + #if GET_BOARD_ADC() == 0 + { PIN_TO_INPUTCTRL(TEMP_BOARD_PIN) }, + #endif #if GET_FILAMENT_WIDTH_ADC() == 0 { PIN_TO_INPUTCTRL(FILWIDTH_PIN) }, #endif #if GET_BUTTONS_ADC() == 0 { PIN_TO_INPUTCTRL(ADC_KEYPAD_PIN) }, #endif + #if GET_JOY_ADC_X() == 0 + { PIN_TO_INPUTCTRL(JOY_X_PIN) }, + #endif + #if GET_JOY_ADC_Y() == 0 + { PIN_TO_INPUTCTRL(JOY_Y_PIN) }, + #endif + #if GET_JOY_ADC_Z() == 0 + { PIN_TO_INPUTCTRL(JOY_Z_PIN) }, + #endif }; #define ADC0_AINCOUNT COUNT(adc0_dma_regs_list) #endif // ADC0_IS_REQUIRED #if ADC1_IS_REQUIRED - Adafruit_ZeroDMA adc1DMAProgram, - adc1DMARead; + Adafruit_ZeroDMA adc1DMAProgram, adc1DMARead; - const HAL_DMA_DAC_Registers adc1_dma_regs_list[] = { + static constexpr HAL_DMA_DAC_Registers adc1_dma_regs_list[ADC_COUNT] = { #if GET_TEMP_0_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_0_PIN) }, #endif @@ -283,24 +429,36 @@ uint16_t HAL_adc_result; #if GET_TEMP_7_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_7_PIN) }, #endif - #if GET_PROBE_ADC() == 1 - { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) }, - #endif #if GET_BED_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_BED_PIN) }, #endif #if GET_CHAMBER_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) }, #endif + #if GET_PROBE_ADC() == 1 + { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) }, + #endif #if GET_COOLER_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) }, #endif + #if GET_BOARD_ADC() == 1 + { PIN_TO_INPUTCTRL(TEMP_BOARD_PIN) }, + #endif #if GET_FILAMENT_WIDTH_ADC() == 1 { PIN_TO_INPUTCTRL(FILWIDTH_PIN) }, #endif #if GET_BUTTONS_ADC() == 1 { PIN_TO_INPUTCTRL(ADC_KEYPAD_PIN) }, #endif + #if GET_JOY_ADC_X() == 1 + { PIN_TO_INPUTCTRL(JOY_X_PIN) }, + #endif + #if GET_JOY_ADC_Y() == 1 + { PIN_TO_INPUTCTRL(JOY_Y_PIN) }, + #endif + #if GET_JOY_ADC_Z() == 1 + { PIN_TO_INPUTCTRL(JOY_Z_PIN) }, + #endif }; #define ADC1_AINCOUNT COUNT(adc1_dma_regs_list) @@ -312,9 +470,10 @@ uint16_t HAL_adc_result; // Private functions // ------------------------ -#if DMA_IS_REQUIRED +void MarlinHAL::dma_init() { + + #if DMA_IS_REQUIRED - void dma_init() { DmacDescriptor *descriptor; #if ADC0_IS_REQUIRED @@ -343,7 +502,7 @@ uint16_t HAL_adc_result; if (adc0DMARead.allocate() == DMA_STATUS_OK) { adc0DMARead.addDescriptor( (void *)&ADC0->RESULT.reg, // SRC - &HAL_adc_results, // DEST + &adc_results, // DEST ADC0_AINCOUNT, // CNT DMA_BEAT_SIZE_HWORD, false, // SRCINC @@ -380,7 +539,7 @@ uint16_t HAL_adc_result; if (adc1DMARead.allocate() == DMA_STATUS_OK) { adc1DMARead.addDescriptor( (void *)&ADC1->RESULT.reg, // SRC - &HAL_adc_results[ADC0_AINCOUNT], // DEST + &adc_results[ADC0_AINCOUNT], // DEST ADC1_AINCOUNT, // CNT DMA_BEAT_SIZE_HWORD, false, // SRCINC @@ -393,16 +552,16 @@ uint16_t HAL_adc_result; #endif DMAC->PRICTRL0.bit.RRLVLEN0 = true; // Activate round robin for DMA channels required by ADCs - } -#endif // DMA_IS_REQUIRED + #endif // DMA_IS_REQUIRED +} // ------------------------ // Public functions // ------------------------ // HAL initialization task -void HAL_init() { +void MarlinHAL::init() { TERN_(DMA_IS_REQUIRED, dma_init()); #if ENABLED(SDSUPPORT) #if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT) @@ -412,17 +571,9 @@ void HAL_init() { #endif } -// HAL idle task -/* -void HAL_idletask() { -} -*/ - -void HAL_clear_reset_source() { } - #pragma push_macro("WDT") #undef WDT // Required to be able to use '.bit.WDT'. Compiler wrongly replace struct field with WDT define -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { RSTC_RCAUSE_Type resetCause; resetCause.reg = REG_RSTC_RCAUSE; @@ -436,7 +587,7 @@ uint8_t HAL_get_reset_source() { } #pragma pop_macro("WDT") -void HAL_reboot() { NVIC_SystemReset(); } +void MarlinHAL::reboot() { NVIC_SystemReset(); } extern "C" { void * _sbrk(int incr); @@ -454,9 +605,11 @@ int freeMemory() { // ADC // ------------------------ -void HAL_adc_init() { +uint16_t MarlinHAL::adc_result; + +void MarlinHAL::adc_init() { #if ADC_IS_REQUIRED - memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results)); // Fill result with invalid values + memset(adc_results, 0xFF, sizeof(adc_results)); // Fill result with invalid values LOOP_L_N(pi, COUNT(adc_pins)) pinPeripheral(adc_pins[pi], PIO_ANALOG); @@ -491,17 +644,13 @@ void HAL_adc_init() { #endif // ADC_IS_REQUIRED } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +void MarlinHAL::adc_start(const pin_t pin) { #if ADC_IS_REQUIRED - LOOP_L_N(pi, COUNT(adc_pins)) { - if (adc_pin == adc_pins[pi]) { - HAL_adc_result = HAL_adc_results[pi]; - return; - } - } + LOOP_L_N(pi, COUNT(adc_pins)) + if (pin == adc_pins[pi]) { adc_result = adc_results[pi]; return; } #endif - HAL_adc_result = 0xFFFF; + adc_result = 0xFFFF; } #endif // __SAMD51__ diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index c262752a8d66..3b09a885a53b 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -89,51 +89,30 @@ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() - -#define cli() __disable_irq() // Disable interrupts -#define sei() __enable_irq() // Enable interrupts - -void HAL_clear_reset_source(); // clear reset reason -uint8_t HAL_get_reset_source(); // get reset reason +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -void HAL_reboot(); +#define cli() __disable_irq() // Disable interrupts +#define sei() __enable_irq() // Enable interrupts // // ADC // -extern uint16_t HAL_adc_result; // Most recent ADC conversion - -#define HAL_ANALOG_SELECT(pin) - -void HAL_adc_init(); //#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values. #define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 // ... 12 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true -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 +// Pin Mapping for M42, M43, M226 // #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin @@ -142,35 +121,93 @@ inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -// Enable hooks into idle and setup for HAL -void HAL_init(); -/* -#define HAL_IDLETASK 1 -void HAL_idletask(); -*/ - -// -// Utility functions -// -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" #endif -int freeMemory(); - -#pragma GCC diagnostic pop - #ifdef __cplusplus extern "C" { #endif + char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s); + +extern "C" int freeMemory(); + #ifdef __cplusplus } #endif + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } + + static void delay_ms(const int ms) { delay(ms); } + + // Tasks, called from idle() + static void idletask() {} + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +private: + static void dma_init(); +}; diff --git a/Marlin/src/HAL/SAMD51/Servo.cpp b/Marlin/src/HAL/SAMD51/Servo.cpp index 9bab8e89be23..23ab21c615c4 100644 --- a/Marlin/src/HAL/SAMD51/Servo.cpp +++ b/Marlin/src/HAL/SAMD51/Servo.cpp @@ -53,7 +53,7 @@ static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval) FORCE_INLINE static uint16_t getTimerCount() { - Tc * const tc = TimerConfig[SERVO_TC].pTc; + Tc * const tc = timer_config[SERVO_TC].pTc; tc->COUNT16.CTRLBSET.reg = TC_CTRLBCLR_CMD_READSYNC; SYNC(tc->COUNT16.SYNCBUSY.bit.CTRLB || tc->COUNT16.SYNCBUSY.bit.COUNT); @@ -65,7 +65,7 @@ FORCE_INLINE static uint16_t getTimerCount() { // Interrupt handler for the TC // ---------------------------- HAL_SERVO_TIMER_ISR() { - Tc * const tc = TimerConfig[SERVO_TC].pTc; + Tc * const tc = timer_config[SERVO_TC].pTc; const timer16_Sequence_t timer = #ifndef _useTimer1 _timer2 @@ -125,7 +125,7 @@ HAL_SERVO_TIMER_ISR() { } void initISR(timer16_Sequence_t timer) { - Tc * const tc = TimerConfig[SERVO_TC].pTc; + Tc * const tc = timer_config[SERVO_TC].pTc; const uint8_t tcChannel = TIMER_TCCHANNEL(timer); static bool initialized = false; // Servo TC has been initialized @@ -202,7 +202,7 @@ void initISR(timer16_Sequence_t timer) { } void finISR(timer16_Sequence_t timer) { - Tc * const tc = TimerConfig[SERVO_TC].pTc; + Tc * const tc = timer_config[SERVO_TC].pTc; const uint8_t tcChannel = TIMER_TCCHANNEL(timer); // Disable the match channel interrupt request diff --git a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h index 38c6dd9e08de..1b876c947dc7 100644 --- a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h +++ b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h @@ -36,7 +36,7 @@ #error "OnBoard SPI BUS can't be shared with other devices." #endif -#if SERVO_TC == RTC_TIMER_NUM +#if SERVO_TC == MF_TIMER_RTC #error "Servos can't use RTC timer" #endif diff --git a/Marlin/src/HAL/SAMD51/timers.cpp b/Marlin/src/HAL/SAMD51/timers.cpp index 7a535299db9a..1ad0e360736a 100644 --- a/Marlin/src/HAL/SAMD51/timers.cpp +++ b/Marlin/src/HAL/SAMD51/timers.cpp @@ -31,13 +31,13 @@ // Local defines // -------------------------------------------------------------------------- -#define NUM_HARDWARE_TIMERS 8 +#define NUM_HARDWARE_TIMERS 9 // -------------------------------------------------------------------------- // Private Variables // -------------------------------------------------------------------------- -const tTimerConfig TimerConfig[NUM_HARDWARE_TIMERS+1] = { +const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = { { {.pTc=TC0}, TC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2) { {.pTc=TC1}, TC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers) { {.pTc=TC2}, TC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5) @@ -67,19 +67,19 @@ FORCE_INLINE void Disable_Irq(IRQn_Type irq) { // -------------------------------------------------------------------------- void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { - IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + IRQn_Type irq = timer_config[timer_num].IRQ_Id; // Disable interrupt, just in case it was already enabled Disable_Irq(irq); - if (timer_num == RTC_TIMER_NUM) { - Rtc * const rtc = TimerConfig[timer_num].pRtc; + if (timer_num == MF_TIMER_RTC) { + Rtc * const rtc = timer_config[timer_num].pRtc; // Disable timer interrupt rtc->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0; // RTC clock setup - OSC32KCTRL->RTCCTRL.reg = OSC32KCTRL_RTCCTRL_RTCSEL_XOSC32K; // External 32.768KHz oscillator + OSC32KCTRL->RTCCTRL.reg = OSC32KCTRL_RTCCTRL_RTCSEL_XOSC32K; // External 32.768kHz oscillator // Stop timer, just in case, to be able to reconfigure it rtc->MODE0.CTRLA.bit.ENABLE = false; @@ -101,7 +101,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { SYNC(rtc->MODE0.SYNCBUSY.bit.ENABLE); } else { - Tc * const tc = TimerConfig[timer_num].pTc; + Tc * const tc = timer_config[timer_num].pTc; // Disable timer interrupt tc->COUNT32.INTENCLR.reg = TC_INTENCLR_OVF; // disable overflow interrupt @@ -141,17 +141,17 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { } // Finally, enable IRQ - NVIC_SetPriority(irq, TimerConfig[timer_num].priority); + NVIC_SetPriority(irq, timer_config[timer_num].priority); NVIC_EnableIRQ(irq); } void HAL_timer_enable_interrupt(const uint8_t timer_num) { - const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; NVIC_EnableIRQ(irq); } void HAL_timer_disable_interrupt(const uint8_t timer_num) { - const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; Disable_Irq(irq); } @@ -161,7 +161,7 @@ static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) { } bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { - const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; return NVIC_GetEnabledIRQ(irq); } diff --git a/Marlin/src/HAL/SAMD51/timers.h b/Marlin/src/HAL/SAMD51/timers.h index dc6e38b7307c..86e980c56690 100644 --- a/Marlin/src/HAL/SAMD51/timers.h +++ b/Marlin/src/HAL/SAMD51/timers.h @@ -25,21 +25,22 @@ // -------------------------------------------------------------------------- // Defines // -------------------------------------------------------------------------- -#define RTC_TIMER_NUM 8 // This is not a TC but a RTC typedef uint32_t hal_timer_t; #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF #define HAL_TIMER_RATE F_CPU // frequency of timers peripherals -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#define MF_TIMER_RTC 8 // This is not a TC but a RTC + +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM RTC_TIMER_NUM // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature #endif #define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency @@ -52,30 +53,29 @@ typedef uint32_t hal_timer_t; #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) -#define TC_PRIORITY(t) t == SERVO_TC ? 1 \ - : (t == STEP_TIMER_NUM || t == PULSE_TIMER_NUM) ? 2 \ - : (t == TEMP_TIMER_NUM) ? 6 \ - : 7 +#define TC_PRIORITY(t) ( t == SERVO_TC ? 1 \ + : (t == MF_TIMER_STEP || t == MF_TIMER_PULSE) ? 2 \ + : (t == MF_TIMER_TEMP) ? 6 : 7 ) #define _TC_HANDLER(t) void TC##t##_Handler() #define TC_HANDLER(t) _TC_HANDLER(t) #ifndef HAL_STEP_TIMER_ISR - #define HAL_STEP_TIMER_ISR() TC_HANDLER(STEP_TIMER_NUM) + #define HAL_STEP_TIMER_ISR() TC_HANDLER(MF_TIMER_STEP) #endif -#if STEP_TIMER_NUM != PULSE_TIMER_NUM - #define HAL_PULSE_TIMER_ISR() TC_HANDLER(PULSE_TIMER_NUM) +#if MF_TIMER_STEP != MF_TIMER_PULSE + #define HAL_PULSE_TIMER_ISR() TC_HANDLER(MF_TIMER_PULSE) #endif -#if TEMP_TIMER_NUM == RTC_TIMER_NUM +#if MF_TIMER_TEMP == MF_TIMER_RTC #define HAL_TEMP_TIMER_ISR() void RTC_Handler() #else - #define HAL_TEMP_TIMER_ISR() TC_HANDLER(TEMP_TIMER_NUM) + #define HAL_TEMP_TIMER_ISR() TC_HANDLER(MF_TIMER_TEMP) #endif // -------------------------------------------------------------------------- @@ -95,7 +95,7 @@ typedef struct { // Public Variables // -------------------------------------------------------------------------- -extern const tTimerConfig TimerConfig[]; +extern const tTimerConfig timer_config[]; // -------------------------------------------------------------------------- // Public functions @@ -104,20 +104,20 @@ extern const tTimerConfig TimerConfig[]; void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { - // Should never be called with timer RTC_TIMER_NUM - Tc * const tc = TimerConfig[timer_num].pTc; + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; tc->COUNT32.CC[0].reg = compare; } FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { - // Should never be called with timer RTC_TIMER_NUM - Tc * const tc = TimerConfig[timer_num].pTc; + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; return (hal_timer_t)tc->COUNT32.CC[0].reg; } FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { - // Should never be called with timer RTC_TIMER_NUM - Tc * const tc = TimerConfig[timer_num].pTc; + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; tc->COUNT32.CTRLBSET.reg = TC_CTRLBCLR_CMD_READSYNC; SYNC(tc->COUNT32.SYNCBUSY.bit.CTRLB || tc->COUNT32.SYNCBUSY.bit.COUNT); return tc->COUNT32.COUNT.reg; @@ -128,13 +128,13 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { - if (timer_num == RTC_TIMER_NUM) { - Rtc * const rtc = TimerConfig[timer_num].pRtc; + if (timer_num == MF_TIMER_RTC) { + Rtc * const rtc = timer_config[timer_num].pRtc; // Clear interrupt flag rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0; } else { - Tc * const tc = TimerConfig[timer_num].pTc; + Tc * const tc = timer_config[timer_num].pTc; // Clear interrupt flag tc->COUNT32.INTFLAG.reg = TC_INTFLAG_OVF; } diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index 0920a72ec1bc..d28f506db9d3 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -53,16 +53,18 @@ // Public Variables // ------------------------ -uint16_t HAL_adc_result; +uint16_t MarlinHAL::adc_result; // ------------------------ // Public functions // ------------------------ -TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); +#if ENABLED(POSTMORTEM_DEBUGGING) + extern void install_min_serial(); +#endif // HAL initialization task -void HAL_init() { +void MarlinHAL::init() { // Ensure F_CPU is a constant expression. // If the compiler breaks here, it means that delay code that should compute at compile time will not work. // So better safe than sorry here. @@ -87,7 +89,7 @@ void HAL_init() { SetTimerInterruptPriorities(); - #if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC + #if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC) USB_Hook_init(); #endif @@ -103,7 +105,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // Stm32duino currently doesn't have a "loop/idle" method CDC_resume_receive(); @@ -111,9 +113,9 @@ void HAL_idletask() { #endif } -void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } +void MarlinHAL::reboot() { NVIC_SystemReset(); } -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { return #ifdef RCC_FLAG_IWDGRST // Some sources may not exist... RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) ? RST_WATCHDOG : @@ -137,24 +139,14 @@ uint8_t HAL_get_reset_source() { ; } -void HAL_reboot() { NVIC_SystemReset(); } - -void _delay_ms(const int delay_ms) { delay(delay_ms); } +void MarlinHAL::clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } extern "C" { extern unsigned int _ebss; // end of bss section } -// ------------------------ -// ADC -// ------------------------ - -// TODO: Make sure this doesn't cause any delay -void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); } -uint16_t HAL_adc_get_result() { return HAL_adc_result; } - // Reset the system to initiate a firmware flash -WEAK 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/HAL.h b/Marlin/src/HAL/STM32/HAL.h index a68e8a8c0e4a..f5e8c1187da7 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -44,9 +44,9 @@ #define CPU_ST7920_DELAY_2 40 #define CPU_ST7920_DELAY_3 340 -// -// Serial Ports -// +// ------------------------ +// Serial ports +// ------------------------ #ifdef USBCON #include #include "../../core/serial_hook.h" @@ -115,60 +115,79 @@ #define analogInputToDigitalPin(p) (p) #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +// +// Interrupts +// +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() #define cli() __disable_irq() #define sei() __enable_irq() -// On AVR this is in math.h? -#define square(x) ((x)*(x)) - // ------------------------ // Types // ------------------------ -typedef int16_t pin_t; +#ifdef STM32G0B1xx + typedef int32_t pin_t; +#else + typedef int16_t pin_t; +#endif -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; #define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos() #define RESUME_SERVO_OUTPUT() libServo::resume_all_servos() // ------------------------ -// Public Variables +// ADC // ------------------------ -// result of last ADC conversion -extern uint16_t HAL_adc_result; +#ifdef ADC_RESOLUTION + #define HAL_ADC_RESOLUTION ADC_RESOLUTION +#else + #define HAL_ADC_RESOLUTION 12 +#endif -// ------------------------ -// Public functions -// ------------------------ +#define HAL_ADC_VREF 3.3 -// Memory related -#define __bss_end __bss_end__ +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + +#ifdef STM32F1xx + #define JTAG_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_JTAGDISABLE) + #define JTAGSWD_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE) + #define JTAGSWD_RESET() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_RESET); // Reset: FULL SWD+JTAG +#endif -// Enable hooks into setup for HAL -void HAL_init(); -#define HAL_IDLETASK 1 -void HAL_idletask(); +#define PLATFORM_M997_SUPPORT +void flashFirmware(const int16_t); + +// Maple Compatibility +typedef void (*systickCallback_t)(void); +void systick_attach_callback(systickCallback_t cb); +void HAL_SYSTICK_Callback(); -// Clear reset reason -void HAL_clear_reset_source(); +extern volatile uint32_t systick_uptime_millis; -// Reset reason -uint8_t HAL_get_reset_source(); +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment -void HAL_reboot(); +// ------------------------ +// Class Utilities +// ------------------------ -void _delay_ms(const int delay); +// Memory related +#define __bss_end __bss_end__ extern "C" char* _sbrk(int incr); #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif static inline int freeMemory() { volatile char top; @@ -177,62 +196,71 @@ static inline int freeMemory() { #pragma GCC diagnostic pop -// -// ADC -// +// ------------------------ +// MarlinHAL Class +// ------------------------ -#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT) +class MarlinHAL { +public: -#ifdef ADC_RESOLUTION - #define HAL_ADC_RESOLUTION ADC_RESOLUTION -#else - #define HAL_ADC_RESOLUTION 12 -#endif + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ADC_VREF 3.3 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -inline void HAL_adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); } + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } -void HAL_adc_start_conversion(const uint8_t adc_pin); + static void delay_ms(const int ms) { delay(ms); } -uint16_t HAL_adc_get_result(); + // Tasks, called from idle() + static void idletask(); -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source(); -#ifdef STM32F1xx - #define JTAG_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_JTAGDISABLE) - #define JTAGSWD_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE) - #define JTAGSWD_RESET() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_RESET); // Reset: FULL SWD+JTAG -#endif + // Free SRAM + static int freeMemory() { return ::freeMemory(); } -#define PLATFORM_M997_SUPPORT -void flashFirmware(const int16_t); + // + // ADC Methods + // -// Maple Compatibility -typedef void (*systickCallback_t)(void); -void systick_attach_callback(systickCallback_t cb); -void HAL_SYSTICK_Callback(); + static uint16_t adc_result; -extern volatile uint32_t systick_uptime_millis; + // Called by Temperature::init once at startup + static void adc_init() { + analogReadResolution(HAL_ADC_RESOLUTION); + } -#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); } -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Timer PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, int f_desired); + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin) { adc_result = analogRead(pin); } -/** - * set_pwm_duty - * 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] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally change the maximum size of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + + /** + * Set the frequency of the timer for the given pin. + * All Timer PWM pins run at the same frequency. + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); + +}; diff --git a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp index 29826a890de4..b6e86b72daa9 100644 --- a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp @@ -135,7 +135,7 @@ void install_min_serial() { HAL_min_serial_out = &TX; } -#if DISABLED(DYNAMIC_VECTORTABLE) && DISABLED(STM32F0xx) // Cortex M0 can't jump to a symbol that's too far from the current function, so we work around this in exception_arm.cpp +#if NONE(DYNAMIC_VECTORTABLE, STM32F0xx, STM32G0xx) // Cortex M0 can't jump to a symbol that's too far from the current function, so we work around this in exception_arm.cpp extern "C" { __attribute__((naked)) void JumpHandler_ASM() { __asm__ __volatile__ ( diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index 8ee476164785..40d320d5e822 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -102,9 +102,9 @@ static SPISettings spiConfig; // Soft SPI receive byte uint8_t spiRec() { - DISABLE_ISRS(); // No interrupts during byte receive + hal.isr_off(); // No interrupts during byte receive const uint8_t data = HAL_SPI_STM32_SpiTransfer_Mode_3(0xFF); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts return data; } @@ -116,9 +116,9 @@ static SPISettings spiConfig; // Soft SPI send byte void spiSend(uint8_t data) { - DISABLE_ISRS(); // No interrupts during byte send + hal.isr_off(); // No interrupts during byte send HAL_SPI_STM32_SpiTransfer_Mode_3(data); // Don't care what is received - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts } // Soft SPI send block diff --git a/Marlin/src/HAL/STM32/MarlinSPI.cpp b/Marlin/src/HAL/STM32/MarlinSPI.cpp index 7078d210dc4c..f7c603d77e5c 100644 --- a/Marlin/src/HAL/STM32/MarlinSPI.cpp +++ b/Marlin/src/HAL/STM32/MarlinSPI.cpp @@ -114,16 +114,19 @@ byte MarlinSPI::transfer(uint8_t _data) { return rxData; } +__STATIC_INLINE void LL_SPI_EnableDMAReq_RX(SPI_TypeDef *SPIx) { SET_BIT(SPIx->CR2, SPI_CR2_RXDMAEN); } +__STATIC_INLINE void LL_SPI_EnableDMAReq_TX(SPI_TypeDef *SPIx) { SET_BIT(SPIx->CR2, SPI_CR2_TXDMAEN); } + uint8_t MarlinSPI::dmaTransfer(const void *transmitBuf, void *receiveBuf, uint16_t length) { const uint8_t ff = 0xFF; - //if ((hspi->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) //only enable if disabled + //if (!LL_SPI_IsEnabled(_spi.handle)) // only enable if disabled __HAL_SPI_ENABLE(&_spi.handle); if (receiveBuf) { setupDma(_spi.handle, _dmaRx, DMA_PERIPH_TO_MEMORY, true); HAL_DMA_Start(&_dmaRx, (uint32_t)&(_spi.handle.Instance->DR), (uint32_t)receiveBuf, length); - SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_RXDMAEN); /* Enable Rx DMA Request */ + LL_SPI_EnableDMAReq_RX(_spi.handle.Instance); // Enable Rx DMA Request } // check for 2 lines transfer @@ -136,7 +139,7 @@ uint8_t MarlinSPI::dmaTransfer(const void *transmitBuf, void *receiveBuf, uint16 if (transmitBuf) { setupDma(_spi.handle, _dmaTx, DMA_MEMORY_TO_PERIPH, mincTransmit); HAL_DMA_Start(&_dmaTx, (uint32_t)transmitBuf, (uint32_t)&(_spi.handle.Instance->DR), length); - SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */ + LL_SPI_EnableDMAReq_TX(_spi.handle.Instance); // Enable Tx DMA Request } if (transmitBuf) { @@ -160,7 +163,7 @@ uint8_t MarlinSPI::dmaSend(const void * transmitBuf, uint16_t length, bool minc) setupDma(_spi.handle, _dmaTx, DMA_MEMORY_TO_PERIPH, minc); HAL_DMA_Start(&_dmaTx, (uint32_t)transmitBuf, (uint32_t)&(_spi.handle.Instance->DR), length); __HAL_SPI_ENABLE(&_spi.handle); - SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */ + LL_SPI_EnableDMAReq_TX(_spi.handle.Instance); // Enable Tx DMA Request HAL_DMA_PollForTransfer(&_dmaTx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY); HAL_DMA_Abort(&_dmaTx); // DeInit objects diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 252b057362c9..7c8cc8dd21e1 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -174,9 +174,9 @@ bool PersistentStore::access_finish() { UNLOCK_FLASH(); TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); - DISABLE_ISRS(); + hal.isr_off(); status = HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError); - ENABLE_ISRS(); + hal.isr_on(); TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); if (status != HAL_OK) { DEBUG_ECHOLNPGM("HAL_FLASHEx_Erase=", status); @@ -229,9 +229,9 @@ bool PersistentStore::access_finish() { // output. Servo output still glitches with interrupts disabled, but recovers after the // erase. TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); - DISABLE_ISRS(); + hal.isr_off(); eeprom_buffer_flush(); - ENABLE_ISRS(); + hal.isr_on(); TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); eeprom_data_written = false; diff --git a/Marlin/src/HAL/STM32/fast_pwm.cpp b/Marlin/src/HAL/STM32/fast_pwm.cpp index 4d450374d32b..a0d8ecc612c2 100644 --- a/Marlin/src/HAL/STM32/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32/fast_pwm.cpp @@ -25,39 +25,64 @@ #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" -#include "timers.h" -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 +// Array to support sticky frequency sets per timer +static uint16_t timer_freq[TIMER_NUM]; - PinName pin_name = digitalPinToPinName(pin); - TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { + const uint16_t duty = invert ? v_size - v : v; + if (PWM_PIN(pin)) { + const PinName pin_name = digitalPinToPinName(pin); + TIM_TypeDef * const 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; - case TIM_CHANNEL_3: LL_TIM_OC_SetCompareCH3(Instance, adj_val); break; - case TIM_CHANNEL_4: LL_TIM_OC_SetCompareCH4(Instance, adj_val); break; - } -} + const timer_index_t index = get_timer_index(Instance); + const bool needs_freq = (HardwareTimer_Handle[index] == nullptr); + if (needs_freq) // A new instance must be set to the default frequency of PWM_FREQUENCY + HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM)); -#if NEEDS_HARDWARE_PWM + HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this); + const uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin_name, PinMap_PWM)); + const TimerModes_t previousMode = HT->getMode(channel); + if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) + HT->setMode(channel, TIMER_OUTPUT_COMPARE_PWM1, pin); - void set_pwm_frequency(const pin_t pin, int f_desired) { - if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer + if (needs_freq && timer_freq[index] == 0) // If the timer is unconfigured and no freq is set then default PWM_FREQUENCY + set_pwm_frequency(pin_name, PWM_FREQUENCY); // Set the frequency and save the value to the assigned index no. - PinName pin_name = digitalPinToPinName(pin); - TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance + // Note the resolution is sticky here, the input can be upto 16 bits and that would require RESOLUTION_16B_COMPARE_FORMAT (16) + // If such a need were to manifest then we would need to calc the resolution based on the v_size parameter and add code for it. + HT->setCaptureCompare(channel, duty, RESOLUTION_8B_COMPARE_FORMAT); // Set the duty, the calc is done in the library :) + pinmap_pinout(pin_name, PinMap_PWM); // Make sure the pin output state is set. + if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) HT->resume(); + } + else { + pinMode(pin, OUTPUT); + digitalWrite(pin, duty < v_size / 2 ? LOW : HIGH); + } +} - LOOP_S_L_N(i, 0, NUM_HARDWARE_TIMERS) // Protect used timers - if (timer_instance[i] && timer_instance[i]->getHandle()->Instance == Instance) - return; +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { + if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer + const PinName pin_name = digitalPinToPinName(pin); + TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance + const timer_index_t index = get_timer_index(Instance); - pwm_start(pin_name, f_desired, 0, RESOLUTION_8B_COMPARE_FORMAT); - } + // Protect used timers. + #ifdef STEP_TIMER + if (index == TIMER_INDEX(STEP_TIMER)) return; + #endif + #ifdef TEMP_TIMER + if (index == TIMER_INDEX(TEMP_TIMER)) return; + #endif + #if defined(PULSE_TIMER) && MF_TIMER_PULSE != MF_TIMER_STEP + if (index == TIMER_INDEX(PULSE_TIMER)) return; + #endif -#endif + if (HardwareTimer_Handle[index] == nullptr) // If frequency is set before duty we need to create a handle here. + HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM)); + HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this); + HT->setOverflow(f_desired, HERTZ_FORMAT); + timer_freq[index] = f_desired; // Save the last frequency so duty will not set the default for this timer number. +} #endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/pinsDebug.h b/Marlin/src/HAL/STM32/pinsDebug.h index 73d850fc4313..a7f022a0b62d 100644 --- a/Marlin/src/HAL/STM32/pinsDebug.h +++ b/Marlin/src/HAL/STM32/pinsDebug.h @@ -115,7 +115,6 @@ const XrefInfo pin_xref[] PROGMEM = { #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PORT(ANUM) port_print(ANUM) #define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine -#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num // x is a variable used to search pin_array #define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital) @@ -123,6 +122,11 @@ const XrefInfo pin_xref[] PROGMEM = { #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) #define MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin +// +// Pin Mapping for M43 +// +#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num + #ifndef M43_NEVER_TOUCH #define _M43_NEVER_TOUCH(Index) (Index >= 9 && Index <= 12) // SERIAL/USB pins: PA9(TX) PA10(RX) PA11(USB_DM) PA12(USB_DP) #ifdef KILL_PIN diff --git a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp b/Marlin/src/HAL/STM32/sdio.cpp similarity index 97% rename from Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp rename to Marlin/src/HAL/STM32/sdio.cpp index 54e1820c78e6..0af5f9040e54 100644 --- a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp +++ b/Marlin/src/HAL/STM32/sdio.cpp @@ -28,6 +28,8 @@ #if ENABLED(SDIO_SUPPORT) +#include "sdio.h" + #include #include @@ -49,14 +51,6 @@ #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, or STM32F7xx." #endif -// Fixed -#define SDIO_D0_PIN PC8 -#define SDIO_D1_PIN PC9 -#define SDIO_D2_PIN PC10 -#define SDIO_D3_PIN PC11 -#define SDIO_CK_PIN PC12 -#define SDIO_CMD_PIN PD2 - SD_HandleTypeDef hsd; // create SDIO structure // F4 supports one DMA for RX and another for TX, but Marlin will never // do read and write at same time, so we use the same DMA for both. @@ -65,7 +59,7 @@ DMA_HandleTypeDef hdma_sdio; /* SDIO_INIT_CLK_DIV is 118 SDIO clock frequency is 48MHz / (TRANSFER_CLOCK_DIV + 2) - SDIO init clock frequency should not exceed 400KHz = 48MHz / (118 + 2) + SDIO init clock frequency should not exceed 400kHz = 48MHz / (118 + 2) Default TRANSFER_CLOCK_DIV is 2 (118 / 40) Default SDIO clock frequency is 48MHz / (2 + 2) = 12 MHz diff --git a/Marlin/src/HAL/STM32/sdio.h b/Marlin/src/HAL/STM32/sdio.h new file mode 100644 index 000000000000..cf5539c3c76d --- /dev/null +++ b/Marlin/src/HAL/STM32/sdio.h @@ -0,0 +1,29 @@ +/** + * 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 + +#define SDIO_D0_PIN PC8 +#define SDIO_D1_PIN PC9 +#define SDIO_D2_PIN PC10 +#define SDIO_D3_PIN PC11 +#define SDIO_CK_PIN PC12 +#define SDIO_CMD_PIN PD2 diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 790513e7edd9..2e18c8a64c06 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -161,11 +161,11 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { for (i = 0; i < 4; i++) { #if TFT_MISO_PIN != TFT_MOSI_PIN //if (hspi->Init.Direction == SPI_DIRECTION_2LINES) { - while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} SPIx.Instance->DR = 0; //} #endif - while ((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_RXNE)) {} Data = (Data << 8) | SPIx.Instance->DR; } @@ -195,8 +195,8 @@ bool TFT_SPI::isBusy() { void TFT_SPI::Abort() { // Wait for any running spi - while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {} - while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} + while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {} // First, abort any running dma HAL_DMA_Abort(&DMAtx); // DeInit objects @@ -214,8 +214,8 @@ void TFT_SPI::Transmit(uint16_t Data) { SPIx.Instance->DR = Data; - while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {} - while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} + while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {} if (TFT_MISO_PIN != TFT_MOSI_PIN) __HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received is not read @@ -242,5 +242,29 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun Abort(); } +#if ENABLED(USE_SPI_DMA_TC) + + void TFT_SPI::TransmitDMA_IT(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + + DMAtx.Init.MemInc = MemoryIncrease; + HAL_DMA_Init(&DMAtx); + + if (TFT_MISO_PIN == TFT_MOSI_PIN) + SPI_1LINE_TX(&SPIx); + + DataTransferBegin(); + + HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); + HAL_DMA_Start_IT(&DMAtx, (uint32_t)Data, (uint32_t)&(SPIx.Instance->DR), Count); + __HAL_SPI_ENABLE(&SPIx); + + SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request + } + + extern "C" void DMA2_Stream3_IRQHandler(void) { HAL_DMA_IRQHandler(&TFT_SPI::DMAtx); } + +#endif + #endif // HAS_SPI_TFT #endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.h b/Marlin/src/HAL/STM32/tft/tft_spi.h index 667b5f366b7e..de051e229459 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32/tft/tft_spi.h @@ -36,20 +36,25 @@ #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341) #endif -#define DATASIZE_8BIT SPI_DATASIZE_8BIT -#define DATASIZE_16BIT SPI_DATASIZE_16BIT -#define TFT_IO_DRIVER TFT_SPI +#define DATASIZE_8BIT SPI_DATASIZE_8BIT +#define DATASIZE_16BIT SPI_DATASIZE_16BIT +#define TFT_IO_DRIVER TFT_SPI class TFT_SPI { private: static SPI_HandleTypeDef SPIx; - static DMA_HandleTypeDef DMAtx; + static uint32_t ReadID(uint16_t Reg); static void Transmit(uint16_t Data); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); + #if ENABLED(USE_SPI_DMA_TC) + static void TransmitDMA_IT(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); + #endif public: + static DMA_HandleTypeDef DMAtx; + static void Init(); static uint32_t GetID(); static bool isBusy(); @@ -63,6 +68,11 @@ class TFT_SPI { static void WriteReg(uint16_t Reg) { WRITE(TFT_A0_PIN, LOW); Transmit(Reg); WRITE(TFT_A0_PIN, HIGH); } static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + + #if ENABLED(USE_SPI_DMA_TC) + static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { TransmitDMA_IT(DMA_MINC_ENABLE, Data, Count); } + #endif + static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { static uint16_t Data; Data = Color; diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.h b/Marlin/src/HAL/STM32/tft/xpt2046.h index 2cff3e29d05b..71de6b00251b 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32/tft/xpt2046.h @@ -69,8 +69,8 @@ class XPT2046 { static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); - static inline void DataTransferBegin() { if (SPIx.Instance) { HAL_SPI_Init(&SPIx); } WRITE(TOUCH_CS_PIN, LOW); }; - static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; + static void DataTransferBegin() { if (SPIx.Instance) { HAL_SPI_Init(&SPIx); } WRITE(TOUCH_CS_PIN, LOW); }; + static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; static uint16_t HardwareIO(uint16_t data); static uint16_t SoftwareIO(uint16_t data); static uint16_t IO(uint16_t data = 0) { return SPIx.Instance ? HardwareIO(data) : SoftwareIO(data); } diff --git a/Marlin/src/HAL/STM32/timers.cpp b/Marlin/src/HAL/STM32/timers.cpp index 9b69323ef543..a1e3372bbb2e 100644 --- a/Marlin/src/HAL/STM32/timers.cpp +++ b/Marlin/src/HAL/STM32/timers.cpp @@ -67,17 +67,17 @@ #endif #endif -#ifdef STM32F0xx +#if defined(STM32F0xx) || defined(STM32G0xx) #define MCU_STEP_TIMER 16 #define MCU_TEMP_TIMER 17 #elif defined(STM32F1xx) #define MCU_STEP_TIMER 4 #define MCU_TEMP_TIMER 2 #elif defined(STM32F401xC) || defined(STM32F401xE) - #define MCU_STEP_TIMER 9 + #define MCU_STEP_TIMER 9 // STM32F401 has no TIM6, TIM7, or TIM8 #define MCU_TEMP_TIMER 10 #elif defined(STM32F4xx) || defined(STM32F7xx) || defined(STM32H7xx) - #define MCU_STEP_TIMER 6 // STM32F401 has no TIM6, TIM7, or TIM8 + #define MCU_STEP_TIMER 6 #define MCU_TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used. #endif @@ -97,9 +97,15 @@ #define STEP_TIMER_DEV _TIMER_DEV(STEP_TIMER) #define TEMP_TIMER_DEV _TIMER_DEV(TEMP_TIMER) -// ------------------------ +// -------------------------------------------------------------------------- +// Local defines +// -------------------------------------------------------------------------- + +#define NUM_HARDWARE_TIMERS 2 + +// -------------------------------------------------------------------------- // Private Variables -// ------------------------ +// -------------------------------------------------------------------------- HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { nullptr }; @@ -110,7 +116,7 @@ HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { nullptr }; uint32_t GetStepperTimerClkFreq() { // Timer input clocks vary between devices, and in some cases between timers on the same device. // Retrieve at runtime to ensure device compatibility. Cache result to avoid repeated overhead. - static uint32_t clkfreq = timer_instance[STEP_TIMER_NUM]->getTimerClkFreq(); + static uint32_t clkfreq = timer_instance[MF_TIMER_STEP]->getTimerClkFreq(); return clkfreq; } @@ -118,7 +124,7 @@ uint32_t GetStepperTimerClkFreq() { void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { if (!HAL_timer_initialized(timer_num)) { switch (timer_num) { - case STEP_TIMER_NUM: // STEPPER TIMER - use a 32bit timer if possible + case MF_TIMER_STEP: // STEPPER TIMER - use a 32bit timer if possible timer_instance[timer_num] = new HardwareTimer(STEP_TIMER_DEV); /* Set the prescaler to the final desired value. * This will change the effective ISR callback frequency but when @@ -137,7 +143,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT); break; - case TEMP_TIMER_NUM: // TEMP TIMER - any available 16bit timer + case MF_TIMER_TEMP: // TEMP TIMER - any available 16bit timer timer_instance[timer_num] = new HardwareTimer(TEMP_TIMER_DEV); // The prescale factor is computed automatically for HERTZ_FORMAT timer_instance[timer_num]->setOverflow(frequency, HERTZ_FORMAT); @@ -157,10 +163,10 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { // These calls can be removed and replaced with // timer_instance[timer_num]->setInterruptPriority switch (timer_num) { - case STEP_TIMER_NUM: + case MF_TIMER_STEP: timer_instance[timer_num]->setInterruptPriority(STEP_TIMER_IRQ_PRIO, 0); break; - case TEMP_TIMER_NUM: + case MF_TIMER_TEMP: timer_instance[timer_num]->setInterruptPriority(TEMP_TIMER_IRQ_PRIO, 0); break; } @@ -170,10 +176,10 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { void HAL_timer_enable_interrupt(const uint8_t timer_num) { if (HAL_timer_initialized(timer_num) && !timer_instance[timer_num]->hasInterrupt()) { switch (timer_num) { - case STEP_TIMER_NUM: + case MF_TIMER_STEP: timer_instance[timer_num]->attachInterrupt(Step_Handler); break; - case TEMP_TIMER_NUM: + case MF_TIMER_TEMP: timer_instance[timer_num]->attachInterrupt(Temp_Handler); break; } diff --git a/Marlin/src/HAL/STM32/timers.h b/Marlin/src/HAL/STM32/timers.h index 7a35e432102d..6828998198af 100644 --- a/Marlin/src/HAL/STM32/timers.h +++ b/Marlin/src/HAL/STM32/timers.h @@ -40,17 +40,13 @@ #define hal_timer_t uint32_t #define HAL_TIMER_TYPE_MAX UINT16_MAX -#define NUM_HARDWARE_TIMERS 2 +// Marlin timer_instance[] content (unrelated to timer selection) +#define MF_TIMER_STEP 0 // Timer Index for Stepper +#define MF_TIMER_TEMP 1 // Timer Index for Temperature +#define MF_TIMER_PULSE MF_TIMER_STEP -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper -#endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM -#endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 1 // Timer Index for Temperature -#endif +#define TIMER_INDEX_(T) TIMER##T##_INDEX // TIMER#_INDEX enums (timer_index_t) depend on TIM#_BASE defines. +#define TIMER_INDEX(T) TIMER_INDEX_(T) // Convert Timer ID to HardwareTimer_Handle index. #define TEMP_TIMER_FREQUENCY 1000 // Temperature::isr() is expected to be called at around 1kHz @@ -64,12 +60,12 @@ extern uint32_t GetStepperTimerClkFreq(); #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) extern void Step_Handler(); extern void Temp_Handler(); @@ -120,5 +116,5 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha } } -#define HAL_timer_isr_prologue(TIMER_NUM) -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/STM32/usb_serial.cpp b/Marlin/src/HAL/STM32/usb_serial.cpp index b607275db5bb..0b2372f3a79d 100644 --- a/Marlin/src/HAL/STM32/usb_serial.cpp +++ b/Marlin/src/HAL/STM32/usb_serial.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC +#if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC) #include "usb_serial.h" #include "../../feature/e_parser.h" diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index f29b30536146..636dc742fcf5 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -79,7 +79,7 @@ #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ // ------------------------ -// Public Variables +// Serial ports // ------------------------ #if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE @@ -112,148 +112,37 @@ #endif #endif -uint16_t HAL_adc_result; - // ------------------------ -// Private Variables +// ADC // ------------------------ -STM32ADC adc(ADC1); -const uint8_t adc_pins[] = { - #if HAS_TEMP_ADC_0 - TEMP_0_PIN, - #endif - #if HAS_TEMP_ADC_PROBE - TEMP_PROBE_PIN, - #endif - #if HAS_HEATED_BED - TEMP_BED_PIN, - #endif - #if HAS_TEMP_CHAMBER - TEMP_CHAMBER_PIN, - #endif - #if HAS_TEMP_COOLER - TEMP_COOLER_PIN, - #endif - #if HAS_TEMP_ADC_1 - TEMP_1_PIN, - #endif - #if HAS_TEMP_ADC_2 - TEMP_2_PIN, - #endif - #if HAS_TEMP_ADC_3 - TEMP_3_PIN, - #endif - #if HAS_TEMP_ADC_4 - TEMP_4_PIN, - #endif - #if HAS_TEMP_ADC_5 - TEMP_5_PIN, - #endif - #if HAS_TEMP_ADC_6 - TEMP_6_PIN, - #endif - #if HAS_TEMP_ADC_7 - TEMP_7_PIN, - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - FILWIDTH_PIN, - #endif - #if HAS_ADC_BUTTONS - ADC_KEYPAD_PIN, - #endif - #if HAS_JOY_ADC_X - JOY_X_PIN, - #endif - #if HAS_JOY_ADC_Y - JOY_Y_PIN, - #endif - #if HAS_JOY_ADC_Z - JOY_Z_PIN, - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - POWER_MONITOR_CURRENT_PIN, - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - POWER_MONITOR_VOLTAGE_PIN, - #endif -}; +// Watch out for recursion here! Our pin_t is signed, so pass through to Arduino -> analogRead(uint8_t) -enum TempPinIndex : char { - #if HAS_TEMP_ADC_0 - TEMP_0, - #endif - #if HAS_TEMP_ADC_PROBE - TEMP_PROBE, - #endif - #if HAS_HEATED_BED - TEMP_BED, - #endif - #if HAS_TEMP_CHAMBER - TEMP_CHAMBER, - #endif - #if HAS_TEMP_COOLER - TEMP_COOLER_PIN, - #endif - #if HAS_TEMP_ADC_1 - TEMP_1, - #endif - #if HAS_TEMP_ADC_2 - TEMP_2, - #endif - #if HAS_TEMP_ADC_3 - TEMP_3, - #endif - #if HAS_TEMP_ADC_4 - TEMP_4, - #endif - #if HAS_TEMP_ADC_5 - TEMP_5, - #endif - #if HAS_TEMP_ADC_6 - TEMP_6, - #endif - #if HAS_TEMP_ADC_7 - TEMP_7, - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - FILWIDTH, - #endif - #if HAS_ADC_BUTTONS - ADC_KEY, - #endif - #if HAS_JOY_ADC_X - JOY_X, - #endif - #if HAS_JOY_ADC_Y - JOY_Y, - #endif - #if HAS_JOY_ADC_Z - JOY_Z, - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - POWERMON_CURRENT, - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - POWERMON_VOLTS, - #endif - ADC_PIN_COUNT -}; +uint16_t analogRead(const pin_t pin) { + const bool is_analog = _GET_MODE(pin) == GPIO_INPUT_ANALOG; + return is_analog ? analogRead(uint8_t(pin)) : 0; +} + +// Wrapper to maple unprotected analogWrite +void analogWrite(const pin_t pin, int pwm_val8) { + if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8); +} -uint16_t HAL_adc_results[ADC_PIN_COUNT]; +uint16_t MarlinHAL::adc_result; // ------------------------ // Private functions // ------------------------ + static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); // only values 0..7 are used - reg_value = SCB->AIRCR; /* read old register configuration */ - reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */ + reg_value = SCB->AIRCR; // read old register configuration + reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); // clear bits to change reg_value = (reg_value | ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8)); /* Insert write key & priority group */ + (PriorityGroupTmp << 8)); // Insert write key & priority group SCB->AIRCR = reg_value; } @@ -261,6 +150,8 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { // Public functions // ------------------------ +void flashFirmware(const int16_t) { hal.reboot(); } + // // Leave PA11/PA12 intact if USBSerial is not used // @@ -280,7 +171,11 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); -void HAL_init() { +// ------------------------ +// MarlinHAL class +// ------------------------ + +void MarlinHAL::init() { NVIC_SetPriorityGrouping(0x3); #if PIN_EXISTS(LED) OUT_WRITE(LED_PIN, LOW); @@ -299,7 +194,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // If Marlin is using the SD card we need to lock it to prevent access from // a PC via USB. @@ -314,14 +209,7 @@ void HAL_idletask() { #endif } -void HAL_clear_reset_source() { } - -/** - * TODO: Check this and change or remove. - */ -uint8_t HAL_get_reset_source() { return RST_POWER_ON; } - -void _delay_ms(const int delay_ms) { delay(delay_ms); } +void MarlinHAL::reboot() { nvic_sys_reset(); } extern "C" { extern unsigned int _ebss; // end of bss section @@ -355,105 +243,99 @@ extern "C" { } */ -// ------------------------ +// // ADC -// ------------------------ +// + +enum ADCIndex : uint8_t { + OPTITEM(HAS_TEMP_ADC_0, TEMP_0) + OPTITEM(HAS_TEMP_ADC_1, TEMP_1) + OPTITEM(HAS_TEMP_ADC_2, TEMP_2) + OPTITEM(HAS_TEMP_ADC_3, TEMP_3) + OPTITEM(HAS_TEMP_ADC_4, TEMP_4) + OPTITEM(HAS_TEMP_ADC_5, TEMP_5) + OPTITEM(HAS_TEMP_ADC_6, TEMP_6) + OPTITEM(HAS_TEMP_ADC_7, TEMP_7) + OPTITEM(HAS_HEATED_BED, TEMP_BED) + OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER) + OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE) + OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER) + OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD) + OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH) + OPTITEM(HAS_ADC_BUTTONS, ADC_KEY) + OPTITEM(HAS_JOY_ADC_X, JOY_X) + OPTITEM(HAS_JOY_ADC_Y, JOY_Y) + OPTITEM(HAS_JOY_ADC_Z, JOY_Z) + OPTITEM(POWER_MONITOR_CURRENT, POWERMON_CURRENT) + OPTITEM(POWER_MONITOR_VOLTAGE, POWERMON_VOLTS) + ADC_COUNT +}; + +static uint16_t adc_results[ADC_COUNT]; + // Init the AD in continuous capture mode -void HAL_adc_init() { +void MarlinHAL::adc_init() { + static const uint8_t adc_pins[] = { + OPTITEM(HAS_TEMP_ADC_0, TEMP_0_PIN) + OPTITEM(HAS_TEMP_ADC_1, TEMP_1_PIN) + OPTITEM(HAS_TEMP_ADC_2, TEMP_2_PIN) + OPTITEM(HAS_TEMP_ADC_3, TEMP_3_PIN) + OPTITEM(HAS_TEMP_ADC_4, TEMP_4_PIN) + OPTITEM(HAS_TEMP_ADC_5, TEMP_5_PIN) + OPTITEM(HAS_TEMP_ADC_6, TEMP_6_PIN) + OPTITEM(HAS_TEMP_ADC_7, TEMP_7_PIN) + OPTITEM(HAS_HEATED_BED, TEMP_BED_PIN) + OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN) + OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN) + OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN) + OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN) + OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN) + OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN) + OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN) + OPTITEM(HAS_JOY_ADC_Y, JOY_Y_PIN) + OPTITEM(HAS_JOY_ADC_Z, JOY_Z_PIN) + OPTITEM(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN) + OPTITEM(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN) + }; + static STM32ADC adc(ADC1); // configure the ADC adc.calibrate(); - #if F_CPU > 72000000 - adc.setSampleRate(ADC_SMPR_71_5); // 71.5 ADC cycles - #else - adc.setSampleRate(ADC_SMPR_41_5); // 41.5 ADC cycles - #endif - adc.setPins((uint8_t *)adc_pins, ADC_PIN_COUNT); - adc.setDMA(HAL_adc_results, (uint16_t)ADC_PIN_COUNT, (uint32_t)(DMA_MINC_MODE | DMA_CIRC_MODE), nullptr); + adc.setSampleRate((F_CPU > 72000000) ? ADC_SMPR_71_5 : ADC_SMPR_41_5); // 71.5 or 41.5 ADC cycles + adc.setPins((uint8_t *)adc_pins, ADC_COUNT); + adc.setDMA(adc_results, uint16_t(ADC_COUNT), uint32_t(DMA_MINC_MODE | DMA_CIRC_MODE), nullptr); adc.setScanMode(); adc.setContinuous(); adc.startConversion(); } -void HAL_adc_start_conversion(const uint8_t adc_pin) { - //TEMP_PINS pin_index; - TempPinIndex pin_index; - switch (adc_pin) { +void MarlinHAL::adc_start(const pin_t pin) { + #define __TCASE(N,I) case N: pin_index = I; break; + #define _TCASE(C,N,I) TERN_(C, __TCASE(N, I)) + ADCIndex pin_index; + switch (pin) { default: return; - #if HAS_TEMP_ADC_0 - case TEMP_0_PIN: pin_index = TEMP_0; break; - #endif - #if HAS_TEMP_ADC_PROBE - case TEMP_PROBE_PIN: pin_index = TEMP_PROBE; break; - #endif - #if HAS_HEATED_BED - case TEMP_BED_PIN: pin_index = TEMP_BED; break; - #endif - #if HAS_TEMP_CHAMBER - case TEMP_CHAMBER_PIN: pin_index = TEMP_CHAMBER; break; - #endif - #if HAS_TEMP_COOLER - case TEMP_COOLER_PIN: pin_index = TEMP_COOLER; break; - #endif - #if HAS_TEMP_ADC_1 - case TEMP_1_PIN: pin_index = TEMP_1; break; - #endif - #if HAS_TEMP_ADC_2 - case TEMP_2_PIN: pin_index = TEMP_2; break; - #endif - #if HAS_TEMP_ADC_3 - case TEMP_3_PIN: pin_index = TEMP_3; break; - #endif - #if HAS_TEMP_ADC_4 - case TEMP_4_PIN: pin_index = TEMP_4; break; - #endif - #if HAS_TEMP_ADC_5 - case TEMP_5_PIN: pin_index = TEMP_5; break; - #endif - #if HAS_TEMP_ADC_6 - case TEMP_6_PIN: pin_index = TEMP_6; break; - #endif - #if HAS_TEMP_ADC_7 - case TEMP_7_PIN: pin_index = TEMP_7; break; - #endif - #if HAS_JOY_ADC_X - case JOY_X_PIN: pin_index = JOY_X; break; - #endif - #if HAS_JOY_ADC_Y - case JOY_Y_PIN: pin_index = JOY_Y; break; - #endif - #if HAS_JOY_ADC_Z - case JOY_Z_PIN: pin_index = JOY_Z; break; - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - case FILWIDTH_PIN: pin_index = FILWIDTH; break; - #endif - #if HAS_ADC_BUTTONS - case ADC_KEYPAD_PIN: pin_index = ADC_KEY; break; - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - case POWER_MONITOR_CURRENT_PIN: pin_index = POWERMON_CURRENT; break; - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - case POWER_MONITOR_VOLTAGE_PIN: pin_index = POWERMON_VOLTS; break; - #endif + _TCASE(HAS_TEMP_ADC_0, TEMP_0_PIN, TEMP_0) + _TCASE(HAS_TEMP_ADC_1, TEMP_1_PIN, TEMP_1) + _TCASE(HAS_TEMP_ADC_2, TEMP_2_PIN, TEMP_2) + _TCASE(HAS_TEMP_ADC_3, TEMP_3_PIN, TEMP_3) + _TCASE(HAS_TEMP_ADC_4, TEMP_4_PIN, TEMP_4) + _TCASE(HAS_TEMP_ADC_5, TEMP_5_PIN, TEMP_5) + _TCASE(HAS_TEMP_ADC_6, TEMP_6_PIN, TEMP_6) + _TCASE(HAS_TEMP_ADC_7, TEMP_7_PIN, TEMP_7) + _TCASE(HAS_HEATED_BED, TEMP_BED_PIN, TEMP_BED) + _TCASE(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN, TEMP_CHAMBER) + _TCASE(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN, TEMP_PROBE) + _TCASE(HAS_TEMP_COOLER, TEMP_COOLER_PIN, TEMP_COOLER) + _TCASE(HAS_TEMP_BOARD, TEMP_BOARD_PIN, TEMP_BOARD) + _TCASE(HAS_JOY_ADC_X, JOY_X_PIN, JOY_X) + _TCASE(HAS_JOY_ADC_Y, JOY_Y_PIN, JOY_Y) + _TCASE(HAS_JOY_ADC_Z, JOY_Z_PIN, JOY_Z) + _TCASE(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN, FILWIDTH) + _TCASE(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN, ADC_KEY) + _TCASE(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN, POWERMON_CURRENT) + _TCASE(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN, POWERMON_VOLTS) } - HAL_adc_result = HAL_adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits -} - -uint16_t HAL_adc_get_result() { return HAL_adc_result; } - -uint16_t analogRead(pin_t pin) { - const bool is_analog = _GET_MODE(pin) == GPIO_INPUT_ANALOG; - return is_analog ? analogRead(uint8_t(pin)) : 0; + adc_result = (adc_results[(int)pin_index] & 0xFFF) >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits } -// Wrapper to maple unprotected analogWrite -void analogWrite(pin_t pin, int pwm_val8) { - if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8); -} - -void HAL_reboot() { nvic_sys_reset(); } - -void flashFirmware(const int16_t) { HAL_reboot(); } - #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 3bdfb9703c64..ceb17b48848b 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -66,6 +66,10 @@ #endif #endif +// ------------------------ +// Serial ports +// ------------------------ + #ifdef SERIAL_USB typedef ForwardSerial1Class< USBSerial > DefaultSerial1; extern DefaultSerial1 MSerial0; @@ -141,11 +145,6 @@ #endif #endif -// Set interrupt grouping for this MCU -void HAL_init(); -#define HAL_IDLETASK 1 -void HAL_idletask(); - /** * TODO: review this to return 1 for pins that are not analog input */ @@ -158,15 +157,7 @@ void HAL_idletask(); #define NO_COMPILE_TIME_PWM #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); (void)__iCliRetVal() -#define CRITICAL_SECTION_END() if (!primask) (void)__iSeiRetVal() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() ((void)__iSeiRetVal()) -#define DISABLE_ISRS() ((void)__iCliRetVal()) - -// On AVR this is in math.h? -#define square(x) ((x)*(x)) - +// Reset Reason #define RST_POWER_ON 1 #define RST_EXTERNAL 2 #define RST_BROWN_OUT 4 @@ -182,46 +173,63 @@ void HAL_idletask(); typedef int8_t pin_t; // ------------------------ -// Public Variables +// Interrupts // ------------------------ -// Result of last ADC conversion -extern uint16_t HAL_adc_result; +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); (void)__iCliRetVal() +#define CRITICAL_SECTION_END() if (!irqon) (void)__iSeiRetVal() +#define cli() noInterrupts() +#define sei() interrupts() // ------------------------ -// Public functions +// ADC // ------------------------ -// Disable interrupts -#define cli() noInterrupts() +#ifdef ADC_RESOLUTION + #define HAL_ADC_RESOLUTION ADC_RESOLUTION +#else + #define HAL_ADC_RESOLUTION 12 +#endif -// Enable interrupts -#define sei() interrupts() +#define HAL_ADC_VREF 3.3 -// Memory related -#define __bss_end __bss_end__ +uint16_t analogRead(const pin_t pin); // need hal.adc_enable() first +void analogWrite(const pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!? -// Clear reset reason -void HAL_clear_reset_source(); +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -// Reset reason -uint8_t HAL_get_reset_source(); +#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY) +#define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE) -void HAL_reboot(); +#define PLATFORM_M997_SUPPORT +void flashFirmware(const int16_t); -void _delay_ms(const int delay); +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment +#ifndef PWM_FREQUENCY + #define PWM_FREQUENCY 1000 // Default PWM Frequency +#endif -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" +// ------------------------ +// Class Utilities +// ------------------------ -/* -extern "C" { - int freeMemory(); -} -*/ +// Memory related +#define __bss_end __bss_end__ + +void _delay_ms(const int ms); extern "C" char* _sbrk(int incr); +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + static inline int freeMemory() { volatile char top; return &top - _sbrk(0); @@ -229,54 +237,70 @@ static inline int freeMemory() { #pragma GCC diagnostic pop -// -// ADC -// +// ------------------------ +// MarlinHAL Class +// ------------------------ -#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT_ANALOG); +class MarlinHAL { +public: -void HAL_adc_init(); + // Earliest possible init, before setup() + MarlinHAL() {} -#ifdef ADC_RESOLUTION - #define HAL_ADC_RESOLUTION ADC_RESOLUTION -#else - #define HAL_ADC_RESOLUTION 12 -#endif + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -#define HAL_ADC_VREF 3.3 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true + // Interrupts + static bool isr_state() { return !__get_primask(); } + static void isr_on() { ((void)__iSeiRetVal()); } + static void isr_off() { ((void)__iCliRetVal()); } -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + static void delay_ms(const int ms) { delay(ms); } -uint16_t analogRead(pin_t pin); // need HAL_ANALOG_SELECT() first -void analogWrite(pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!? + // Tasks, called from idle() + static void idletask(); -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Reset + static uint8_t get_reset_source() { return RST_POWER_ON; } + static void clear_reset_source() {} -#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY) -#define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE) + // Free SRAM + static int freeMemory() { return ::freeMemory(); } -#define PLATFORM_M997_SUPPORT -void flashFirmware(const int16_t); + // + // ADC Methods + // -#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment + static uint16_t adc_result; -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Timer PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, int f_desired); + // Called by Temperature::init once at startup + static void adc_init(); -/** - * set_pwm_duty - * 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] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) { pinMode(pin, INPUT_ANALOG); } + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally change the maximum size of the provided value to enable finer PWM duty control [default = 255] + * The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false); + + /** + * Set the frequency of the timer for the given pin. + * All Timer PWM pins run at the same frequency. + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); + +}; diff --git a/Marlin/src/HAL/STM32F1/SPI.cpp b/Marlin/src/HAL/STM32F1/SPI.cpp index 8bfa3d236a7c..1ce2c7d3fd5d 100644 --- a/Marlin/src/HAL/STM32F1/SPI.cpp +++ b/Marlin/src/HAL/STM32F1/SPI.cpp @@ -91,6 +91,14 @@ static const spi_pins board_spi_pins[] __FLASH__ = { static void *_spi3_this; #endif +/** + * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. + */ +static inline void waitSpiTxEnd(spi_dev *spi_d) { + while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1 + while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0 +} + /** * Constructor */ diff --git a/Marlin/src/HAL/STM32F1/SPI.h b/Marlin/src/HAL/STM32F1/SPI.h index 2467432e0718..13f4d5ed6cfe 100644 --- a/Marlin/src/HAL/STM32F1/SPI.h +++ b/Marlin/src/HAL/STM32F1/SPI.h @@ -414,12 +414,4 @@ class SPIClass { */ }; -/** - * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. - */ -static inline void waitSpiTxEnd(spi_dev *spi_d) { - while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1 - while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0 -} - extern SPIClass SPI; diff --git a/Marlin/src/HAL/STM32F1/Servo.cpp b/Marlin/src/HAL/STM32F1/Servo.cpp index 36f7c6d51273..8dc1ef7b6a5b 100644 --- a/Marlin/src/HAL/STM32F1/Servo.cpp +++ b/Marlin/src/HAL/STM32F1/Servo.cpp @@ -60,7 +60,7 @@ uint8_t ServoCount = 0; #define US_TO_ANGLE(us) int16_t(map((us), SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW, minAngle, maxAngle)) void libServo::servoWrite(uint8_t inPin, uint16_t duty_cycle) { - #ifdef SERVO0_TIMER_NUM + #ifdef MF_TIMER_SERVO0 if (servoIndex == 0) { pwmSetDuty(duty_cycle); return; @@ -74,7 +74,7 @@ void libServo::servoWrite(uint8_t inPin, uint16_t duty_cycle) { libServo::libServo() { servoIndex = ServoCount < MAX_SERVOS ? ServoCount++ : INVALID_SERVO; - timer_set_interrupt_priority(SERVO0_TIMER_NUM, SERVO0_TIMER_IRQ_PRIO); + HAL_timer_set_interrupt_priority(MF_TIMER_SERVO0, SERVO0_TIMER_IRQ_PRIO); } bool libServo::attach(const int32_t inPin, const int32_t inMinAngle, const int32_t inMaxAngle) { @@ -85,7 +85,7 @@ bool libServo::attach(const int32_t inPin, const int32_t inMinAngle, const int32 maxAngle = inMaxAngle; angle = -1; - #ifdef SERVO0_TIMER_NUM + #ifdef MF_TIMER_SERVO0 if (servoIndex == 0 && setupSoftPWM(inPin)) { pin = inPin; // set attached() return true; @@ -119,7 +119,7 @@ bool libServo::detach() { int32_t libServo::read() const { if (attached()) { - #ifdef SERVO0_TIMER_NUM + #ifdef MF_TIMER_SERVO0 if (servoIndex == 0) return angle; #endif timer_dev *tdev = PIN_MAP[pin].timer_device; @@ -141,9 +141,9 @@ void libServo::move(const int32_t value) { } } -#ifdef SERVO0_TIMER_NUM +#ifdef MF_TIMER_SERVO0 extern "C" void Servo_IRQHandler() { - static timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM); + static timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0); uint16_t SR = timer_get_status(tdev); if (SR & TIMER_SR_CC1IF) { // channel 1 off #ifdef SERVO0_PWM_OD @@ -164,7 +164,7 @@ void libServo::move(const int32_t value) { } bool libServo::setupSoftPWM(const int32_t inPin) { - timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM); + timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0); if (!tdev) return false; #ifdef SERVO0_PWM_OD OUT_WRITE_OD(inPin, 1); @@ -189,7 +189,7 @@ void libServo::move(const int32_t value) { } void libServo::pwmSetDuty(const uint16_t duty_cycle) { - timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM); + timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0); timer_set_compare(tdev, 1, duty_cycle); timer_generate_update(tdev); if (duty_cycle) { @@ -208,7 +208,7 @@ void libServo::move(const int32_t value) { } void libServo::pauseSoftPWM() { // detach - timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM); + timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0); timer_pause(tdev); pwmSetDuty(0); } diff --git a/Marlin/src/HAL/STM32F1/Servo.h b/Marlin/src/HAL/STM32F1/Servo.h index b6143de81d62..745a1c93f07d 100644 --- a/Marlin/src/HAL/STM32F1/Servo.h +++ b/Marlin/src/HAL/STM32F1/Servo.h @@ -35,7 +35,8 @@ #define SERVO_DEFAULT_MIN_ANGLE 0 #define SERVO_DEFAULT_MAX_ANGLE 180 -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; class libServo { public: diff --git a/Marlin/src/HAL/STM32F1/fast_pwm.cpp b/Marlin/src/HAL/STM32F1/fast_pwm.cpp index 5171c11545f5..297804a3ac42 100644 --- a/Marlin/src/HAL/STM32F1/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32F1/fast_pwm.cpp @@ -21,49 +21,65 @@ */ #ifdef __STM32F1__ -#include "../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfig.h" #include -#include "HAL.h" -#include "timers.h" -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); +#define NR_TIMERS TERN(STM32_XL_DENSITY, 14, 8) // Maple timers, 14 for STM32_XL_DENSITY (F/G chips), 8 for HIGH density (C D E) + +static uint16_t timer_freq[NR_TIMERS]; + +inline uint8_t timer_and_index_for_pin(const pin_t pin, timer_dev **timer_ptr) { + *timer_ptr = PIN_MAP[pin].timer_device; + for (uint8_t i = 0; i < NR_TIMERS; i++) if (*timer_ptr == HAL_get_timer_dev(i)) + return i; + return 0; } -#if NEEDS_HARDWARE_PWM +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { + const uint16_t duty = invert ? v_size - v : v; + if (PWM_PIN(pin)) { + timer_dev *timer; UNUSED(timer); + if (timer_freq[timer_and_index_for_pin(pin, &timer)] == 0) + set_pwm_frequency(pin, PWM_FREQUENCY); + const uint8_t channel = PIN_MAP[pin].timer_channel; + timer_set_compare(timer, channel, duty); + timer_set_mode(timer, channel, TIMER_PWM); // PWM Output Mode + } + else { + pinMode(pin, OUTPUT); + digitalWrite(pin, duty < v_size / 2 ? LOW : HIGH); + } +} - void set_pwm_frequency(const pin_t pin, int f_desired) { - if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t 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; + timer_dev *timer; UNUSED(timer); + timer_freq[timer_and_index_for_pin(pin, &timer)] = f_desired; - // 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 + // Protect used timers + if (timer == HAL_get_timer_dev(MF_TIMER_TEMP)) return; + if (timer == HAL_get_timer_dev(MF_TIMER_STEP)) return; + #if MF_TIMER_PULSE != MF_TIMER_STEP + if (timer == HAL_get_timer_dev(MF_TIMER_PULSE)) return; + #endif - if (!(timer->regs.bas->SR & TIMER_CR1_CEN)) // Ensure the timer is enabled - timer_init(timer); + 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); + const uint8_t channel = PIN_MAP[pin].timer_channel; + timer_set_mode(timer, channel, TIMER_PWM); + // Preload (resolution) cannot be equal to duty of 255 otherwise it may not result in digital off or on. + uint16_t preload = 254; + 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/STM32F1/inc/SanityCheck.h b/Marlin/src/HAL/STM32F1/inc/SanityCheck.h index 2846155c351d..fe8f6e0ec24b 100644 --- a/Marlin/src/HAL/STM32F1/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32F1/inc/SanityCheck.h @@ -39,7 +39,7 @@ #error "SERIAL_STATS_DROPPED_RX is not supported on the STM32F1 platform." #endif -#if ENABLED(NEOPIXEL_LED) && DISABLED(MKS_MINI_12864_V3) +#if ENABLED(NEOPIXEL_LED) && DISABLED(FYSETC_MINI_12864_2_1) #error "NEOPIXEL_LED (Adafruit NeoPixel) is not supported for HAL/STM32F1. Comment out this line to proceed at your own risk!" #endif diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.cpp b/Marlin/src/HAL/STM32F1/onboard_sd.cpp index df98c2c057af..a3d8dcb2d57e 100644 --- a/Marlin/src/HAL/STM32F1/onboard_sd.cpp +++ b/Marlin/src/HAL/STM32F1/onboard_sd.cpp @@ -38,8 +38,13 @@ #define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2 #endif -#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low -#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high +#if PIN_EXISTS(ONBOARD_SD_CS) && ONBOARD_SD_CS_PIN != SD_SS_PIN + #define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low + #define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high +#else + #define CS_LOW() + #define CS_HIGH() +#endif #define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX) #define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256) @@ -278,7 +283,7 @@ DSTATUS disk_initialize ( if (drv) return STA_NOINIT; // Supports only drive 0 sd_power_on(); // Initialize SPI - if (Stat & STA_NODISK) return Stat; // Is a card existing in the soket? + if (Stat & STA_NODISK) return Stat; // Is a card existing in the socket? FCLK_SLOW(); for (n = 10; n; n--) xchg_spi(0xFF); // Send 80 dummy clocks diff --git a/Marlin/src/HAL/STM32F1/pinsDebug.h b/Marlin/src/HAL/STM32F1/pinsDebug.h index 27f4b6732bfb..7828479658a9 100644 --- a/Marlin/src/HAL/STM32F1/pinsDebug.h +++ b/Marlin/src/HAL/STM32F1/pinsDebug.h @@ -54,11 +54,11 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS]; #define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX) #endif -static inline int8_t get_pin_mode(pin_t pin) { +static int8_t get_pin_mode(pin_t pin) { return VALID_PIN(pin) ? _GET_MODE(pin) : -1; } -static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) { +static pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) { if (!VALID_PIN(pin)) return -1; int8_t adc_channel = int8_t(PIN_MAP[pin].adc_channel); #ifdef NUM_ANALOG_INPUTS @@ -67,7 +67,7 @@ static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) { return pin_t(adc_channel); } -static inline bool IS_ANALOG(pin_t pin) { +static bool IS_ANALOG(pin_t pin) { if (!VALID_PIN(pin)) return false; if (PIN_MAP[pin].adc_channel != ADCx) { #ifdef NUM_ANALOG_INPUTS @@ -78,11 +78,11 @@ static inline bool IS_ANALOG(pin_t pin) { return false; } -static inline bool GET_PINMODE(const pin_t pin) { +static bool GET_PINMODE(const pin_t pin) { return VALID_PIN(pin) && !IS_INPUT(pin); } -static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) { +static bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) { const pin_t pin = GET_ARRAY_PIN(array_pin); return (!IS_ANALOG(pin) #ifdef NUM_ANALOG_INPUTS @@ -93,7 +93,7 @@ static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) { #include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density -static inline void pwm_details(const pin_t pin) { +static void pwm_details(const pin_t pin) { if (PWM_PIN(pin)) { timer_dev * const tdev = PIN_MAP[pin].timer_device; const uint8_t channel = PIN_MAP[pin].timer_channel; @@ -113,7 +113,7 @@ static inline void pwm_details(const pin_t pin) { } } -static inline void print_port(pin_t pin) { +static void print_port(pin_t pin) { const char port = 'A' + char(pin >> 4); // pin div 16 const int16_t gbit = PIN_MAP[pin].gpio_bit; char buffer[8]; diff --git a/Marlin/src/HAL/STM32F1/tft/xpt2046.h b/Marlin/src/HAL/STM32F1/tft/xpt2046.h index aba0799e445f..7c456cf00e1b 100644 --- a/Marlin/src/HAL/STM32F1/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32F1/tft/xpt2046.h @@ -65,8 +65,8 @@ class XPT2046 { static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); - static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; - static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; + static void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; + static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; #if ENABLED(TOUCH_BUTTONS_HW_SPI) static uint16_t HardwareIO(uint16_t data); #endif diff --git a/Marlin/src/HAL/STM32F1/timers.cpp b/Marlin/src/HAL/STM32F1/timers.cpp index 8c2df1e216e7..112c730b9acc 100644 --- a/Marlin/src/HAL/STM32F1/timers.cpp +++ b/Marlin/src/HAL/STM32F1/timers.cpp @@ -47,10 +47,7 @@ * TODO: Calculate Timer prescale value, so we get the 32bit to adjust */ - - - -void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority) { +void HAL_timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority) { nvic_irq_num irq_num; switch (timer_num) { case 1: irq_num = NVIC_TIMER1_CC; break; @@ -73,7 +70,6 @@ void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority) nvic_irq_set_priority(irq_num, priority); } - void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { /** * Give the Stepper ISR a higher priority (lower number) @@ -81,7 +77,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { */ switch (timer_num) { - case STEP_TIMER_NUM: + case MF_TIMER_STEP: timer_pause(STEP_TIMER_DEV); timer_set_mode(STEP_TIMER_DEV, STEP_TIMER_CHAN, TIMER_OUTPUT_COMPARE); // counter timer_set_count(STEP_TIMER_DEV, 0); @@ -91,11 +87,11 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, _MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (STEPPER_TIMER_RATE) / frequency)); timer_no_ARR_preload_ARPE(STEP_TIMER_DEV); // Need to be sure no preload on ARR register timer_attach_interrupt(STEP_TIMER_DEV, STEP_TIMER_CHAN, stepTC_Handler); - timer_set_interrupt_priority(STEP_TIMER_NUM, STEP_TIMER_IRQ_PRIO); + HAL_timer_set_interrupt_priority(MF_TIMER_STEP, STEP_TIMER_IRQ_PRIO); timer_generate_update(STEP_TIMER_DEV); timer_resume(STEP_TIMER_DEV); break; - case TEMP_TIMER_NUM: + case MF_TIMER_TEMP: timer_pause(TEMP_TIMER_DEV); timer_set_mode(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, TIMER_OUTPUT_COMPARE); timer_set_count(TEMP_TIMER_DEV, 0); @@ -103,7 +99,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { timer_set_reload(TEMP_TIMER_DEV, 0xFFFF); timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, _MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (F_CPU) / (TEMP_TIMER_PRESCALE) / frequency)); timer_attach_interrupt(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, tempTC_Handler); - timer_set_interrupt_priority(TEMP_TIMER_NUM, TEMP_TIMER_IRQ_PRIO); + HAL_timer_set_interrupt_priority(MF_TIMER_TEMP, TEMP_TIMER_IRQ_PRIO); timer_generate_update(TEMP_TIMER_DEV); timer_resume(TEMP_TIMER_DEV); break; @@ -112,31 +108,31 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { void HAL_timer_enable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case STEP_TIMER_NUM: ENABLE_STEPPER_DRIVER_INTERRUPT(); break; - case TEMP_TIMER_NUM: ENABLE_TEMPERATURE_INTERRUPT(); break; + case MF_TIMER_STEP: ENABLE_STEPPER_DRIVER_INTERRUPT(); break; + case MF_TIMER_TEMP: ENABLE_TEMPERATURE_INTERRUPT(); break; } } void HAL_timer_disable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case STEP_TIMER_NUM: DISABLE_STEPPER_DRIVER_INTERRUPT(); break; - case TEMP_TIMER_NUM: DISABLE_TEMPERATURE_INTERRUPT(); break; + case MF_TIMER_STEP: DISABLE_STEPPER_DRIVER_INTERRUPT(); break; + case MF_TIMER_TEMP: DISABLE_TEMPERATURE_INTERRUPT(); break; } } -static inline bool timer_irq_enabled(const timer_dev * const dev, const uint8_t interrupt) { +static inline bool HAL_timer_irq_enabled(const timer_dev * const dev, const uint8_t interrupt) { return bool(*bb_perip(&(dev->regs).gen->DIER, interrupt)); } bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { switch (timer_num) { - case STEP_TIMER_NUM: return timer_irq_enabled(STEP_TIMER_DEV, STEP_TIMER_CHAN); - case TEMP_TIMER_NUM: return timer_irq_enabled(TEMP_TIMER_DEV, TEMP_TIMER_CHAN); + case MF_TIMER_STEP: return HAL_timer_irq_enabled(STEP_TIMER_DEV, STEP_TIMER_CHAN); + case MF_TIMER_TEMP: return HAL_timer_irq_enabled(TEMP_TIMER_DEV, TEMP_TIMER_CHAN); } return false; } -timer_dev* get_timer_dev(int number) { +timer_dev* HAL_get_timer_dev(int number) { switch (number) { #if STM32_HAVE_TIMER(1) case 1: return &timer1; diff --git a/Marlin/src/HAL/STM32F1/timers.h b/Marlin/src/HAL/STM32F1/timers.h index c89d55a134b4..0cd807fc8479 100644 --- a/Marlin/src/HAL/STM32F1/timers.h +++ b/Marlin/src/HAL/STM32F1/timers.h @@ -65,30 +65,30 @@ typedef uint16_t hal_timer_t; * - Otherwise it uses Timer 8 on boards with STM32_HIGH_DENSITY * or Timer 4 on other boards. */ -#ifndef STEP_TIMER_NUM +#ifndef MF_TIMER_STEP #if defined(MCU_STM32F103CB) || defined(MCU_STM32F103C8) - #define STEP_TIMER_NUM 4 // For C8/CB boards, use timer 4 + #define MF_TIMER_STEP 4 // For C8/CB boards, use timer 4 #else - #define STEP_TIMER_NUM 5 // for other boards, five is fine. + #define MF_TIMER_STEP 5 // for other boards, five is fine. #endif #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 2 // Timer Index for Temperature - //#define TEMP_TIMER_NUM 4 // 2->4, Timer 2 for Stepper Current PWM +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 2 // Timer Index for Temperature + //#define MF_TIMER_TEMP 4 // 2->4, Timer 2 for Stepper Current PWM #endif #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE, MKS_ROBIN_E3D, MKS_ROBIN_E3) // SKR Mini E3 boards use PA8 as FAN_PIN, so TIMER 1 is used for Fan PWM. #ifdef STM32_HIGH_DENSITY - #define SERVO0_TIMER_NUM 8 // tone.cpp uses Timer 4 + #define MF_TIMER_SERVO0 8 // tone.cpp uses Timer 4 #else - #define SERVO0_TIMER_NUM 3 // tone.cpp uses Timer 8 + #define MF_TIMER_SERVO0 3 // tone.cpp uses Timer 8 #endif #else - #define SERVO0_TIMER_NUM 1 // SERVO0 or BLTOUCH + #define MF_TIMER_SERVO0 1 // SERVO0 or BLTOUCH #endif #define STEP_TIMER_IRQ_PRIO 2 @@ -98,22 +98,22 @@ typedef uint16_t hal_timer_t; #define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz #define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency -#define STEPPER_TIMER_PRESCALE 18 // prescaler for setting stepper timer, 4Mhz -#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_PRESCALE 18 // prescaler for setting stepper timer, 4Mhz +#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -timer_dev* get_timer_dev(int number); -#define TIMER_DEV(num) get_timer_dev(num) -#define STEP_TIMER_DEV TIMER_DEV(STEP_TIMER_NUM) -#define TEMP_TIMER_DEV TIMER_DEV(TEMP_TIMER_NUM) +timer_dev* HAL_get_timer_dev(int number); +#define TIMER_DEV(num) HAL_get_timer_dev(num) +#define STEP_TIMER_DEV TIMER_DEV(MF_TIMER_STEP) +#define TEMP_TIMER_DEV TIMER_DEV(MF_TIMER_TEMP) #define ENABLE_STEPPER_DRIVER_INTERRUPT() timer_enable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN) #define DISABLE_STEPPER_DRIVER_INTERRUPT() timer_disable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) #define ENABLE_TEMPERATURE_INTERRUPT() timer_enable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN) #define DISABLE_TEMPERATURE_INTERRUPT() timer_disable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN) @@ -138,8 +138,8 @@ extern "C" { // Public Variables // ------------------------ -//static HardwareTimer StepperTimer(STEP_TIMER_NUM); -//static HardwareTimer TempTimer(TEMP_TIMER_NUM); +//static HardwareTimer StepperTimer(MF_TIMER_STEP); +//static HardwareTimer TempTimer(MF_TIMER_TEMP); // ------------------------ // Public functions @@ -163,13 +163,13 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num); FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { switch (timer_num) { - case STEP_TIMER_NUM: + case MF_TIMER_STEP: // NOTE: WE have set ARPE = 0, which means the Auto reload register is not preloaded // and there is no need to use any compare, as in the timer mode used, setting ARR to the compare value // will result in exactly the same effect, ie triggering an interrupt, and on top, set counter to 0 timer_set_reload(STEP_TIMER_DEV, compare); // We reload direct ARR as needed during counting up break; - case TEMP_TIMER_NUM: + case MF_TIMER_TEMP: timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, compare); break; } @@ -177,18 +177,18 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { switch (timer_num) { - case STEP_TIMER_NUM: - // No counter to clear - timer_generate_update(STEP_TIMER_DEV); - return; - case TEMP_TIMER_NUM: - timer_set_count(TEMP_TIMER_DEV, 0); - timer_generate_update(TEMP_TIMER_DEV); - return; + case MF_TIMER_STEP: + // No counter to clear + timer_generate_update(STEP_TIMER_DEV); + return; + case MF_TIMER_TEMP: + timer_set_count(TEMP_TIMER_DEV, 0); + timer_generate_update(TEMP_TIMER_DEV); + return; } } -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_epilogue(T) NOOP // No command is available in framework to turn off ARPE bit, which is turned on by default in libmaple. // Needed here to reset ARPE=0 for stepper timer @@ -196,6 +196,6 @@ FORCE_INLINE static void timer_no_ARR_preload_ARPE(timer_dev *dev) { bb_peri_set_bit(&(dev->regs).gen->CR1, TIMER_CR1_ARPE_BIT, 0); } -void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority); +void HAL_timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority); #define TIMER_OC_NO_PRELOAD 0 // Need to disable preload also on compare registers. diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index f08cf799e9e8..b923ab77b1f1 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -31,6 +31,10 @@ #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -40,33 +44,32 @@ #endif USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result; - -static const uint8_t pin2sc1a[] = { - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13 - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9) - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33 - 0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13) - 26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0. -}; - -/* - // disable interrupts - void cli() { noInterrupts(); } +// ------------------------ +// Class Utilities +// ------------------------ - // enable interrupts - void sei() { interrupts(); } -*/ +extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; -void HAL_adc_init() { - analog_init(); - while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - NVIC_ENABLE_IRQ(IRQ_FTM1); + int freeMemory() { + int free_memory; + if ((int)__brkval == 0) + free_memory = ((int)&free_memory) - ((int)&__bss_end); + else + free_memory = ((int)&free_memory) - ((int)__brkval); + return free_memory; + } } -void HAL_clear_reset_source() { } +// ------------------------ +// MarlinHAL Class +// ------------------------ -uint8_t HAL_get_reset_source() { +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } + +uint8_t MarlinHAL::get_reset_source() { switch (RCM_SRS0) { case 128: return RST_POWER_ON; break; case 64: return RST_EXTERNAL; break; @@ -78,25 +81,25 @@ uint8_t HAL_get_reset_source() { return 0; } -void HAL_reboot() { _reboot_Teensyduino_(); } +// ADC -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; - - int freeMemory() { - int free_memory; - if ((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - return free_memory; - } +void MarlinHAL::adc_init() { + analog_init(); + while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish + NVIC_ENABLE_IRQ(IRQ_FTM1); } -void HAL_adc_start_conversion(const uint8_t adc_pin) { ADC0_SC1A = pin2sc1a[adc_pin]; } +void MarlinHAL::adc_start(const pin_t pin) { + static const uint8_t pin2sc1a[] = { + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13 + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9) + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33 + 0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13) + 26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0. + }; + ADC0_SC1A = pin2sc1a[pin]; +} -uint16_t HAL_adc_get_result() { return ADC0_RA; } +uint16_t MarlinHAL::adc_value() { return ADC0_RA; } #endif // __MK20DX256__ diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 61d8b34604c5..50c0f411cf92 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -36,12 +36,9 @@ #include -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - -//#undef MOTHERBOARD -//#define MOTHERBOARD BOARD_TEENSY31_32 +// ------------------------ +// Defines +// ------------------------ #define IS_32BIT_TEENSY 1 #define IS_TEENSY_31_32 1 @@ -49,6 +46,14 @@ #define IS_TEENSY32 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" #define Serial0 Serial @@ -72,31 +77,44 @@ extern USBSerialType USBSerial; #error "The required SERIAL_PORT must be from 0 to 3, or -1 for Native USB." #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ + +class libServo; +typedef libServo hal_servo_t; typedef int8_t pin_t; -#ifndef analogInputToDigitalPin - #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) -#endif +// ------------------------ +// Interrupts +// ------------------------ -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +uint32_t __get_PRIMASK(void); // CMSIS +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -inline void HAL_init() {} +// ------------------------ +// ADC +// ------------------------ -// Clear the reset reason -void HAL_clear_reset_source(); +#ifndef analogInputToDigitalPin + #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) +#endif -// Get the reason for the reset -uint8_t HAL_get_reset_source(); +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 -void HAL_reboot(); +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -107,27 +125,63 @@ extern "C" int freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -// PWM + static void delay_ms(const int ms) { delay(ms); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Tasks, called from idle() + static void idletask() {} -// Pin Map + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t ch) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t ch); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/TEENSY31_32/timers.cpp b/Marlin/src/HAL/TEENSY31_32/timers.cpp index 7e01a38f8946..f217715a3fed 100644 --- a/Marlin/src/HAL/TEENSY31_32/timers.cpp +++ b/Marlin/src/HAL/TEENSY31_32/timers.cpp @@ -47,7 +47,7 @@ FORCE_INLINE static void __DSB() { void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { switch (timer_num) { - case 0: + case MF_TIMER_STEP: FTM0_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; FTM0_SC = 0x00; // Set this to zero before changing the modulus FTM0_CNT = 0x0000; // Reset the count to zero @@ -56,7 +56,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { FTM0_SC = (FTM_SC_CLKS(0b1) & FTM_SC_CLKS_MASK) | (FTM_SC_PS(FTM0_TIMER_PRESCALE_BITS) & FTM_SC_PS_MASK); // Bus clock 60MHz divided by prescaler 8 FTM0_C0SC = FTM_CSC_CHIE | FTM_CSC_MSA | FTM_CSC_ELSA; break; - case 1: + case MF_TIMER_TEMP: FTM1_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; // Disable write protection, Enable FTM1 FTM1_SC = 0x00; // Set this to zero before changing the modulus FTM1_CNT = 0x0000; // Reset the count to zero @@ -70,15 +70,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { void HAL_timer_enable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case 0: NVIC_ENABLE_IRQ(IRQ_FTM0); break; - case 1: NVIC_ENABLE_IRQ(IRQ_FTM1); break; + case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_FTM0); break; + case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_FTM1); break; } } void HAL_timer_disable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case 0: NVIC_DISABLE_IRQ(IRQ_FTM0); break; - case 1: NVIC_DISABLE_IRQ(IRQ_FTM1); break; + case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_FTM0); break; + case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_FTM1); break; } // We NEED memory barriers to ensure Interrupts are actually disabled! @@ -89,20 +89,20 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) { bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { switch (timer_num) { - case 0: return NVIC_IS_ENABLED(IRQ_FTM0); - case 1: return NVIC_IS_ENABLED(IRQ_FTM1); + case MF_TIMER_STEP: return NVIC_IS_ENABLED(IRQ_FTM0); + case MF_TIMER_TEMP: return NVIC_IS_ENABLED(IRQ_FTM1); } return false; } void HAL_timer_isr_prologue(const uint8_t timer_num) { switch (timer_num) { - case 0: + case MF_TIMER_STEP: FTM0_CNT = 0x0000; FTM0_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag FTM0_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag break; - case 1: + case MF_TIMER_TEMP: FTM1_CNT = 0x0000; FTM1_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag FTM1_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag diff --git a/Marlin/src/HAL/TEENSY31_32/timers.h b/Marlin/src/HAL/TEENSY31_32/timers.h index 61b86735967e..9fcbb6f232c9 100644 --- a/Marlin/src/HAL/TEENSY31_32/timers.h +++ b/Marlin/src/HAL/TEENSY31_32/timers.h @@ -46,14 +46,14 @@ typedef uint32_t hal_timer_t; #define HAL_TIMER_RATE (FTM0_TIMER_RATE) -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 1 // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 1 // Timer Index for Temperature #endif #define TEMP_TIMER_FREQUENCY 1000 @@ -66,12 +66,12 @@ typedef uint32_t hal_timer_t; #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR #define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr() //void TC3_Handler() @@ -84,23 +84,23 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { switch (timer_num) { - case 0: FTM0_C0V = compare; break; - case 1: FTM1_C0V = compare; break; + case MF_TIMER_STEP: FTM0_C0V = compare; break; + case MF_TIMER_TEMP: FTM1_C0V = compare; break; } } FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { switch (timer_num) { - case 0: return FTM0_C0V; - case 1: return FTM1_C0V; + case MF_TIMER_STEP: return FTM0_C0V; + case MF_TIMER_TEMP: return FTM1_C0V; } return 0; } FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { switch (timer_num) { - case 0: return FTM0_CNT; - case 1: return FTM1_CNT; + case MF_TIMER_STEP: return FTM0_CNT; + case MF_TIMER_TEMP: return FTM1_CNT; } return 0; } @@ -110,4 +110,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index 046c00b56ed5..54a5ad385536 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,6 +31,10 @@ #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -39,42 +43,34 @@ USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result, HAL_adc_select; - -static const uint8_t pin2sc1a[] = { - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13 - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9 - 255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only - 14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20 - 255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only - 10+128, 11+128, // 49-50 are A23-A24 - 255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only - 255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only - 3, 19+128, // 64-65 are A10-A11 - 23, 23+128,// 66-67 are A21-A22 (DAC pins) - 1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5) - 26, // 70 is Temperature Sensor - 18+128 // 71 is Vref -}; - -/* - // disable interrupts - void cli() { noInterrupts(); } - - // enable interrupts - void sei() { interrupts(); } -*/ - -void HAL_adc_init() { - analog_init(); - while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - while (ADC1_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - NVIC_ENABLE_IRQ(IRQ_FTM1); +// ------------------------ +// Class Utilities +// ------------------------ + +extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; + + int freeMemory() { + int free_memory; + if ((int)__brkval == 0) + free_memory = ((int)&free_memory) - ((int)&__bss_end); + else + free_memory = ((int)&free_memory) - ((int)__brkval); + return free_memory; + } } -void HAL_clear_reset_source() { } +// ------------------------ +// MarlinHAL Class +// ------------------------ -uint8_t HAL_get_reset_source() { +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } + +// Reset + +uint8_t MarlinHAL::get_reset_source() { switch (RCM_SRS0) { case 128: return RST_POWER_ON; break; case 64: return RST_EXTERNAL; break; @@ -86,41 +82,49 @@ uint8_t HAL_get_reset_source() { return 0; } -void HAL_reboot() { _reboot_Teensyduino_(); } +// ADC -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; +int8_t MarlinHAL::adc_select; - int freeMemory() { - int free_memory; - if ((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - return free_memory; - } +void MarlinHAL::adc_init() { + analog_init(); + while (ADC0_SC3 & ADC_SC3_CAL) { /* Wait for calibration to finish */ } + while (ADC1_SC3 & ADC_SC3_CAL) { /* Wait for calibration to finish */ } + NVIC_ENABLE_IRQ(IRQ_FTM1); } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +void MarlinHAL::adc_start(const pin_t adc_pin) { + static const uint8_t pin2sc1a[] = { + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13 + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9 + 255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only + 14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20 + 255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only + 10+128, 11+128, // 49-50 are A23-A24 + 255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only + 255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only + 3, 19+128, // 64-65 are A10-A11 + 23, 23+128,// 66-67 are A21-A22 (DAC pins) + 1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5) + 26, // 70 is Temperature Sensor + 18+128 // 71 is Vref + }; const uint16_t pin = pin2sc1a[adc_pin]; if (pin == 0xFF) { - // Digital only - HAL_adc_select = -1; + adc_select = -1; // Digital only } else if (pin & 0x80) { - HAL_adc_select = 1; + adc_select = 1; ADC1_SC1A = pin & 0x7F; } else { - HAL_adc_select = 0; + adc_select = 0; ADC0_SC1A = pin; } } -uint16_t HAL_adc_get_result() { - switch (HAL_adc_select) { +uint16_t MarlinHAL::adc_value() { + switch (adc_select) { case 0: return ADC0_RA; case 1: return ADC1_RA; } diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 892eb2d3c5b8..e4c57f8d1e10 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -37,10 +37,6 @@ #include #include -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - // ------------------------ // Defines // ------------------------ @@ -53,6 +49,17 @@ #define IS_TEENSY35 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +#undef sq +#define sq(x) ((x)*(x)) + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" #define Serial0 Serial @@ -76,34 +83,43 @@ extern USBSerialType USBSerial; #error "SERIAL_PORT must be from 0 to 3, or -1 for Native USB." #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ -typedef int8_t pin_t; +class libServo; +typedef libServo hal_servo_t; -#ifndef analogInputToDigitalPin - #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) -#endif +typedef int8_t pin_t; -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +// ------------------------ +// Interrupts +// ------------------------ -#undef sq -#define sq(x) ((x)*(x)) +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -inline void HAL_init() {} +// ------------------------ +// ADC +// ------------------------ -// Clear reset reason -void HAL_clear_reset_source(); +#ifndef analogInputToDigitalPin + #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) +#endif -// Reset reason -uint8_t HAL_get_reset_source(); +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 -void HAL_reboot(); +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -114,27 +130,65 @@ extern "C" int freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + // Interrupts + static bool isr_state() { return true; } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -// PWM + static void delay_ms(const int ms) { delay(ms); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Tasks, called from idle() + static void idletask() {} -// Pin Map + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static int8_t adc_select; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/TEENSY35_36/timers.cpp b/Marlin/src/HAL/TEENSY35_36/timers.cpp index 8067d091dd01..39095fbd77af 100644 --- a/Marlin/src/HAL/TEENSY35_36/timers.cpp +++ b/Marlin/src/HAL/TEENSY35_36/timers.cpp @@ -47,7 +47,7 @@ FORCE_INLINE static void __DSB() { void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { switch (timer_num) { - case 0: + case MF_TIMER_STEP: FTM0_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; FTM0_SC = 0x00; // Set this to zero before changing the modulus FTM0_CNT = 0x0000; // Reset the count to zero @@ -56,7 +56,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { FTM0_SC = (FTM_SC_CLKS(0b1) & FTM_SC_CLKS_MASK) | (FTM_SC_PS(FTM0_TIMER_PRESCALE_BITS) & FTM_SC_PS_MASK); // Bus clock 60MHz divided by prescaler 8 FTM0_C0SC = FTM_CSC_CHIE | FTM_CSC_MSA | FTM_CSC_ELSA; break; - case 1: + case MF_TIMER_TEMP: FTM1_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; // Disable write protection, Enable FTM1 FTM1_SC = 0x00; // Set this to zero before changing the modulus FTM1_CNT = 0x0000; // Reset the count to zero @@ -70,15 +70,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { void HAL_timer_enable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case 0: NVIC_ENABLE_IRQ(IRQ_FTM0); break; - case 1: NVIC_ENABLE_IRQ(IRQ_FTM1); break; + case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_FTM0); break; + case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_FTM1); break; } } void HAL_timer_disable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case 0: NVIC_DISABLE_IRQ(IRQ_FTM0); break; - case 1: NVIC_DISABLE_IRQ(IRQ_FTM1); break; + case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_FTM0); break; + case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_FTM1); break; } // We NEED memory barriers to ensure Interrupts are actually disabled! @@ -89,20 +89,20 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) { bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { switch (timer_num) { - case 0: return NVIC_IS_ENABLED(IRQ_FTM0); - case 1: return NVIC_IS_ENABLED(IRQ_FTM1); + case MF_TIMER_STEP: return NVIC_IS_ENABLED(IRQ_FTM0); + case MF_TIMER_TEMP: return NVIC_IS_ENABLED(IRQ_FTM1); } return false; } void HAL_timer_isr_prologue(const uint8_t timer_num) { switch (timer_num) { - case 0: + case MF_TIMER_STEP: FTM0_CNT = 0x0000; FTM0_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag FTM0_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag break; - case 1: + case MF_TIMER_TEMP: FTM1_CNT = 0x0000; FTM1_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag FTM1_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag diff --git a/Marlin/src/HAL/TEENSY35_36/timers.h b/Marlin/src/HAL/TEENSY35_36/timers.h index 99269ac6571f..8af79d73928e 100644 --- a/Marlin/src/HAL/TEENSY35_36/timers.h +++ b/Marlin/src/HAL/TEENSY35_36/timers.h @@ -45,14 +45,14 @@ typedef uint32_t hal_timer_t; #define HAL_TIMER_RATE (FTM0_TIMER_RATE) -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 1 // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 1 // Timer Index for Temperature #endif #define TEMP_TIMER_FREQUENCY 1000 @@ -65,12 +65,12 @@ typedef uint32_t hal_timer_t; #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR #define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr() //void TC3_Handler() @@ -83,23 +83,23 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { switch (timer_num) { - case 0: FTM0_C0V = compare; break; - case 1: FTM1_C0V = compare; break; + case MF_TIMER_STEP: FTM0_C0V = compare; break; + case MF_TIMER_TEMP: FTM1_C0V = compare; break; } } FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { switch (timer_num) { - case 0: return FTM0_C0V; - case 1: return FTM1_C0V; + case MF_TIMER_STEP: return FTM0_C0V; + case MF_TIMER_TEMP: return FTM1_C0V; } return 0; } FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { switch (timer_num) { - case 0: return FTM0_CNT; - case 1: return FTM1_CNT; + case MF_TIMER_STEP: return FTM0_CNT; + case MF_TIMER_TEMP: return FTM1_CNT; } return 0; } @@ -109,4 +109,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index 270bee0dc9d4..68bd38f72ff8 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -33,6 +33,10 @@ #include "timers.h" #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -40,75 +44,42 @@ #endif USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result, HAL_adc_select; - -static const uint8_t pin2sc1a[] = { - 0x07, // 0/A0 AD_B1_02 - 0x08, // 1/A1 AD_B1_03 - 0x0C, // 2/A2 AD_B1_07 - 0x0B, // 3/A3 AD_B1_06 - 0x06, // 4/A4 AD_B1_01 - 0x05, // 5/A5 AD_B1_00 - 0x0F, // 6/A6 AD_B1_10 - 0x00, // 7/A7 AD_B1_11 - 0x0D, // 8/A8 AD_B1_08 - 0x0E, // 9/A9 AD_B1_09 - 0x01, // 24/A10 AD_B0_12 - 0x02, // 25/A11 AD_B0_13 - 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 - 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 - 0x07, // 14/A0 AD_B1_02 - 0x08, // 15/A1 AD_B1_03 - 0x0C, // 16/A2 AD_B1_07 - 0x0B, // 17/A3 AD_B1_06 - 0x06, // 18/A4 AD_B1_01 - 0x05, // 19/A5 AD_B1_00 - 0x0F, // 20/A6 AD_B1_10 - 0x00, // 21/A7 AD_B1_11 - 0x0D, // 22/A8 AD_B1_08 - 0x0E, // 23/A9 AD_B1_09 - 0x01, // 24/A10 AD_B0_12 - 0x02, // 25/A11 AD_B0_13 - 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 - 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 - #ifdef ARDUINO_TEENSY41 - 0xFF, // 28 - 0xFF, // 29 - 0xFF, // 30 - 0xFF, // 31 - 0xFF, // 32 - 0xFF, // 33 - 0xFF, // 34 - 0xFF, // 35 - 0xFF, // 36 - 0xFF, // 37 - 0x81, // 38/A14 AD_B1_12 - only on ADC2, 1 - 0x82, // 39/A15 AD_B1_13 - only on ADC2, 2 - 0x09, // 40/A16 AD_B1_04 - 0x0A, // 41/A17 AD_B1_05 - #endif -}; - -/* -// disable interrupts -void cli() { noInterrupts(); } - -// enable interrupts -void sei() { interrupts(); } -*/ - -void HAL_adc_init() { - analog_init(); - while (ADC1_GC & ADC_GC_CAL) ; - while (ADC2_GC & ADC_GC_CAL) ; +// ------------------------ +// Class Utilities +// ------------------------ + +#define __bss_end _ebss + +extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; + + // Doesn't work on Teensy 4.x + uint32_t freeMemory() { + uint32_t free_memory; + free_memory = ((uint32_t)&free_memory) - (((uint32_t)__brkval) ?: ((uint32_t)&__bss_end)); + return free_memory; + } } -void HAL_clear_reset_source() { - uint32_t reset_source = SRC_SRSR; - SRC_SRSR = reset_source; +// ------------------------ +// FastIO +// ------------------------ + +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); } -uint8_t HAL_get_reset_source() { +// ------------------------ +// MarlinHAL Class +// ------------------------ + +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } + +uint8_t MarlinHAL::get_reset_source() { switch (SRC_SRSR & 0xFF) { case 1: return RST_POWER_ON; break; case 2: return RST_SOFTWARE; break; @@ -121,57 +92,92 @@ uint8_t HAL_get_reset_source() { return 0; } -void HAL_reboot() { _reboot_Teensyduino_(); } +void MarlinHAL::clear_reset_source() { + uint32_t reset_source = SRC_SRSR; + SRC_SRSR = reset_source; +} -#define __bss_end _ebss +// ADC -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; +int8_t MarlinHAL::adc_select; - // Doesn't work on Teensy 4.x - uint32_t freeMemory() { - uint32_t free_memory; - if ((uint32_t)__brkval == 0) - free_memory = ((uint32_t)&free_memory) - ((uint32_t)&__bss_end); - else - free_memory = ((uint32_t)&free_memory) - ((uint32_t)__brkval); - return free_memory; - } +void MarlinHAL::adc_init() { + analog_init(); + while (ADC1_GC & ADC_GC_CAL) { /* wait */ } + while (ADC2_GC & ADC_GC_CAL) { /* wait */ } } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +void MarlinHAL::adc_start(const pin_t adc_pin) { + static const uint8_t pin2sc1a[] = { + 0x07, // 0/A0 AD_B1_02 + 0x08, // 1/A1 AD_B1_03 + 0x0C, // 2/A2 AD_B1_07 + 0x0B, // 3/A3 AD_B1_06 + 0x06, // 4/A4 AD_B1_01 + 0x05, // 5/A5 AD_B1_00 + 0x0F, // 6/A6 AD_B1_10 + 0x00, // 7/A7 AD_B1_11 + 0x0D, // 8/A8 AD_B1_08 + 0x0E, // 9/A9 AD_B1_09 + 0x01, // 24/A10 AD_B0_12 + 0x02, // 25/A11 AD_B0_13 + 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 + 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 + 0x07, // 14/A0 AD_B1_02 + 0x08, // 15/A1 AD_B1_03 + 0x0C, // 16/A2 AD_B1_07 + 0x0B, // 17/A3 AD_B1_06 + 0x06, // 18/A4 AD_B1_01 + 0x05, // 19/A5 AD_B1_00 + 0x0F, // 20/A6 AD_B1_10 + 0x00, // 21/A7 AD_B1_11 + 0x0D, // 22/A8 AD_B1_08 + 0x0E, // 23/A9 AD_B1_09 + 0x01, // 24/A10 AD_B0_12 + 0x02, // 25/A11 AD_B0_13 + 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 + 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 + #ifdef ARDUINO_TEENSY41 + 0xFF, // 28 + 0xFF, // 29 + 0xFF, // 30 + 0xFF, // 31 + 0xFF, // 32 + 0xFF, // 33 + 0xFF, // 34 + 0xFF, // 35 + 0xFF, // 36 + 0xFF, // 37 + 0x81, // 38/A14 AD_B1_12 - only on ADC2, 1 + 0x82, // 39/A15 AD_B1_13 - only on ADC2, 2 + 0x09, // 40/A16 AD_B1_04 + 0x0A, // 41/A17 AD_B1_05 + #endif + }; const uint16_t pin = pin2sc1a[adc_pin]; if (pin == 0xFF) { - HAL_adc_select = -1; // Digital only + adc_select = -1; // Digital only } else if (pin & 0x80) { - HAL_adc_select = 1; + adc_select = 1; ADC2_HC0 = pin & 0x7F; } else { - HAL_adc_select = 0; + adc_select = 0; ADC1_HC0 = pin; } } -uint16_t HAL_adc_get_result() { - switch (HAL_adc_select) { +uint16_t MarlinHAL::adc_value() { + switch (adc_select) { case 0: - while (!(ADC1_HS & ADC_HS_COCO0)) ; // wait + while (!(ADC1_HS & ADC_HS_COCO0)) { /* wait */ } return ADC1_R0; case 1: - while (!(ADC2_HS & ADC_HS_COCO0)) ; // wait + while (!(ADC2_HS & ADC_HS_COCO0)) { /* wait */ } return ADC2_R0; } return 0; } -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); -} - #endif // __IMXRT1062__ diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 2b730768a802..a21e65285409 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -41,10 +41,6 @@ #include "../../feature/ethernet.h" #endif -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - // ------------------------ // Defines // ------------------------ @@ -55,7 +51,23 @@ #define IS_TEENSY41 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +#undef sq +#define sq(x) ((x)*(x)) + +// Don't place string constants in PROGMEM +#undef PSTR +#define PSTR(str) ({static const char *data = (str); &data[0];}) + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" + #define Serial0 Serial #define _DECLARE_SERIAL(X) \ typedef ForwardSerial1Class DefaultSerial##X; \ @@ -89,41 +101,47 @@ extern USBSerialType USBSerial; #endif #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ -typedef int8_t pin_t; +class libServo; +typedef libServo hal_servo_t; -#ifndef analogInputToDigitalPin - #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) -#endif +typedef int8_t pin_t; -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +// ------------------------ +// Interrupts +// ------------------------ -#undef sq -#define sq(x) ((x)*(x)) +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -// Don't place string constants in PROGMEM -#undef PSTR -#define PSTR(str) ({static const char *data = (str); &data[0];}) +// ------------------------ +// ADC +// ------------------------ -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -FORCE_INLINE void HAL_idletask() {} -FORCE_INLINE void HAL_init() {} +#ifndef analogInputToDigitalPin + #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) +#endif -// Clear reset reason -void HAL_clear_reset_source(); +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 +#define HAL_ADC_FILTERED // turn off ADC oversampling -// Reset reason -uint8_t HAL_get_reset_source(); +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -void HAL_reboot(); +// FastIO +bool is_output(pin_t pin); -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -134,30 +152,65 @@ extern "C" uint32_t freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_ADC_FILTERED // turn off ADC oversampling -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + // Interrupts + static bool isr_state() { return !__get_primask(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -// PWM + static void delay_ms(const int ms) { delay(ms); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Tasks, called from idle() + static void idletask() {} -// Pin Map + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source(); -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Free SRAM + static int freeMemory() { return ::freeMemory(); } -bool is_output(pin_t pin); + // + // ADC Methods + // + + static int8_t adc_select; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/TEENSY40_41/timers.cpp b/Marlin/src/HAL/TEENSY40_41/timers.cpp index 81c9b08c17a5..ed99f65d6e26 100644 --- a/Marlin/src/HAL/TEENSY40_41/timers.cpp +++ b/Marlin/src/HAL/TEENSY40_41/timers.cpp @@ -30,7 +30,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { switch (timer_num) { - case 0: + case MF_TIMER_STEP: CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode CCM_CCGR1 |= CCM_CCGR1_GPT1_BUS(CCM_CCGR_ON); @@ -48,7 +48,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { attachInterruptVector(IRQ_GPT1, &stepTC_Handler); NVIC_SET_PRIORITY(IRQ_GPT1, 16); break; - case 1: + case MF_TIMER_TEMP: CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode CCM_CCGR0 |= CCM_CCGR0_GPT2_BUS(CCM_CCGR_ON); @@ -71,19 +71,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { void HAL_timer_enable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case 0: - NVIC_ENABLE_IRQ(IRQ_GPT1); - break; - case 1: - NVIC_ENABLE_IRQ(IRQ_GPT2); - break; + case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_GPT1); break; + case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_GPT2); break; } } void HAL_timer_disable_interrupt(const uint8_t timer_num) { switch (timer_num) { - case 0: NVIC_DISABLE_IRQ(IRQ_GPT1); break; - case 1: NVIC_DISABLE_IRQ(IRQ_GPT2); break; + case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_GPT1); break; + case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_GPT2); break; } // We NEED memory barriers to ensure Interrupts are actually disabled! @@ -93,20 +89,16 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) { bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { switch (timer_num) { - case 0: return (NVIC_IS_ENABLED(IRQ_GPT1)); - case 1: return (NVIC_IS_ENABLED(IRQ_GPT2)); + case MF_TIMER_STEP: return (NVIC_IS_ENABLED(IRQ_GPT1)); + case MF_TIMER_TEMP: return (NVIC_IS_ENABLED(IRQ_GPT2)); } return false; } void HAL_timer_isr_prologue(const uint8_t timer_num) { switch (timer_num) { - case 0: - GPT1_SR = GPT_IR_OF1IE; // clear OF3 bit - break; - case 1: - GPT2_SR = GPT_IR_OF1IE; // clear OF3 bit - break; + case MF_TIMER_STEP: GPT1_SR = GPT_IR_OF1IE; break; // clear OF3 bit + case MF_TIMER_TEMP: GPT2_SR = GPT_IR_OF1IE; break; // clear OF3 bit } asm volatile("dsb"); } diff --git a/Marlin/src/HAL/TEENSY40_41/timers.h b/Marlin/src/HAL/TEENSY40_41/timers.h index 556333d7f408..77fe0953d3bd 100644 --- a/Marlin/src/HAL/TEENSY40_41/timers.h +++ b/Marlin/src/HAL/TEENSY40_41/timers.h @@ -43,14 +43,14 @@ typedef uint32_t hal_timer_t; #define GPT1_TIMER_RATE (GPT_TIMER_RATE / GPT1_TIMER_PRESCALE) // 75MHz #define GPT2_TIMER_RATE (GPT_TIMER_RATE / GPT2_TIMER_PRESCALE) // 15MHz -#ifndef STEP_TIMER_NUM - #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif -#ifndef PULSE_TIMER_NUM - #define PULSE_TIMER_NUM STEP_TIMER_NUM +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP #endif -#ifndef TEMP_TIMER_NUM - #define TEMP_TIMER_NUM 1 // Timer Index for Temperature +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP 1 // Timer Index for Temperature #endif #define TEMP_TIMER_RATE 1000000 @@ -64,12 +64,12 @@ typedef uint32_t hal_timer_t; #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) -#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR #define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler() // GPT1_Handler() @@ -87,27 +87,23 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { switch (timer_num) { - case 0: - GPT1_OCR1 = compare - 1; - break; - case 1: - GPT2_OCR1 = compare - 1; - break; + case MF_TIMER_STEP: GPT1_OCR1 = compare - 1; break; + case MF_TIMER_TEMP: GPT2_OCR1 = compare - 1; break; } } FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { switch (timer_num) { - case 0: return GPT1_OCR1; - case 1: return GPT2_OCR1; + case MF_TIMER_STEP: return GPT1_OCR1; + case MF_TIMER_TEMP: return GPT2_OCR1; } return 0; } FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { switch (timer_num) { - case 0: return GPT1_CNT; - case 1: return GPT2_CNT; + case MF_TIMER_STEP: return GPT1_CNT; + case MF_TIMER_TEMP: return GPT2_CNT; } return 0; } @@ -118,4 +114,4 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); //void HAL_timer_isr_epilogue(const uint8_t timer_num) {} -#define HAL_timer_isr_epilogue(TIMER_NUM) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/shared/Delay.h b/Marlin/src/HAL/shared/Delay.h index df07881f01d9..a6795a78eaf4 100644 --- a/Marlin/src/HAL/shared/Delay.h +++ b/Marlin/src/HAL/shared/Delay.h @@ -166,6 +166,8 @@ void calibrate_delay_loop(); // Delay in microseconds #define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL)) + #define DELAY_CYCLES_VAR DELAY_CYCLES + #elif defined(ESP32) || defined(__PLAT_LINUX__) || defined(__PLAT_NATIVE_SIM__) // DELAY_CYCLES specified inside platform diff --git a/Marlin/src/HAL/shared/HAL.cpp b/Marlin/src/HAL/shared/HAL.cpp new file mode 100644 index 000000000000..4d92aedd9a1f --- /dev/null +++ b/Marlin/src/HAL/shared/HAL.cpp @@ -0,0 +1,36 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * HAL/shared/HAL.cpp + */ + +#include "../../inc/MarlinConfig.h" + +MarlinHAL hal; + +#if ENABLED(SOFT_RESET_VIA_SERIAL) + + // Global for use by e_parser.h + void HAL_reboot() { hal.reboot(); } + +#endif diff --git a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp index bd85dbe7bd7e..5d4ce89b2748 100644 --- a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp +++ b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp @@ -92,9 +92,9 @@ uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) { // First device in chain has data sent last extDigitalWrite(ss_pin, LOW); - DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips) + hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) const uint8_t data_out = L6470_SpiTransfer_Mode_3(data); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts extDigitalWrite(ss_pin, HIGH); return data_out; @@ -107,9 +107,9 @@ uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain extDigitalWrite(ss_pin, LOW); for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted - DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips) + hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP)); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts if (i == chain_position) data_out = temp; } diff --git a/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp b/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp index 2bde1e208d95..a4151b38c20e 100644 --- a/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp +++ b/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp @@ -41,7 +41,7 @@ #define START_FLASH_ADDR 0x00000000 #define END_FLASH_ADDR 0x00080000 -#elif defined(__STM32F1__) || defined(STM32F1xx) || defined(STM32F0xx) +#elif defined(__STM32F1__) || defined(STM32F1xx) || defined(STM32F0xx) || defined(STM32G0xx) // For STM32F103ZET6/STM32F103VET6/STM32F0xx // SRAM (0x20000000 - 0x20010000) (64kb) diff --git a/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp b/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp index 0f0f7c480727..a106ed2b05e5 100644 --- a/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp +++ b/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp @@ -101,7 +101,7 @@ struct __attribute__((packed)) ContextSavedFrame { uint32_t ELR; }; -#if DISABLED(STM32F0xx) +#if NONE(STM32F0xx, STM32G0xx) extern "C" __attribute__((naked)) void CommonHandler_ASM() { __asm__ __volatile__ ( diff --git a/Marlin/src/HAL/shared/eeprom_api.h b/Marlin/src/HAL/shared/eeprom_api.h index 1f38639930dc..cd744f82dc79 100644 --- a/Marlin/src/HAL/shared/eeprom_api.h +++ b/Marlin/src/HAL/shared/eeprom_api.h @@ -49,7 +49,7 @@ class PersistentStore { // Write one or more bytes of data // Return 'true' on write error - static inline bool write_data(const int pos, const uint8_t *value, const size_t size=sizeof(uint8_t)) { + static bool write_data(const int pos, const uint8_t *value, const size_t size=sizeof(uint8_t)) { int data_pos = pos; uint16_t crc = 0; return write_data(data_pos, value, size, &crc); @@ -57,11 +57,11 @@ class PersistentStore { // Write a single byte of data // Return 'true' on write error - static inline bool write_data(const int pos, const uint8_t value) { return write_data(pos, &value); } + static bool write_data(const int pos, const uint8_t value) { return write_data(pos, &value); } // Read one or more bytes of data // Return 'true' on read error - static inline bool read_data(const int pos, uint8_t *value, const size_t size=1) { + static bool read_data(const int pos, uint8_t *value, const size_t size=1) { int data_pos = pos; uint16_t crc = 0; return read_data(data_pos, value, size, &crc); diff --git a/Marlin/src/HAL/shared/math_32bit.h b/Marlin/src/HAL/shared/math_32bit.h index 87e9e6406ee4..1fb233e3e896 100644 --- a/Marlin/src/HAL/shared/math_32bit.h +++ b/Marlin/src/HAL/shared/math_32bit.h @@ -26,6 +26,6 @@ /** * Math helper functions for 32 bit CPUs */ -static FORCE_INLINE uint32_t MultiU32X24toH32(uint32_t longIn1, uint32_t longIn2) { +FORCE_INLINE static uint32_t MultiU32X24toH32(uint32_t longIn1, uint32_t longIn2) { return ((uint64_t)longIn1 * longIn2 + 0x00800000) >> 24; } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index f2031cdfb9f6..4117d3f382a1 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -74,8 +74,8 @@ #include "lcd/e3v2/common/encoder.h" #if ENABLED(DWIN_CREALITY_LCD) #include "lcd/e3v2/creality/dwin.h" - #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "lcd/e3v2/enhanced/dwin.h" + #elif ENABLED(DWIN_LCD_PROUI) + #include "lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "lcd/e3v2/jyersui/dwin.h" #endif @@ -145,7 +145,7 @@ #include "feature/encoder_i2c.h" #endif -#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF) +#if (HAS_TRINAMIC_CONFIG || HAS_TMC_SPI) && DISABLED(PSU_DEFAULT_OFF) #include "feature/tmc_util.h" #endif @@ -212,6 +212,10 @@ #include "module/tool_change.h" +#if HAS_FANCHECK + #include "feature/fancheck.h" +#endif + #if ENABLED(USE_CONTROLLER_FAN) #include "feature/controllerfan.h" #endif @@ -244,6 +248,10 @@ #include "feature/power.h" #endif +#if ENABLED(EASYTHREED_UI) + #include "feature/easythreed_ui.h" +#endif + PGMSTR(M112_KILL_STR, "M112 Shutdown"); MarlinState marlin_state = MF_INITIALIZING; @@ -498,7 +506,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \ CODE; \ queue.inject(F(BUTTON##N##_GCODE)); \ - TERN_(HAS_LCD_MENU, ui.quick_feedback()); \ + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \ } \ } \ }while(0) @@ -633,6 +641,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { #endif #endif + TERN_(EASYTHREED_UI, easythreed_ui.run()); + TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused())); @@ -774,10 +784,13 @@ void idle(bool no_stepper_sleep/*=false*/) { (void)check_tool_sensor_stats(active_extruder, true); // Handle filament runout sensors - TERN_(HAS_FILAMENT_SENSOR, runout.run()); + #if HAS_FILAMENT_SENSOR + if (TERN1(HAS_PRUSA_MMU2, !mmu2.enabled())) + runout.run(); + #endif // Run HAL idle tasks - TERN_(HAL_IDLETASK, HAL_idletask()); + hal.idletask(); // Check network connection TERN_(HAS_ETHERNET, ethernet.check()); @@ -809,7 +822,7 @@ void idle(bool no_stepper_sleep/*=false*/) { TERN_(USE_BEEPER, buzzer.tick()); // Handle UI input / draw events - TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update()); + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); // Run i2c Position Encoders #if ENABLED(I2C_POSITION_ENCODERS) @@ -829,6 +842,7 @@ void idle(bool no_stepper_sleep/*=false*/) { #if HAS_AUTO_REPORTING if (!gcode.autoreport_paused) { TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick()); + TERN_(AUTO_REPORT_FANS, fan_check.auto_reporter.tick()); TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick()); TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick()); TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics()); @@ -864,7 +878,7 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp // Echo the LCD message to serial for extra context if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); } - #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR)); #else UNUSED(lcd_error); UNUSED(lcd_component); @@ -915,7 +929,7 @@ void minkill(const bool steppers_off/*=false*/) { watchdog_refresh(); // Reboot the board - HAL_reboot(); + hal.reboot(); #else @@ -1027,7 +1041,7 @@ inline void tmc_standby_setup() { * • L64XX Stepper Drivers (SPI) * • Stepper Driver Reset: DISABLE * • TMC Stepper Drivers (SPI) - * • Run BOARD_INIT if defined + * • Run hal.init_board() for additional pins setup * • ESP WiFi * - Get the Reset Reason and report it * - Print startup messages and diagnostics @@ -1105,8 +1119,8 @@ 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(); + const byte mcu = hal.get_reset_source(); + hal.clear_reset_source(); #if ENABLED(MARLIN_DEV_MODE) auto log_current_ms = [&](PGM_P const msg) { @@ -1167,23 +1181,20 @@ void setup() { JTAGSWD_RESET(); #endif - #if EITHER(DISABLE_DEBUG, DISABLE_JTAG) + // Disable any hardware debug to free up pins for IO + #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE) delay(10); - // Disable any hardware debug to free up pins for IO - #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE) - SETUP_LOG("JTAGSWD_DISABLE"); - JTAGSWD_DISABLE(); - #elif defined(JTAG_DISABLE) - SETUP_LOG("JTAG_DISABLE"); - JTAG_DISABLE(); - #else - #error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board." - #endif + SETUP_LOG("JTAGSWD_DISABLE"); + JTAGSWD_DISABLE(); + #elif ENABLED(DISABLE_JTAG) && defined(JTAG_DISABLE) + delay(10); + SETUP_LOG("JTAG_DISABLE"); + JTAG_DISABLE(); #endif TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime - SETUP_RUN(HAL_init()); + SETUP_RUN(hal.init()); // Init and disable SPI thermocouples; this is still needed #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0)) @@ -1229,19 +1240,16 @@ void setup() { SETUP_RUN(tmc_init_cs_pins()); #endif - #ifdef BOARD_INIT - SETUP_LOG("BOARD_INIT"); - BOARD_INIT(); - #endif + SETUP_RUN(hal.init_board()); SETUP_RUN(esp_wifi_init()); // Report Reset Reason - if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); - if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); + 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); + if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); + if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); // Identify myself as Marlin x.x.x SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION); @@ -1252,7 +1260,7 @@ void setup() { ); #endif SERIAL_ECHO_MSG(" Compiled: " __DATE__); - SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE)); + SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE)); // Some HAL need precise delay adjustment calibrate_delay_loop(); @@ -1275,19 +1283,12 @@ void setup() { SETUP_RUN(controllerFan.setup()); #endif + TERN_(HAS_FANCHECK, fan_check.init()); + // UI must be initialized before EEPROM // (because EEPROM code calls the UI). - #if HAS_DWIN_E3V2_BASIC - SETUP_RUN(DWIN_Startup()); - #else - SETUP_RUN(ui.init()); - #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) - SETUP_RUN(ui.show_bootscreen()); - const millis_t bootscreen_ms = millis(); - #endif - SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) - #endif + SETUP_RUN(ui.init()); #if PIN_EXISTS(SAFE_POWER) #if HAS_DRIVER_SAFE_POWER_PROTECT @@ -1298,10 +1299,6 @@ void setup() { #endif #endif - #if ENABLED(PROBE_TARE) - SETUP_RUN(probe.tare_init()); - #endif - #if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION) SETUP_RUN(card.mount()); // Mount media with settings before first_load #endif @@ -1309,6 +1306,15 @@ void setup() { SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults) // This also updates variables in the planner, elsewhere + #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) + SETUP_RUN(ui.show_bootscreen()); + const millis_t bootscreen_ms = millis(); + #endif + + #if ENABLED(PROBE_TARE) + SETUP_RUN(probe.tare_init()); + #endif + #if HAS_ETHERNET SETUP_RUN(ethernet.init()); #endif @@ -1327,6 +1333,10 @@ void setup() { SETUP_RUN(endstops.init()); // Init endstops and pullups + #if ENABLED(DELTA) && !HAS_SOFTWARE_ENDSTOPS + SETUP_RUN(refresh_delta_clip_start_height()); // Init safe delta height without soft endstops + #endif + SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts! #if HAS_SERVOS @@ -1353,6 +1363,9 @@ void setup() { #endif #if HAS_BED_PROBE + #if PIN_EXISTS(PROBE_ENABLE) + OUT_WRITE(PROBE_ENABLE_PIN, LOW); // Disable + #endif SETUP_RUN(endstops.enable_z_probe(false)); #endif @@ -1483,6 +1496,10 @@ void setup() { SETUP_RUN(bltouch.init(/*set_voltage=*/true)); #endif + #if ENABLED(MAGLEV4) + OUT_WRITE(MAGLEV_TRIGGER_PIN, LOW); + #endif + #if ENABLED(I2C_POSITION_ENCODERS) SETUP_RUN(I2CPEM.init()); #endif @@ -1519,7 +1536,7 @@ void setup() { #endif #if ENABLED(USE_WATCHDOG) - SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call + SETUP_RUN(watchdog_init()); // Reinit watchdog after hal.get_reset_source call #endif #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) @@ -1554,11 +1571,7 @@ void setup() { #endif #if HAS_DWIN_E3V2_BASIC - SETUP_LOG("E3V2 Init"); - Encoder_Configuration(); - HMI_Init(); - HMI_SetLanguageCache(); - HMI_StartFrame(true); + SETUP_RUN(DWIN_InitScreen()); #endif #if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC @@ -1592,10 +1605,14 @@ void setup() { SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided #endif - #if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI) + #if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI) SETUP_RUN(ui.check_touch_calibration()); #endif + #if ENABLED(EASYTHREED_UI) + SETUP_RUN(easythreed_ui.init()); + #endif + marlin_state = MF_RUNNING; SETUP_LOG("setup() completed."); @@ -1625,6 +1642,10 @@ void loop() { queue.advance(); + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + powerManager.checkAutoPowerOff(); + #endif + endstops.event_handler(); TERN_(HAS_TFT_LVGL_UI, printer_state_polling()); diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 789512c4ef71..d1cc971e51d1 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -115,6 +115,8 @@ #define BOARD_RAMPS_S_12_EFFB 1159 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) #define BOARD_LONGER3D_LK1_PRO 1160 // Longer LK1 PRO / Alfawise U20 Pro (PRO version) #define BOARD_LONGER3D_LKx_PRO 1161 // Longer LKx PRO / Alfawise Uxx Pro (PRO version) +#define BOARD_ZRIB_V53 1162 // Zonestar zrib V5.3 (Chinese RAMPS replica) +#define BOARD_PXMALION_CORE_I3 1163 // Pxmalion Core I3 // // RAMBo and derivatives @@ -162,6 +164,7 @@ #define BOARD_MALYAN_M180 1327 // Malyan M180 Mainboard Version 2 (no display function, direct gcode only) #define BOARD_GT2560_V4_A20 1328 // Geeetech GT2560 Rev B for A20(M/T/D) #define BOARD_PROTONEER_CNC_SHIELD_V3 1329 // Mega controller & Protoneer CNC Shield V3.00 +#define BOARD_WEEDO_62A 1330 // WEEDO 62A board (TINA2, Monoprice Cadet, etc.) // // ATmega1281, ATmega2561 @@ -300,63 +303,68 @@ #define BOARD_MALYAN_M200_V2 4000 // STM32F070CB controller #define BOARD_MALYAN_M300 4001 // STM32F070-based delta #define BOARD_STM32F103RE 4002 // STM32F103RE Libmaple-based STM32F1 controller -#define BOARD_MALYAN_M200 4003 // STM32C8T6 Libmaple-based STM32F1 controller +#define BOARD_MALYAN_M200 4003 // STM32C8 Libmaple-based STM32F1 controller #define BOARD_STM3R_MINI 4004 // STM32F103RE Libmaple-based STM32F1 controller -#define BOARD_GTM32_PRO_VB 4005 // STM32F103VET6 controller -#define BOARD_GTM32_MINI 4006 // STM32F103VET6 controller -#define BOARD_GTM32_MINI_A30 4007 // STM32F103VET6 controller -#define BOARD_GTM32_REV_B 4008 // STM32F103VET6 controller +#define BOARD_GTM32_PRO_VB 4005 // STM32F103VE controller +#define BOARD_GTM32_MINI 4006 // STM32F103VE controller +#define BOARD_GTM32_MINI_A30 4007 // STM32F103VE controller +#define BOARD_GTM32_REV_B 4008 // STM32F103VE controller #define BOARD_MORPHEUS 4009 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller -#define BOARD_CHITU3D 4010 // Chitu3D (STM32F103RET6) -#define BOARD_MKS_ROBIN 4011 // MKS Robin (STM32F103ZET6) -#define BOARD_MKS_ROBIN_MINI 4012 // MKS Robin Mini (STM32F103VET6) -#define BOARD_MKS_ROBIN_NANO 4013 // MKS Robin Nano (STM32F103VET6) -#define BOARD_MKS_ROBIN_NANO_V2 4014 // MKS Robin Nano V2 (STM32F103VET6) -#define BOARD_MKS_ROBIN_LITE 4015 // MKS Robin Lite/Lite2 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_LITE3 4016 // MKS Robin Lite3 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_PRO 4017 // MKS Robin Pro (STM32F103ZET6) -#define BOARD_MKS_ROBIN_E3 4018 // MKS Robin E3 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3_V1_1 4019 // MKS Robin E3 V1.1 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3D 4020 // MKS Robin E3D (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3D_V1_1 4021 // MKS Robin E3D V1.1 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3P 4022 // MKS Robin E3p (STM32F103VET6) +#define BOARD_CHITU3D 4010 // Chitu3D (STM32F103RE) +#define BOARD_MKS_ROBIN 4011 // MKS Robin (STM32F103ZE) +#define BOARD_MKS_ROBIN_MINI 4012 // MKS Robin Mini (STM32F103VE) +#define BOARD_MKS_ROBIN_NANO 4013 // MKS Robin Nano (STM32F103VE) +#define BOARD_MKS_ROBIN_NANO_V2 4014 // MKS Robin Nano V2 (STM32F103VE) +#define BOARD_MKS_ROBIN_LITE 4015 // MKS Robin Lite/Lite2 (STM32F103RC) +#define BOARD_MKS_ROBIN_LITE3 4016 // MKS Robin Lite3 (STM32F103RC) +#define BOARD_MKS_ROBIN_PRO 4017 // MKS Robin Pro (STM32F103ZE) +#define BOARD_MKS_ROBIN_E3 4018 // MKS Robin E3 (STM32F103RC) +#define BOARD_MKS_ROBIN_E3_V1_1 4019 // MKS Robin E3 V1.1 (STM32F103RC) +#define BOARD_MKS_ROBIN_E3D 4020 // MKS Robin E3D (STM32F103RC) +#define BOARD_MKS_ROBIN_E3D_V1_1 4021 // MKS Robin E3D V1.1 (STM32F103RC) +#define BOARD_MKS_ROBIN_E3P 4022 // MKS Robin E3p (STM32F103VE) #define BOARD_BTT_SKR_MINI_V1_1 4023 // BigTreeTech SKR Mini v1.1 (STM32F103RC) #define BOARD_BTT_SKR_MINI_E3_V1_0 4024 // BigTreeTech SKR Mini E3 (STM32F103RC) #define BOARD_BTT_SKR_MINI_E3_V1_2 4025 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC) #define BOARD_BTT_SKR_MINI_E3_V2_0 4026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE) -#define BOARD_BTT_SKR_MINI_MZ_V1_0 4027 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC) -#define BOARD_BTT_SKR_E3_DIP 4028 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) -#define BOARD_BTT_SKR_CR6 4029 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) -#define BOARD_JGAURORA_A5S_A1 4030 // JGAurora A5S A1 (STM32F103ZET6) -#define BOARD_FYSETC_AIO_II 4031 // FYSETC AIO_II -#define BOARD_FYSETC_CHEETAH 4032 // FYSETC Cheetah -#define BOARD_FYSETC_CHEETAH_V12 4033 // FYSETC Cheetah V1.2 -#define BOARD_LONGER3D_LK 4034 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6 -#define BOARD_CCROBOT_MEEB_3DP 4035 // ccrobot-online.com MEEB_3DP (STM32F103RC) -#define BOARD_CHITU3D_V5 4036 // Chitu3D TronXY X5SA V5 Board -#define BOARD_CHITU3D_V6 4037 // Chitu3D TronXY X5SA V6 Board -#define BOARD_CHITU3D_V9 4038 // Chitu3D TronXY X5SA V9 Board -#define BOARD_CREALITY_V4 4039 // Creality v4.x (STM32F103RE) -#define BOARD_CREALITY_V427 4040 // Creality v4.2.7 (STM32F103RE) -#define BOARD_CREALITY_V4210 4041 // Creality v4.2.10 (STM32F103RE) as found in the CR-30 -#define BOARD_CREALITY_V431 4042 // Creality v4.3.1 (STM32F103RE) -#define BOARD_CREALITY_V431_A 4043 // Creality v4.3.1a (STM32F103RE) -#define BOARD_CREALITY_V431_B 4044 // Creality v4.3.1b (STM32F103RE) -#define BOARD_CREALITY_V431_C 4045 // Creality v4.3.1c (STM32F103RE) -#define BOARD_CREALITY_V431_D 4046 // Creality v4.3.1d (STM32F103RE) -#define BOARD_CREALITY_V452 4047 // Creality v4.5.2 (STM32F103RE) -#define BOARD_CREALITY_V453 4048 // Creality v4.5.3 (STM32F103RE) -#define BOARD_CREALITY_V24S1 4049 // Creality v2.4.S1 (STM32F103RE) v101 as found in the Ender 7 -#define BOARD_TRIGORILLA_PRO 4050 // Trigorilla Pro (STM32F103ZET6) -#define BOARD_FLY_MINI 4051 // FLYmaker FLY MINI (STM32F103RCT6) -#define BOARD_FLSUN_HISPEED 4052 // FLSUN HiSpeedV1 (STM32F103VET6) -#define BOARD_BEAST 4053 // STM32F103RET6 Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4054 // STM32F103ZET6 Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4055 // STM32F103VET6 controller -#define BOARD_ZONESTAR_ZM3E2 4056 // Zonestar ZM3E2 (STM32F103RCT6) -#define BOARD_ZONESTAR_ZM3E4 4057 // Zonestar ZM3E4 V1 (STM32F103VCT6) -#define BOARD_ZONESTAR_ZM3E4V2 4058 // Zonestar ZM3E4 V2 (STM32F103VCT6) -#define BOARD_ERYONE_ERY32_MINI 4059 // Eryone Ery32 mini (STM32F103VET6) +#define BOARD_BTT_SKR_MINI_E3_V3_0 4027 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RE) +#define BOARD_BTT_SKR_MINI_MZ_V1_0 4028 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC) +#define BOARD_BTT_SKR_E3_DIP 4029 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) +#define BOARD_BTT_SKR_CR6 4030 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) +#define BOARD_JGAURORA_A5S_A1 4031 // JGAurora A5S A1 (STM32F103ZE) +#define BOARD_FYSETC_AIO_II 4032 // FYSETC AIO_II +#define BOARD_FYSETC_CHEETAH 4033 // FYSETC Cheetah +#define BOARD_FYSETC_CHEETAH_V12 4034 // FYSETC Cheetah V1.2 +#define BOARD_LONGER3D_LK 4035 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VE +#define BOARD_CCROBOT_MEEB_3DP 4036 // ccrobot-online.com MEEB_3DP (STM32F103RC) +#define BOARD_CHITU3D_V5 4037 // Chitu3D TronXY X5SA V5 Board +#define BOARD_CHITU3D_V6 4038 // Chitu3D TronXY X5SA V6 Board +#define BOARD_CHITU3D_V9 4039 // Chitu3D TronXY X5SA V9 Board +#define BOARD_CREALITY_V4 4040 // Creality v4.x (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V422 4041 // Creality v4.2.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V423 4042 // Creality v4.2.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V427 4043 // Creality v4.2.7 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V4210 4044 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 +#define BOARD_CREALITY_V431 4045 // Creality v4.3.1 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_A 4046 // Creality v4.3.1a (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_B 4047 // Creality v4.3.1b (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_C 4048 // Creality v4.3.1c (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_D 4049 // Creality v4.3.1d (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V452 4050 // Creality v4.5.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V453 4051 // Creality v4.5.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V24S1 4052 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender 7 +#define BOARD_CREALITY_V24S1_301 4053 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) as found in the Ender 3 S1 +#define BOARD_TRIGORILLA_PRO 4054 // Trigorilla Pro (STM32F103ZE) +#define BOARD_FLY_MINI 4055 // FLYmaker FLY MINI (STM32F103RC) +#define BOARD_FLSUN_HISPEED 4056 // FLSUN HiSpeedV1 (STM32F103VE) +#define BOARD_BEAST 4057 // STM32F103RE Libmaple-based controller +#define BOARD_MINGDA_MPX_ARM_MINI 4058 // STM32F103ZE Mingda MD-16 +#define BOARD_GTM32_PRO_VD 4059 // STM32F103VE controller +#define BOARD_ZONESTAR_ZM3E2 4060 // Zonestar ZM3E2 (STM32F103RC) +#define BOARD_ZONESTAR_ZM3E4 4061 // Zonestar ZM3E4 V1 (STM32F103VC) +#define BOARD_ZONESTAR_ZM3E4V2 4062 // Zonestar ZM3E4 V2 (STM32F103VC) +#define BOARD_ERYONE_ERY32_MINI 4063 // Eryone Ery32 mini (STM32F103VE) +#define BOARD_PANDA_PI_V29 4064 // Panda Pi V2.9 - Standalone (STM32F103RC) // // ARM Cortex-M4F @@ -370,43 +378,45 @@ // #define BOARD_ARMED 4200 // Arm'ed STM32F4-based controller -#define BOARD_RUMBA32_V1_0 4201 // RUMBA32 STM32F446VET6 based controller from Aus3D -#define BOARD_RUMBA32_V1_1 4202 // RUMBA32 STM32F446VET6 based controller from Aus3D -#define BOARD_RUMBA32_MKS 4203 // RUMBA32 STM32F446VET6 based controller from Makerbase -#define BOARD_RUMBA32_BTT 4204 // RUMBA32 STM32F446VET6 based controller from BIGTREETECH +#define BOARD_RUMBA32_V1_0 4201 // RUMBA32 STM32F446VE based controller from Aus3D +#define BOARD_RUMBA32_V1_1 4202 // RUMBA32 STM32F446VE based controller from Aus3D +#define BOARD_RUMBA32_MKS 4203 // RUMBA32 STM32F446VE based controller from Makerbase +#define BOARD_RUMBA32_BTT 4204 // RUMBA32 STM32F446VE based controller from BIGTREETECH #define BOARD_BLACK_STM32F407VE 4205 // BLACK_STM32F407VE #define BOARD_BLACK_STM32F407ZE 4206 // BLACK_STM32F407ZE #define BOARD_STEVAL_3DP001V1 4207 // STEVAL-3DP001V1 3D PRINTER BOARD -#define BOARD_BTT_SKR_PRO_V1_1 4208 // BigTreeTech SKR Pro v1.1 (STM32F407ZGT6) -#define BOARD_BTT_SKR_PRO_V1_2 4209 // BigTreeTech SKR Pro v1.2 (STM32F407ZGT6) -#define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VGT6) -#define BOARD_BTT_E3_RRF 4211 // BigTreeTech E3 RRF (STM32F407VGT6) -#define BOARD_BTT_SKR_V2_0_REV_A 4212 // BigTreeTech SKR v2.0 Rev A (STM32F407VGT6) -#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VGT6) +#define BOARD_BTT_SKR_PRO_V1_1 4208 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) +#define BOARD_BTT_SKR_PRO_V1_2 4209 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) +#define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VG) +#define BOARD_BTT_E3_RRF 4211 // BigTreeTech E3 RRF (STM32F407VG) +#define BOARD_BTT_SKR_V2_0_REV_A 4212 // BigTreeTech SKR v2.0 Rev A (STM32F407VG) +#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VG/STM32F429VG) #define BOARD_BTT_GTR_V1_0 4214 // BigTreeTech GTR v1.0 (STM32F407IGT) -#define BOARD_BTT_OCTOPUS_V1_0 4215 // BigTreeTech Octopus v1.0 (STM32F446ZET6) -#define BOARD_BTT_OCTOPUS_V1_1 4216 // BigTreeTech Octopus v1.1 (STM32F446ZET6) -#define BOARD_BTT_OCTOPUS_PRO_V1_0 4217 // BigTreeTech Octopus Pro v1.0 (STM32F446ZET6/STM32F429ZGT6) +#define BOARD_BTT_OCTOPUS_V1_0 4215 // BigTreeTech Octopus v1.0 (STM32F446ZE) +#define BOARD_BTT_OCTOPUS_V1_1 4216 // BigTreeTech Octopus v1.1 (STM32F446ZE) +#define BOARD_BTT_OCTOPUS_PRO_V1_0 4217 // BigTreeTech Octopus Pro v1.0 (STM32F446ZE/STM32F429ZG) #define BOARD_LERDGE_K 4218 // Lerdge K (STM32F407ZG) #define BOARD_LERDGE_S 4219 // Lerdge S (STM32F407VE) #define BOARD_LERDGE_X 4220 // Lerdge X (STM32F407VE) -#define BOARD_VAKE403D 4221 // VAkE 403D (STM32F446VET6) -#define BOARD_FYSETC_S6 4222 // FYSETC S6 (STM32F446VET6) -#define BOARD_FYSETC_S6_V2_0 4223 // FYSETC S6 v2.0 (STM32F446VET6) -#define BOARD_FYSETC_SPIDER 4224 // FYSETC Spider (STM32F446VET6) +#define BOARD_VAKE403D 4221 // VAkE 403D (STM32F446VE) +#define BOARD_FYSETC_S6 4222 // FYSETC S6 (STM32F446VE) +#define BOARD_FYSETC_S6_V2_0 4223 // FYSETC S6 v2.0 (STM32F446VE) +#define BOARD_FYSETC_SPIDER 4224 // FYSETC Spider (STM32F446VE) #define BOARD_FLYF407ZG 4225 // FLYmaker FLYF407ZG (STM32F407ZG) #define BOARD_MKS_ROBIN2 4226 // MKS_ROBIN2 (STM32F407ZE) #define BOARD_MKS_ROBIN_PRO_V2 4227 // MKS Robin Pro V2 (STM32F407VE) #define BOARD_MKS_ROBIN_NANO_V3 4228 // MKS Robin Nano V3 (STM32F407VG) -#define BOARD_MKS_MONSTER8 4229 // MKS Monster8 (STM32F407VGT6) -#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_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) +#define BOARD_MKS_ROBIN_NANO_V3_1 4229 // MKS Robin Nano V3.1 (STM32F407VE) +#define BOARD_MKS_MONSTER8 4230 // MKS Monster8 (STM32F407VG) +#define BOARD_ANET_ET4 4231 // ANET ET4 V1.x (STM32F407VG) +#define BOARD_ANET_ET4P 4232 // ANET ET4P V1.x (STM32F407VG) +#define BOARD_FYSETC_CHEETAH_V20 4233 // FYSETC Cheetah V2.0 +#define BOARD_TH3D_EZBOARD_V2 4234 // TH3D EZBoard v2.0 +#define BOARD_INDEX_REV03 4235 // Index PnP Controller REV03 (STM32F407VE/VG) +#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4236 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE) +#define BOARD_MKS_EAGLE 4237 // MKS Eagle (STM32F407VE) +#define BOARD_ARTILLERY_RUBY 4238 // Artillery Ruby (STM32F401RC) +#define BOARD_FYSETC_SPIDER_V2_2 4239 // FYSETC Spider V2.2 (STM32F446VE) // // ARM Cortex M7 @@ -430,12 +440,15 @@ #define BOARD_FYSETC_E4 6005 // FYSETC E4 #define BOARD_PANDA_ZHU 6006 // Panda_ZHU #define BOARD_PANDA_M4 6007 // Panda_M4 +#define BOARD_MKS_TINYBEE 6008 // MKS TinyBee based on ESP32 (with I2S stepper stream) // // SAMD51 ARM Cortex M4 // #define BOARD_AGCM4_RAMPS_144 6100 // RAMPS 1.4.4 +#define BOARD_BRICOLEMON_V1_0 6101 // Bricolemon +#define BOARD_BRICOLEMON_LITE_V1_0 6102 // Bricolemon Lite // // Custom board diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 0a76410274bb..ac1f4a155de1 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -128,7 +128,7 @@ // Test for a driver that uses SPI - this allows checking whether a _CS_ pin // is considered sensitive #define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \ - || AXIS_DRIVER_TYPE(A,TMC2660) \ + || AXIS_DRIVER_TYPE(A,TMC26X) || AXIS_DRIVER_TYPE(A,TMC2660) \ || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) ) #define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) ) @@ -200,4 +200,4 @@ #define HAS_L64XX_NOT_L6474 1 #endif -#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01)) +#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01)) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 03bffb8bd9ad..8e0784f70d76 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -105,6 +105,7 @@ #define STR_ENQUEUEING "enqueueing \"" #define STR_POWERUP "PowerUp" +#define STR_POWEROFF "PowerOff" #define STR_EXTERNAL_RESET " External Reset" #define STR_BROWNOUT_RESET " Brown out Reset" #define STR_WATCHDOG_RESET " Watchdog Reset" @@ -140,6 +141,7 @@ #define STR_RESEND "Resend: " #define STR_UNKNOWN_COMMAND "Unknown command: \"" #define STR_ACTIVE_EXTRUDER "Active Extruder: " +#define STR_ERR_FANSPEED "Fan speed E" #define STR_PROBE_OFFSET "Probe Offset" #define STR_SKEW_MIN "min_skew_factor: " @@ -239,6 +241,7 @@ #define STR_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !" #define STR_T_HEATING_FAILED "Heating failed" #define STR_T_THERMAL_RUNAWAY "Thermal Runaway" +#define STR_T_MALFUNCTION "Thermal Malfunction" #define STR_T_MAXTEMP "MAXTEMP triggered" #define STR_T_MINTEMP "MINTEMP triggered" #define STR_ERR_PROBING_FAILED "Probing Failed" @@ -252,7 +255,7 @@ #define STR_DEBUG_ERRORS "ERRORS" #define STR_DEBUG_DRYRUN "DRYRUN" #define STR_DEBUG_COMMUNICATION "COMMUNICATION" -#define STR_DEBUG_LEVELING "LEVELING" +#define STR_DEBUG_DETAIL "DETAIL" #define STR_PRINTER_LOCKED "Printer locked! (Unlock with M511 or LCD)" #define STR_WRONG_PASSWORD "Incorrect Password" @@ -304,6 +307,7 @@ #define STR_Z_PROBE_OFFSET "Z-Probe Offset" #define STR_TEMPERATURE_UNITS "Temperature Units" #define STR_USER_THERMISTORS "User thermistors" +#define STR_DELAYED_POWEROFF "Delayed poweroff" // // Endstop Names used by Endstops::report_states @@ -339,9 +343,6 @@ #define STR_X "X" #define STR_Y "Y" #define STR_Z "Z" -#define STR_I AXIS4_STR -#define STR_J AXIS5_STR -#define STR_K AXIS6_STR #define STR_E "E" #if IS_KINEMATIC #define STR_A "A" @@ -358,115 +359,89 @@ #define STR_Z3 "Z3" #define STR_Z4 "Z4" -#define LCD_STR_A STR_A -#define LCD_STR_B STR_B -#define LCD_STR_C STR_C -#define LCD_STR_I STR_I -#define LCD_STR_J STR_J -#define LCD_STR_K STR_K -#define LCD_STR_E STR_E - // Extra Axis and Endstop Names -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #if AXIS4_NAME == 'A' - #define AXIS4_STR "A" + #define STR_I "A" #define STR_I_MIN "a_min" #define STR_I_MAX "a_max" #elif AXIS4_NAME == 'B' - #define AXIS4_STR "B" + #define STR_I "B" #define STR_I_MIN "b_min" #define STR_I_MAX "b_max" #elif AXIS4_NAME == 'C' - #define AXIS4_STR "C" + #define STR_I "C" #define STR_I_MIN "c_min" #define STR_I_MAX "c_max" #elif AXIS4_NAME == 'U' - #define AXIS4_STR "U" + #define STR_I "U" #define STR_I_MIN "u_min" #define STR_I_MAX "u_max" #elif AXIS4_NAME == 'V' - #define AXIS4_STR "V" + #define STR_I "V" #define STR_I_MIN "v_min" #define STR_I_MAX "v_max" #elif AXIS4_NAME == 'W' - #define AXIS4_STR "W" + #define STR_I "W" #define STR_I_MIN "w_min" #define STR_I_MAX "w_max" #else - #define AXIS4_STR "A" - #define STR_I_MIN "a_min" - #define STR_I_MAX "a_max" + #error "AXIS4_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." #endif #else - #define AXIS4_STR "" + #define STR_I "" #endif -#if LINEAR_AXES >= 5 - #if AXIS5_NAME == 'A' - #define AXIS5_STR "A" - #define STR_J_MIN "a_min" - #define STR_J_MAX "a_max" - #elif AXIS5_NAME == 'B' - #define AXIS5_STR "B" +#if HAS_J_AXIS + #if AXIS5_NAME == 'B' + #define STR_J "B" #define STR_J_MIN "b_min" #define STR_J_MAX "b_max" #elif AXIS5_NAME == 'C' - #define AXIS5_STR "C" + #define STR_J "C" #define STR_J_MIN "c_min" #define STR_J_MAX "c_max" #elif AXIS5_NAME == 'U' - #define AXIS5_STR "U" + #define STR_J "U" #define STR_J_MIN "u_min" #define STR_J_MAX "u_max" #elif AXIS5_NAME == 'V' - #define AXIS5_STR "V" + #define STR_J "V" #define STR_J_MIN "v_min" #define STR_J_MAX "v_max" #elif AXIS5_NAME == 'W' - #define AXIS5_STR "W" + #define STR_J "W" #define STR_J_MIN "w_min" #define STR_J_MAX "w_max" #else - #define AXIS5_STR "B" - #define STR_J_MIN "b_min" - #define STR_J_MAX "b_max" + #error "AXIS5_NAME can only be one of 'B', 'C', 'U', 'V', or 'W'." #endif #else - #define AXIS5_STR "" + #define STR_J "" #endif -#if LINEAR_AXES >= 6 - #if AXIS6_NAME == 'A' - #define AXIS6_STR "A" - #define STR_K_MIN "a_min" - #define STR_K_MAX "a_max" - #elif AXIS6_NAME == 'B' - #define AXIS6_STR "B" - #define STR_K_MIN "b_min" - #define STR_K_MAX "b_max" - #elif AXIS6_NAME == 'C' - #define AXIS6_STR "C" +#if HAS_K_AXIS + #if AXIS6_NAME == 'C' + #define STR_K "C" #define STR_K_MIN "c_min" #define STR_K_MAX "c_max" #elif AXIS6_NAME == 'U' - #define AXIS6_STR "U" + #define STR_K "U" #define STR_K_MIN "u_min" #define STR_K_MAX "u_max" #elif AXIS6_NAME == 'V' - #define AXIS6_STR "V" + #define STR_K "V" #define STR_K_MIN "v_min" #define STR_K_MAX "v_max" #elif AXIS6_NAME == 'W' - #define AXIS6_STR "W" + #define STR_K "W" #define STR_K_MIN "w_min" #define STR_K_MAX "w_max" #else - #define AXIS6_STR "C" - #define STR_K_MIN "c_min" - #define STR_K_MAX "c_max" + #error "AXIS6_NAME can only be one of 'C', 'U', 'V', or 'W'." #endif #else - #define AXIS6_STR "" + #define STR_K "" #endif #if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) @@ -517,34 +492,34 @@ */ #if ENABLED(NUMBER_TOOLS_FROM_0) #define LCD_FIRST_TOOL 0 - #define LCD_STR_N0 "0" - #define LCD_STR_N1 "1" - #define LCD_STR_N2 "2" - #define LCD_STR_N3 "3" - #define LCD_STR_N4 "4" - #define LCD_STR_N5 "5" - #define LCD_STR_N6 "6" - #define LCD_STR_N7 "7" + #define STR_N0 "0" + #define STR_N1 "1" + #define STR_N2 "2" + #define STR_N3 "3" + #define STR_N4 "4" + #define STR_N5 "5" + #define STR_N6 "6" + #define STR_N7 "7" #else #define LCD_FIRST_TOOL 1 - #define LCD_STR_N0 "1" - #define LCD_STR_N1 "2" - #define LCD_STR_N2 "3" - #define LCD_STR_N3 "4" - #define LCD_STR_N4 "5" - #define LCD_STR_N5 "6" - #define LCD_STR_N6 "7" - #define LCD_STR_N7 "8" + #define STR_N0 "1" + #define STR_N1 "2" + #define STR_N2 "3" + #define STR_N3 "4" + #define STR_N4 "5" + #define STR_N5 "6" + #define STR_N6 "7" + #define STR_N7 "8" #endif -#define LCD_STR_E0 "E" LCD_STR_N0 -#define LCD_STR_E1 "E" LCD_STR_N1 -#define LCD_STR_E2 "E" LCD_STR_N2 -#define LCD_STR_E3 "E" LCD_STR_N3 -#define LCD_STR_E4 "E" LCD_STR_N4 -#define LCD_STR_E5 "E" LCD_STR_N5 -#define LCD_STR_E6 "E" LCD_STR_N6 -#define LCD_STR_E7 "E" LCD_STR_N7 +#define STR_E0 STR_E STR_N0 +#define STR_E1 STR_E STR_N1 +#define STR_E2 STR_E STR_N2 +#define STR_E3 STR_E STR_N3 +#define STR_E4 STR_E STR_N4 +#define STR_E5 STR_E STR_N5 +#define STR_E6 STR_E STR_N6 +#define STR_E7 STR_E STR_N7 // Include localized LCD Menu Messages diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 62675d131972..31808586cf0d 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -131,13 +131,13 @@ #ifdef __cplusplus // C++11 solution that is standards compliant. - template static inline constexpr void NOLESS(V& v, const N n) { + template static constexpr void NOLESS(V& v, const N n) { if (n > v) v = n; } - template static inline constexpr void NOMORE(V& v, const N n) { + template static constexpr void NOMORE(V& v, const N n) { if (n < v) v = n; } - template static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) { + template static constexpr void LIMIT(V& v, const N1 n1, const N2 n2) { if (n1 > v) v = n1; else if (n2 < v) v = n2; } @@ -235,6 +235,8 @@ #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. +#define _OPTITEM(A...) A, +#define OPTITEM(O,A...) TERN_(O,DEFER4(_OPTITEM)(A)) #define _OPTARG(A...) , A #define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A)) #define _OPTCODE(A) A; @@ -366,7 +368,7 @@ #undef ABS #ifdef __cplusplus - template static inline constexpr const T ABS(const T v) { return v >= 0 ? v : -v; } + template static constexpr const T ABS(const T v) { return v >= 0 ? v : -v; } #else #define ABS(a) ({__typeof__(a) _a = (a); _a >= 0 ? _a : -_a;}) #endif @@ -409,14 +411,14 @@ extern "C++" { // C++11 solution that is standards compliant. Return type is deduced automatically - template static inline constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) { + template static constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) { return lhs < rhs ? lhs : rhs; } - template static inline constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) { + template static constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) { return lhs > rhs ? lhs : rhs; } - template static inline constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); } - template static inline constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); } + template static constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); } + template static constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); } } diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 9cd862df702c..562cddbaa07a 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -36,10 +36,10 @@ PGMSTR(X_LBL, "X:"); PGMSTR(Y_LBL, "Y:"); PGMSTR(Z_LBL, "Z:"); PGMST PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C"); PGMSTR(SP_X_STR, " X"); PGMSTR(SP_Y_STR, " Y"); PGMSTR(SP_Z_STR, " Z"); PGMSTR(SP_E_STR, " E"); PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMSTR(SP_E_LBL, " E:"); -PGMSTR(I_STR, AXIS4_STR); PGMSTR(J_STR, AXIS5_STR); PGMSTR(K_STR, AXIS6_STR); -PGMSTR(I_LBL, AXIS4_STR ":"); PGMSTR(J_LBL, AXIS5_STR ":"); PGMSTR(K_LBL, AXIS6_STR ":"); -PGMSTR(SP_I_STR, " " AXIS4_STR); PGMSTR(SP_J_STR, " " AXIS5_STR); PGMSTR(SP_K_STR, " " AXIS6_STR); -PGMSTR(SP_I_LBL, " " AXIS4_STR ":"); PGMSTR(SP_J_LBL, " " AXIS5_STR ":"); PGMSTR(SP_K_LBL, " " AXIS6_STR ":"); +PGMSTR(I_STR, STR_I); PGMSTR(J_STR, STR_J); PGMSTR(K_STR, STR_K); +PGMSTR(I_LBL, STR_I ":"); PGMSTR(J_LBL, STR_J ":"); PGMSTR(K_LBL, STR_K ":"); +PGMSTR(SP_I_STR, " " STR_I); PGMSTR(SP_J_STR, " " STR_J); PGMSTR(SP_K_STR, " " STR_K); +PGMSTR(SP_I_LBL, " " STR_I ":"); PGMSTR(SP_J_LBL, " " STR_J ":"); PGMSTR(SP_K_LBL, " " STR_K ":"); // Hook Meatpack if it's enabled on the first leaf #if ENABLED(MEATPACK_ON_SERIAL_PORT_1) @@ -78,6 +78,14 @@ void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P( void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); } +void serial_offset(const_float_t v, const uint8_t sp/*=0*/) { + if (v == 0 && sp == 1) + SERIAL_CHAR(' '); + else if (v > 0 || (v == 0 && sp == 2)) + SERIAL_CHAR('+'); + SERIAL_DECIMAL(v); +} + void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) { if (pre) serial_print(pre); serial_print(onoff ? on : off); diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index aee4d4d43db8..98e82b6d7281 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -345,6 +345,7 @@ void serialprint_onoff(const bool onoff); void serialprintln_onoff(const bool onoff); void serialprint_truefalse(const bool tf); void serial_spaces(uint8_t count); +void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space (sp==1) or plus (sp==2) void print_bin(const uint16_t val); void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr); diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index 2019b389e497..9b9fa8fa3828 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -37,7 +37,7 @@ class SerialMask { inline constexpr bool enabled(const SerialMask PortMask) const { return mask & PortMask.mask; } inline constexpr SerialMask combine(const SerialMask other) const { return SerialMask(mask | other.mask); } inline constexpr SerialMask operator<< (const int offset) const { return SerialMask(mask << offset); } - static inline SerialMask from(const serial_index_t index) { + static SerialMask from(const serial_index_t index) { if (index.valid()) return SerialMask(_BV(index.index)); return SerialMask(0); // A invalid index mean no output } diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 72099fb40873..53d98e0e6dd2 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -52,7 +52,7 @@ struct IF { typedef L type; }; #define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k) #define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V) -#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR) +#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", STR_I, STR_J, STR_K) #if HAS_EXTRUDERS #define LIST_ITEM_E(N) , N @@ -64,6 +64,8 @@ struct IF { typedef L type; }; #define GANG_ITEM_E(N) #endif +#define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L) + // // Enumerated axis indices // @@ -82,7 +84,7 @@ enum AxisEnum : uint8_t { #undef _EN_ITEM // Core also keeps toolhead directions - #if EITHER(IS_CORE, MARKFORGED_XY) + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) , X_HEAD, Y_HEAD, Z_HEAD #endif @@ -96,10 +98,10 @@ enum AxisEnum : uint8_t { // A, B, and C are for DELTA, SCARA, etc. , A_AXIS = X_AXIS - #if LINEAR_AXES >= 2 + #if HAS_Y_AXIS , B_AXIS = Y_AXIS #endif - #if LINEAR_AXES >= 3 + #if HAS_Z_AXIS , C_AXIS = Z_AXIS #endif @@ -126,6 +128,7 @@ typedef float feedRate_t; // celsius_t is the native unit of temperature. Signed to handle a disconnected thermistor value (-14). // For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100 // +typedef uint16_t raw_adc_t; typedef int16_t celsius_t; typedef float celsius_float_t; @@ -406,13 +409,13 @@ struct XYZval { FI void set(const T (&arr)[DISTINCT_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); } #endif #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } #endif @@ -534,28 +537,30 @@ struct XYZEval { // Reset all to 0 FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =) 0; } + // Setters for some number of linear axes, not all + FI void set(const T px) { x = px; } + FI void set(const T px, const T py) { x = px; y = py; } + #if HAS_I_AXIS + FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } + #endif + #if HAS_J_AXIS + FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } + #endif + #if HAS_K_AXIS + FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } + #endif // Setters taking struct types and arrays - FI void set(const T px) { x = px; } - FI void set(const T px, const T py) { x = px; y = py; } - FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } - FI void set(const XYZval pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); } + FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } + FI void set(const XYZval pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); } #if HAS_Z_AXIS FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k); } #endif + FI void set(const XYval pxy, const T pz) { set(pxy); TERN_(HAS_Z_AXIS, z = pz); } #if LOGICAL_AXES > LINEAR_AXES - FI void set(const XYval pxy, const T pe) { set(pxy); e = pe; } + FI void set(const XYval pxy, const T pz, const T pe) { set(pxy, pz); e = pe; } FI void set(const XYZval pxyz, const T pe) { set(pxyz); e = pe; } FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, u = i, v = j, w = k); } #endif - #if LINEAR_AXES >= 4 - FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } - #endif - #if LINEAR_AXES >= 5 - FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } - #endif - #if LINEAR_AXES >= 6 - FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } - #endif // Length reduced to one dimension FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k)); } diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index b70e2fa9a94d..59e59d4cb7ff 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -60,7 +60,8 @@ void safe_delay(millis_t ms) { TERN_(DELTA, "Delta") TERN_(IS_SCARA, "SCARA") TERN_(IS_CORE, "Core") - TERN_(MARKFORGED_XY, "MarkForged") + TERN_(MARKFORGED_XY, "MarkForgedXY") + TERN_(MARKFORGED_YX, "MarkForgedYX") TERN_(IS_CARTESIAN, "Cartesian") ); @@ -73,7 +74,8 @@ void safe_delay(millis_t ms) { TERN_(Z_PROBE_SLED, "Z_PROBE_SLED") TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY") TERN_(SOLENOID_PROBE, "SOLENOID_PROBE") - TERN(PROBE_SELECTED, "", "NONE") + TERN_(MAGLEV4, "MAGLEV4") + IF_DISABLED(PROBE_SELECTED, "NONE") ); #if HAS_BED_PROBE @@ -124,10 +126,8 @@ void safe_delay(millis_t ms) { #if ABL_PLANAR SERIAL_ECHOPGM("ABL Adjustment"); LOOP_LINEAR_AXES(a) { - const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]; SERIAL_CHAR(' ', AXIS_CHAR(a)); - if (v > 0) SERIAL_CHAR('+'); - SERIAL_DECIMAL(v); + serial_offset(planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]); } #else #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/feature/adc/adc_mcp3426.cpp b/Marlin/src/feature/adc/adc_mcp3426.cpp new file mode 100644 index 000000000000..aaddf46821b0 --- /dev/null +++ b/Marlin/src/feature/adc/adc_mcp3426.cpp @@ -0,0 +1,104 @@ +/** + * 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 . + * + */ + +/** + * adc_mcp3426.cpp - library for MicroChip MCP3426 I2C A/D converter + * + * For implementation details, please take a look at the datasheet: + * https://www.microchip.com/en-us/product/MCP3426 + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(HAS_MCP3426_ADC) + +#include "adc_mcp3426.h" + +// Read the ADC value from MCP342X on a specific channel +int16_t MCP3426::ReadValue(uint8_t channel, uint8_t gain) { + Error = false; + + #if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) + Wire.setSDA(pin_t(I2C_SDA_PIN)); + Wire.setSCL(pin_t(I2C_SCL_PIN)); + #endif + + Wire.begin(); // No address joins the BUS as the master + + Wire.beginTransmission(I2C_ADDRESS(MCP342X_ADC_I2C_ADDRESS)); + + // Continuous Conversion Mode, 16 bit, Channel 1, Gain x4 + // 26 = 0b00011000 + // RXXCSSGG + // R = Ready Bit + // XX = Channel (00=1, 01=2, 10=3 (MCP3428), 11=4 (MCP3428)) + // C = Conversion Mode Bit (1= Continuous Conversion Mode (Default)) + // SS = Sample rate, 10=15 samples per second @ 16 bits + // GG = Gain 00 =x1 + uint8_t controlRegister = 0b00011000; + + if (channel == 2) controlRegister |= 0b00100000; // Select channel 2 + + if (gain == 2) + controlRegister |= 0b00000001; + else if (gain == 4) + controlRegister |= 0b00000010; + else if (gain == 8) + controlRegister |= 0b00000011; + + Wire.write(controlRegister); + if (Wire.endTransmission() != 0) { + Error = true; + return 0; + } + + const uint8_t len = 3; + uint8_t buffer[len] = {}; + + do { + Wire.requestFrom(I2C_ADDRESS(MCP342X_ADC_I2C_ADDRESS), len); + if (Wire.available() != len) { + Error = true; + return 0; + } + + for (uint8_t i = 0; i < len; ++i) + buffer[i] = Wire.read(); + + // Is conversion ready, if not loop around again + } while ((buffer[2] & 0x80) != 0); + + union TwoBytesToInt16 { + uint8_t bytes[2]; + int16_t integervalue; + }; + TwoBytesToInt16 ConversionUnion; + + ConversionUnion.bytes[1] = buffer[0]; + ConversionUnion.bytes[0] = buffer[1]; + + return ConversionUnion.integervalue; +} + +MCP3426 mcp3426; + +#endif // HAS_MCP3426_ADC diff --git a/Marlin/src/feature/adc/adc_mcp3426.h b/Marlin/src/feature/adc/adc_mcp3426.h new file mode 100644 index 000000000000..35458716b975 --- /dev/null +++ b/Marlin/src/feature/adc/adc_mcp3426.h @@ -0,0 +1,41 @@ +/** + * 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 + +/** + * Arduino library for MicroChip MCP3426 I2C A/D converter. + * https://www.microchip.com/en-us/product/MCP3426 + */ + +#include +#include + +// Address of MCP342X chip +#define MCP342X_ADC_I2C_ADDRESS 104 + +class MCP3426 { + public: + int16_t ReadValue(uint8_t channel, uint8_t gain); + bool Error; +}; + +extern MCP3426 mcp3426; diff --git a/Marlin/src/feature/babystep.h b/Marlin/src/feature/babystep.h index f8037678ca16..5693afb4fc5b 100644 --- a/Marlin/src/feature/babystep.h +++ b/Marlin/src/feature/babystep.h @@ -54,7 +54,7 @@ class Babystep { #if ENABLED(BABYSTEP_DISPLAY_TOTAL) static int16_t axis_total[BS_TOTAL_IND(Z_AXIS) + 1]; // Total babysteps since G28 - static inline void reset_total(const AxisEnum axis) { + static void reset_total(const AxisEnum axis) { if (TERN1(BABYSTEP_XY, axis == Z_AXIS)) axis_total[BS_TOTAL_IND(axis)] = 0; } @@ -63,7 +63,7 @@ class Babystep { static void add_steps(const AxisEnum axis, const int16_t distance); static void add_mm(const AxisEnum axis, const_float_t mm); - static inline bool has_steps() { + static bool has_steps() { return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)]; } @@ -71,7 +71,7 @@ class Babystep { // Called by the Temperature or Stepper ISR to // apply accumulated babysteps to the axes. // - static inline void task() { + static void task() { LOOP_LE_N(i, BS_AXIS_IND(Z_AXIS)) step_axis(BS_AXIS(i)); } diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index b646e19f15ab..84382cf85680 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -29,6 +29,9 @@ #include "../module/motion.h" #include "../module/planner.h" +axis_bits_t Backlash::last_direction_bits; +xyz_long_t Backlash::residual_error{0}; + #ifdef BACKLASH_DISTANCE_MM #if ENABLED(BACKLASH_GCODE) xyz_float_t Backlash::distance_mm = BACKLASH_DISTANCE_MM; @@ -38,7 +41,7 @@ #endif #if ENABLED(BACKLASH_GCODE) - uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF; + uint8_t Backlash::correction = (BACKLASH_CORRECTION) * all_on; #ifdef BACKLASH_SMOOTHING_MM float Backlash::smoothing_mm = BACKLASH_SMOOTHING_MM; #endif @@ -61,10 +64,9 @@ Backlash backlash; */ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block) { - static axis_bits_t last_direction_bits; axis_bits_t changed_dir = last_direction_bits ^ dm; // Ignore direction change unless steps are taken in that direction - #if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY) + #if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX) if (!da) CBI(changed_dir, X_AXIS); if (!db) CBI(changed_dir, Y_AXIS); if (!dc) CBI(changed_dir, Z_AXIS); @@ -83,7 +85,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const #endif last_direction_bits ^= changed_dir; - if (correction == 0) return; + if (!correction && !residual_error) return; #ifdef BACKLASH_SMOOTHING_MM // The segment proportion is a value greater than 0.0 indicating how much residual_error @@ -91,39 +93,28 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const // smoothing distance. Since the computation of this proportion involves a floating point // division, defer computation until needed. float segment_proportion = 0; - - // Residual error carried forward across multiple segments, so correction can be applied - // to segments where there is no direction change. - static xyz_long_t residual_error{0}; - #else - // No direction change, no correction. - if (!changed_dir) return; - // No leftover residual error from segment to segment - xyz_long_t residual_error{0}; #endif - const float f_corr = float(correction) / 255.0f; + const float f_corr = float(correction) / all_on; LOOP_LINEAR_AXES(axis) { if (distance_mm[axis]) { - const bool reversing = TEST(dm,axis); + const bool reverse = TEST(dm, axis); // When an axis changes direction, add axis backlash to the residual error if (TEST(changed_dir, axis)) - residual_error[axis] += (reversing ? -f_corr : f_corr) * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; + residual_error[axis] += (reverse ? -f_corr : f_corr) * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; // Decide how much of the residual error to correct in this segment int32_t error_correction = residual_error[axis]; + if (reverse != (error_correction < 0)) + error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps + #ifdef BACKLASH_SMOOTHING_MM if (error_correction && smoothing_mm != 0) { - // Take up a portion of the residual_error in this segment, but only when - // the current segment travels in the same direction as the correction - if (reversing == (error_correction < 0)) { - if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm); - error_correction = CEIL(segment_proportion * error_correction); - } - else - error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps + // Take up a portion of the residual_error in this segment + if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm); + error_correction = CEIL(segment_proportion * error_correction); } #endif @@ -153,6 +144,52 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const } } +int32_t Backlash::get_applied_steps(const AxisEnum axis) { + if (axis >= LINEAR_AXES) return 0; + + const bool reverse = TEST(last_direction_bits, axis); + + const int32_t residual_error_axis = residual_error[axis]; + + // At startup it is assumed the last move was forwards. So the applied + // steps will always be a non-positive number. + + if (!reverse) return -residual_error_axis; + + const float f_corr = float(correction) / all_on; + const int32_t full_error_axis = -f_corr * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; + return full_error_axis - residual_error_axis; +} + +class Backlash::StepAdjuster { + xyz_long_t applied_steps; +public: + StepAdjuster() { + LOOP_LINEAR_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis); + } + ~StepAdjuster() { + // after backlash compensation parameter changes, ensure applied step count does not change + LOOP_LINEAR_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis]; + } +}; + +void Backlash::set_correction_uint8(const uint8_t v) { + StepAdjuster adjuster; + correction = v; +} + +void Backlash::set_distance_mm(const AxisEnum axis, const float v) { + StepAdjuster adjuster; + distance_mm[axis] = v; +} + +#ifdef BACKLASH_SMOOTHING_MM + void Backlash::set_smoothing_mm(const float v) { + StepAdjuster adjuster; + smoothing_mm = v; + } +#endif + #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) #include "../module/probe.h" diff --git a/Marlin/src/feature/backlash.h b/Marlin/src/feature/backlash.h index 4d4e2940382c..0bace526e53f 100644 --- a/Marlin/src/feature/backlash.h +++ b/Marlin/src/feature/backlash.h @@ -24,21 +24,22 @@ #include "../inc/MarlinConfigPre.h" #include "../module/planner.h" -constexpr uint8_t all_on = 0xFF, all_off = 0x00; - class Backlash { public: + static constexpr uint8_t all_on = 0xFF, all_off = 0x00; + +private: + static axis_bits_t last_direction_bits; + static xyz_long_t residual_error; + #if ENABLED(BACKLASH_GCODE) - static xyz_float_t distance_mm; static uint8_t correction; + static xyz_float_t distance_mm; #ifdef BACKLASH_SMOOTHING_MM static float smoothing_mm; #endif - - static inline void set_correction(const_float_t v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; } - static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; } #else - static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF; + static constexpr uint8_t correction = (BACKLASH_CORRECTION) * all_on; static const xyz_float_t distance_mm; #ifdef BACKLASH_SMOOTHING_MM static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM; @@ -46,14 +47,14 @@ class Backlash { #endif #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) - private: - static xyz_float_t measured_mm; - static xyz_uint8_t measured_count; - public: - static void measure_with_probe(); + static xyz_float_t measured_mm; + static xyz_uint8_t measured_count; #endif - static inline float get_measurement(const AxisEnum a) { + class StepAdjuster; + +public: + static float get_measurement(const AxisEnum a) { UNUSED(a); // Return the measurement averaged over all readings return TERN(MEASURE_BACKLASH_WHEN_PROBING @@ -62,16 +63,34 @@ class Backlash { ); } - static inline bool has_measurement(const AxisEnum a) { + static bool has_measurement(const AxisEnum a) { UNUSED(a); return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0); } - static inline bool has_any_measurement() { + static bool has_any_measurement() { return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS); } - void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block); + static void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block); + static int32_t get_applied_steps(const AxisEnum axis); + + #if ENABLED(BACKLASH_GCODE) + static void set_correction_uint8(const uint8_t v); + static uint8_t get_correction_uint8() { return correction; } + static void set_correction(const float v) { set_correction_uint8(_MAX(0, _MIN(1.0, v)) * all_on + 0.5f); } + static float get_correction() { return float(get_correction_uint8()) / all_on; } + static void set_distance_mm(const AxisEnum axis, const float v); + static float get_distance_mm(const AxisEnum axis) {return distance_mm[axis];} + #ifdef BACKLASH_SMOOTHING_MM + static void set_smoothing_mm(const float v); + static float get_smoothing_mm() {return smoothing_mm;} + #endif + #endif + + #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) + static void measure_with_probe(); + #endif }; extern Backlash backlash; diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index cc5469577189..06fae16c21e9 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -58,7 +58,7 @@ class mesh_bed_leveling { static void set_z(const int8_t px, const int8_t py, const_float_t z) { z_values[px][py] = z; } - static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) { + static void zigzag(const int8_t index, int8_t &px, int8_t &py) { px = index % (GRID_MAX_POINTS_X); py = index / (GRID_MAX_POINTS_X); if (py & 1) px = (GRID_MAX_POINTS_X) - 1 - px; // Zig zag @@ -78,10 +78,10 @@ class mesh_bed_leveling { int8_t cy = (y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST); return constrain(cy, 0, GRID_MAX_CELLS_Y - 1); } - static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { + static xy_int8_t cell_indexes(const_float_t x, const_float_t y) { return { cell_index_x(x), cell_index_y(y) }; } - static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } + static xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } static int8_t probe_index_x(const_float_t x) { int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * RECIPROCAL(MESH_X_DIST); @@ -91,10 +91,10 @@ class mesh_bed_leveling { int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * RECIPROCAL(MESH_Y_DIST); return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1; } - static inline xy_int8_t probe_indexes(const_float_t x, const_float_t y) { + static xy_int8_t probe_indexes(const_float_t x, const_float_t y) { return { probe_index_x(x), probe_index_y(y) }; } - static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); } + static xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); } static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) { const float delta_z = (z2 - z1) / (a2 - a1), diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 964f1123fe42..c162062f8609 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -213,8 +213,8 @@ void unified_bed_leveling::display_map(const uint8_t map_type) { else if (isnan(f)) SERIAL_ECHOF(human ? F(" . ") : F("NAN")); else if (human || csv) { - if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) - SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits + if (human && f >= 0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) + SERIAL_DECIMAL(f); // Positive: 5 digits, Negative: 6 digits } if (csv && i < (GRID_MAX_POINTS_X) - 1) SERIAL_CHAR('\t'); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index ffabadd990b3..f117c1af65d3 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -80,7 +80,7 @@ class unified_bed_leveling { static void tilt_mesh_based_on_3pts(const_float_t z1, const_float_t z2, const_float_t z3); static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map); static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir); - static inline bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) { + static bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) { return smart_fill_one(pos.x, pos.y, dir.x, dir.y); } static void smart_fill_mesh(); @@ -120,11 +120,11 @@ class unified_bed_leveling { static const float _mesh_index_to_xpos[GRID_MAX_POINTS_X], _mesh_index_to_ypos[GRID_MAX_POINTS_Y]; - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU static bool lcd_map_control; static void steppers_were_disabled(); #else - static inline void steppers_were_disabled() {} + static void steppers_were_disabled() {} #endif static volatile int16_t encoder_diff; // Volatile because buttons may change it at interrupt time @@ -157,10 +157,10 @@ class unified_bed_leveling { return constrain(cell_index_y_raw(y), 0, GRID_MAX_CELLS_Y - 1); } - static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { + static xy_int8_t cell_indexes(const_float_t x, const_float_t y) { return { cell_index_x(x), cell_index_y(y) }; } - static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } + static xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } static int8_t closest_x_index(const_float_t x) { const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * RECIPROCAL(MESH_X_DIST); @@ -170,7 +170,7 @@ class unified_bed_leveling { const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * RECIPROCAL(MESH_Y_DIST); return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1; } - static inline xy_int8_t closest_indexes(const xy_pos_t &xy) { + static xy_int8_t closest_indexes(const xy_pos_t &xy) { return { closest_x_index(xy.x), closest_y_index(xy.y) }; } @@ -203,7 +203,7 @@ class unified_bed_leveling { * z_correction_for_x_on_horizontal_mesh_line is an optimization for * the case where the printer is making a vertical line that only crosses horizontal mesh lines. */ - static inline float z_correction_for_x_on_horizontal_mesh_line(const_float_t rx0, const int x1_i, const int yi) { + static float z_correction_for_x_on_horizontal_mesh_line(const_float_t rx0, const int x1_i, const int yi) { if (!WITHIN(x1_i, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(yi, 0, (GRID_MAX_POINTS_Y) - 1)) { if (DEBUGGING(LEVELING)) { @@ -226,7 +226,7 @@ class unified_bed_leveling { // // See comments above for z_correction_for_x_on_horizontal_mesh_line // - static inline float z_correction_for_y_on_vertical_mesh_line(const_float_t ry0, const int xi, const int y1_i) { + static float z_correction_for_y_on_vertical_mesh_line(const_float_t ry0, const int xi, const int y1_i) { if (!WITHIN(xi, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(y1_i, 0, (GRID_MAX_POINTS_Y) - 1)) { if (DEBUGGING(LEVELING)) { @@ -285,12 +285,12 @@ class unified_bed_leveling { return z0; } - static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); } + static float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); } - static inline float mesh_index_to_xpos(const uint8_t i) { + static float mesh_index_to_xpos(const uint8_t i) { return i < (GRID_MAX_POINTS_X) ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST); } - static inline float mesh_index_to_ypos(const uint8_t i) { + static float mesh_index_to_ypos(const uint8_t i) { return i < (GRID_MAX_POINTS_Y) ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST); } @@ -300,7 +300,7 @@ class unified_bed_leveling { static void line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t e); #endif - static inline bool mesh_is_valid() { + static bool mesh_is_valid() { GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false; return true; } diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index df83923fef0a..0d00296b5b60 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -57,7 +57,7 @@ #define UBL_G29_P31 -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU bool unified_bed_leveling::lcd_map_control = false; @@ -316,7 +316,7 @@ void unified_bed_leveling::G29() { planner.synchronize(); // Send 'N' to force homing before G29 (internal only) if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes(); - TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); + TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true)); } // Invalidate one or more nearby mesh points, possibly all. @@ -367,13 +367,13 @@ void unified_bed_leveling::G29() { case 1: LOOP_L_N(x, GRID_MAX_POINTS_X) { // Create a diagonal line several Mesh cells thick that is raised + const uint8_t x2 = x + (x < (GRID_MAX_POINTS_Y) - 1 ? 1 : -1); z_values[x][x] += 9.999f; - z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick + z_values[x][x2] += 9.999f; // We want the altered line several mesh points thick #if ENABLED(EXTENSIBLE_UI) ExtUI::onMeshUpdate(x, x, z_values[x][x]); - ExtUI::onMeshUpdate(x, (x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1), z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1]); + ExtUI::onMeshUpdate(x, (x2), z_values[x][x2]); #endif - } break; @@ -443,7 +443,7 @@ void unified_bed_leveling::G29() { #endif // HAS_BED_PROBE case 2: { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU // // Manually Probe Mesh in areas that can't be reached by the probe // @@ -555,7 +555,7 @@ void unified_bed_leveling::G29() { } case 4: // Fine Tune (i.e., Edit) the Mesh - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU fine_tune_mesh(param.XY_pos, parser.seen_test('T')); #else SERIAL_ECHOLNPGM("?P4 is only available when an LCD is present."); @@ -646,7 +646,7 @@ void unified_bed_leveling::G29() { LEAVE: - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU ui.reset_alert_level(); ui.quick_feedback(); ui.reset_status(); @@ -663,7 +663,7 @@ void unified_bed_leveling::G29() { UNUSED(probe_deployed); #endif - TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index)); + TERN_(HAS_MULTI_HOTEND, if (old_tool_index != 0) tool_change(old_tool_index)); return; } @@ -725,7 +725,7 @@ void unified_bed_leveling::shift_mesh_height() { void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &nearby, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) { probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW - TERN_(HAS_LCD_MENU, ui.capture()); + TERN_(HAS_MARLINUI_MENU, ui.capture()); save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained uint8_t count = GRID_MAX_POINTS; @@ -739,7 +739,7 @@ void unified_bed_leveling::shift_mesh_height() { SERIAL_ECHOLNPGM("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, "."); TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS))); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (ui.button_pressed()) { ui.quick_feedback(false); // Preserve button state for click-and-hold SERIAL_ECHOLNPGM("\nMesh only partially populated.\n"); @@ -774,9 +774,9 @@ void unified_bed_leveling::shift_mesh_height() { TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_FINISH)); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW - TERN_(HAS_LCD_MENU, ui.release()); + TERN_(HAS_MARLINUI_MENU, ui.release()); probe.stow(); - TERN_(HAS_LCD_MENU, ui.capture()); + TERN_(HAS_MARLINUI_MENU, ui.capture()); probe.move_z_after_probing(); @@ -791,7 +791,7 @@ void unified_bed_leveling::shift_mesh_height() { #endif // HAS_BED_PROBE void set_message_with_feedback(FSTR_P const fstr) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU ui.set_status(fstr); ui.quick_feedback(); #else @@ -799,7 +799,7 @@ void set_message_with_feedback(FSTR_P const fstr) { #endif } -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU typedef void (*clickFunc_t)(); @@ -1070,7 +1070,7 @@ void set_message_with_feedback(FSTR_P const fstr) { ui.return_to_status(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU /** * Parse and validate most G29 parameters, store for use by G29 functions. @@ -1210,7 +1210,7 @@ void unified_bed_leveling::save_ubl_active_state_and_disable() { } void unified_bed_leveling::restore_ubl_active_state_and_leave() { - TERN_(HAS_LCD_MENU, ui.release()); + TERN_(HAS_MARLINUI_MENU, ui.release()); #if ENABLED(UBL_DEVEL_DEBUGGING) if (--ubl_state_recursion_chk) { SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times."); @@ -1219,6 +1219,7 @@ void unified_bed_leveling::restore_ubl_active_state_and_leave() { } #endif set_bed_leveling_enabled(ubl_state_at_invocation); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 49a10f62b155..b1cc30bee0d9 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -28,7 +28,12 @@ BLTouch bltouch; -bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +#ifdef BLTOUCH_HS_MODE + bool BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed +#else + constexpr bool BLTouch::high_speed_mode; +#endif #include "../module/servo.h" #include "../module/probe.h" @@ -63,18 +68,17 @@ void BLTouch::init(const bool set_voltage/*=false*/) { #else - if (DEBUGGING(LEVELING)) { - DEBUG_ECHOLNPGM("last_written_mode - ", last_written_mode); - DEBUG_ECHOLNPGM("config mode - " - #if ENABLED(BLTOUCH_SET_5V_MODE) - "BLTOUCH_SET_5V_MODE" - #else - "OD" - #endif - ); - } + #ifdef DEBUG_OUT + if (DEBUGGING(LEVELING)) { + PGMSTR(mode0, "OD"); + PGMSTR(mode1, "5V"); + DEBUG_ECHOPGM("BLTouch Mode: "); + DEBUG_ECHOPGM_P(bltouch.od_5v_mode ? mode1 : mode0); + DEBUG_ECHOLNPGM(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")"); + } + #endif - const bool should_set = last_written_mode != ENABLED(BLTOUCH_SET_5V_MODE); + const bool should_set = od_5v_mode != ENABLED(BLTOUCH_SET_5V_MODE); #endif @@ -193,7 +197,7 @@ void BLTouch::mode_conv_proc(const bool M5V) { _mode_store(); if (M5V) _set_5V_mode(); else _set_OD_mode(); _stow(); - last_written_mode = M5V; + od_5v_mode = M5V; } #endif // BLTOUCH diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index 9ecccb4256f4..fa857bb96ab6 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -23,10 +23,6 @@ #include "../inc/MarlinConfigPre.h" -#if DISABLED(BLTOUCH_HS_MODE) - #define BLTOUCH_SLOW_MODE 1 -#endif - // BLTouch commands are sent as servo angles typedef unsigned char BLTCommand; @@ -70,8 +66,17 @@ typedef unsigned char BLTCommand; class BLTouch { public: + static void init(const bool set_voltage=false); - static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + static bool od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + + #ifdef BLTOUCH_HS_MODE + static bool high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed + #else + static constexpr bool high_speed_mode = false; + #endif + + static float z_extra_clearance() { return high_speed_mode ? 7 : 0; } // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } diff --git a/Marlin/src/feature/cancel_object.h b/Marlin/src/feature/cancel_object.h index 1d2d77f20334..62548a371937 100644 --- a/Marlin/src/feature/cancel_object.h +++ b/Marlin/src/feature/cancel_object.h @@ -32,10 +32,10 @@ class CancelObject { static void cancel_object(const int8_t obj); static void uncancel_object(const int8_t obj); static void report(); - static inline bool is_canceled(const int8_t obj) { return TEST(canceled, obj); } - static inline void clear_active_object() { set_active_object(-1); } - static inline void cancel_active_object() { cancel_object(active_object); } - static inline void reset() { canceled = 0x0000; object_count = 0; clear_active_object(); } + static bool is_canceled(const int8_t obj) { return TEST(canceled, obj); } + static void clear_active_object() { set_active_object(-1); } + static void cancel_active_object() { cancel_object(active_object); } + static void reset() { canceled = 0x0000; object_count = 0; clear_active_object(); } }; extern CancelObject cancelable; diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index 59832fd6edd7..eb580a6d6269 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -64,12 +64,22 @@ void CaseLight::update(const bool sflag) { #endif #if CASE_LIGHT_IS_COLOR_LED - leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w) OPTARG(NEOPIXEL_LED, n10ct))); + #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) + if (on) + // Use current color of (NeoPixel) leds and new brightness level + leds.set_color(LEDColor(leds.color.r, leds.color.g, leds.color.b OPTARG(HAS_WHITE_LED, leds.color.w) OPTARG(NEOPIXEL_LED, n10ct))); + else + // Switch off leds + leds.set_off(); + #else + // Use CaseLight color (CASE_LIGHT_DEFAULT_COLOR) and new brightness level + leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w) OPTARG(NEOPIXEL_LED, n10ct))); + #endif #else // !CASE_LIGHT_IS_COLOR_LED #if CASELIGHT_USES_BRIGHTNESS if (pin_is_pwm()) - set_pwm_duty(pin_t(CASE_LIGHT_PIN), ( + hal.set_pwm_duty(pin_t(CASE_LIGHT_PIN), ( #if CASE_LIGHT_MAX_PWM == 255 n10ct #else diff --git a/Marlin/src/feature/caselight.h b/Marlin/src/feature/caselight.h index b2e82f9b838f..17e1222acbfa 100644 --- a/Marlin/src/feature/caselight.h +++ b/Marlin/src/feature/caselight.h @@ -27,10 +27,6 @@ #include "leds/leds.h" // for LEDColor #endif -#if NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL) - #define CASELIGHT_USES_BRIGHTNESS 1 -#endif - class CaseLight { public: static bool on; @@ -49,8 +45,8 @@ class CaseLight { } static void update(const bool sflag); - static inline void update_brightness() { update(false); } - static inline void update_enabled() { update(true); } + static void update_brightness() { update(false); } + static void update_enabled() { update(true); } #if ENABLED(CASE_LIGHT_IS_COLOR_LED) private: diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 330f3914f6c0..f42bf52ae40a 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -72,10 +72,14 @@ void ControllerFan::update() { ? settings.active_speed : settings.idle_speed ); - if (PWM_PIN(CONTROLLER_FAN_PIN)) - set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); - else - WRITE(CONTROLLER_FAN_PIN, speed); + #if ENABLED(FAN_SOFT_PWM) + thermalManager.soft_pwm_controller_speed = speed; + #else + if (PWM_PIN(CONTROLLER_FAN_PIN)) + hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); + else + WRITE(CONTROLLER_FAN_PIN, speed > 0); + #endif } } diff --git a/Marlin/src/feature/controllerfan.h b/Marlin/src/feature/controllerfan.h index 55f2d5cfc7aa..55eb2359b067 100644 --- a/Marlin/src/feature/controllerfan.h +++ b/Marlin/src/feature/controllerfan.h @@ -60,9 +60,9 @@ class ControllerFan { #else static const controllerFan_settings_t &settings; #endif - static inline bool state() { return speed > 0; } - static inline void init() { reset(); } - static inline void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); } + static bool state() { return speed > 0; } + static void init() { reset(); } + static void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); } static void setup(); static void update(); }; diff --git a/Marlin/src/feature/digipot/digipot_mcp4018.cpp b/Marlin/src/feature/digipot/digipot_mcp4018.cpp index 37853ff428bc..3f2ecbfcdc0b 100644 --- a/Marlin/src/feature/digipot/digipot_mcp4018.cpp +++ b/Marlin/src/feature/digipot/digipot_mcp4018.cpp @@ -31,9 +31,13 @@ // Settings for the I2C based DIGIPOT (MCP4018) based on WT150 -#define DIGIPOT_A4988_Rsx 0.250 -#define DIGIPOT_A4988_Vrefmax 1.666 -#define DIGIPOT_MCP4018_MAX_VALUE 127 +#ifndef DIGIPOT_A4988_Rsx + #define DIGIPOT_A4988_Rsx 0.250 +#endif +#ifndef DIGIPOT_A4988_Vrefmax + #define DIGIPOT_A4988_Vrefmax 1.666 +#endif +#define DIGIPOT_MCP4018_MAX_VALUE 127 #define DIGIPOT_A4988_Itripmax(Vref) ((Vref) / (8.0 * DIGIPOT_A4988_Rsx)) diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index b8ef04fcd908..052e79de41e5 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -52,13 +52,13 @@ namespace DirectStepping { volatile bool SerialPageManager::fatal_error; template - volatile PageState SerialPageManager::page_states[Cfg::NUM_PAGES]; + volatile PageState SerialPageManager::page_states[Cfg::PAGE_COUNT]; template volatile bool SerialPageManager::page_states_dirty; template - uint8_t SerialPageManager::pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE]; + uint8_t SerialPageManager::pages[Cfg::PAGE_COUNT][Cfg::PAGE_SIZE]; template uint8_t SerialPageManager::checksum; @@ -74,7 +74,7 @@ namespace DirectStepping { template void SerialPageManager::init() { - for (int i = 0 ; i < Cfg::NUM_PAGES ; i++) + for (int i = 0 ; i < Cfg::PAGE_COUNT ; i++) page_states[i] = PageState::FREE; fatal_error = false; @@ -183,10 +183,10 @@ namespace DirectStepping { SERIAL_CHAR(Cfg::CONTROL_CHAR); constexpr int state_bits = 2; - constexpr int n_bytes = Cfg::NUM_PAGES >> state_bits; + constexpr int n_bytes = Cfg::PAGE_COUNT >> state_bits; volatile uint8_t bits_b[n_bytes] = { 0 }; - for (page_idx_t i = 0 ; i < Cfg::NUM_PAGES ; i++) { + for (page_idx_t i = 0 ; i < Cfg::PAGE_COUNT ; i++) { bits_b[i >> state_bits] |= page_states[i] << ((i * state_bits) & 0x7); } diff --git a/Marlin/src/feature/direct_stepping.h b/Marlin/src/feature/direct_stepping.h index b3007731cdb2..962310281edb 100644 --- a/Marlin/src/feature/direct_stepping.h +++ b/Marlin/src/feature/direct_stepping.h @@ -68,10 +68,10 @@ namespace DirectStepping { static State state; static volatile bool fatal_error; - static volatile PageState page_states[Cfg::NUM_PAGES]; + static volatile PageState page_states[Cfg::PAGE_COUNT]; static volatile bool page_states_dirty; - static uint8_t pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE]; + static uint8_t pages[Cfg::PAGE_COUNT][Cfg::PAGE_SIZE]; static uint8_t checksum; static write_byte_idx_t write_byte_idx; static page_idx_t write_page_idx; @@ -87,8 +87,8 @@ namespace DirectStepping { struct config_t { static constexpr char CONTROL_CHAR = '!'; - static constexpr int NUM_PAGES = num_pages; - static constexpr int NUM_AXES = num_axes; + static constexpr int PAGE_COUNT = num_pages; + static constexpr int AXIS_COUNT = num_axes; static constexpr int BITS_SEGMENT = bits_segment; static constexpr int DIRECTIONAL = dir ? 1 : 0; static constexpr int SEGMENTS = segments; @@ -96,10 +96,10 @@ namespace DirectStepping { static constexpr int NUM_SEGMENTS = _BV(BITS_SEGMENT); static constexpr int SEGMENT_STEPS = _BV(BITS_SEGMENT - DIRECTIONAL) - 1; static constexpr int TOTAL_STEPS = SEGMENT_STEPS * SEGMENTS; - static constexpr int PAGE_SIZE = (NUM_AXES * BITS_SEGMENT * SEGMENTS) / 8; + static constexpr int PAGE_SIZE = (AXIS_COUNT * BITS_SEGMENT * SEGMENTS) / 8; typedef typename TypeSelector<(PAGE_SIZE>256), uint16_t, uint8_t>::type write_byte_idx_t; - typedef typename TypeSelector<(NUM_PAGES>256), uint16_t, uint8_t>::type page_idx_t; + typedef typename TypeSelector<(PAGE_COUNT>256), uint16_t, uint8_t>::type page_idx_t; }; template diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index 1dee0cf7550c..fda1ba144bc4 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -41,7 +41,9 @@ extern bool wait_for_user, wait_for_heatup; void quickresume_stepper(); #endif -void HAL_reboot(); +#if ENABLED(SOFT_RESET_VIA_SERIAL) + void HAL_reboot(); +#endif class EmergencyParser { diff --git a/Marlin/src/feature/easythreed_ui.cpp b/Marlin/src/feature/easythreed_ui.cpp new file mode 100644 index 000000000000..b15daffc09be --- /dev/null +++ b/Marlin/src/feature/easythreed_ui.cpp @@ -0,0 +1,236 @@ +/** + * 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 . + * + */ + +#include "../inc/MarlinConfigPre.h" + +#if ENABLED(EASYTHREED_UI) + +#include "easythreed_ui.h" +#include "pause.h" +#include "../module/temperature.h" +#include "../module/printcounter.h" +#include "../sd/cardreader.h" +#include "../gcode/queue.h" +#include "../module/motion.h" +#include "../module/planner.h" +#include "../MarlinCore.h" + +EasythreedUI easythreed_ui; + +#define BTN_DEBOUNCE_MS 20 + +void EasythreedUI::init() { + SET_INPUT_PULLUP(BTN_HOME); SET_OUTPUT(BTN_HOME_GND); + SET_INPUT_PULLUP(BTN_FEED); SET_OUTPUT(BTN_FEED_GND); + SET_INPUT_PULLUP(BTN_RETRACT); SET_OUTPUT(BTN_RETRACT_GND); + SET_INPUT_PULLUP(BTN_PRINT); + SET_OUTPUT(EASYTHREED_LED_PIN); +} + +void EasythreedUI::run() { + blinkLED(); + loadButton(); + printButton(); +} + +enum LEDInterval : uint16_t { + LED_OFF = 0, + LED_ON = 4000, + LED_BLINK_0 = 2500, + LED_BLINK_1 = 1500, + LED_BLINK_2 = 1000, + LED_BLINK_3 = 800, + LED_BLINK_4 = 500, + LED_BLINK_5 = 300, + LED_BLINK_6 = 150, + LED_BLINK_7 = 50 +}; + +uint16_t blink_interval_ms = LED_ON; // Status LED on Start button + +void EasythreedUI::blinkLED() { + static millis_t prev_blink_interval_ms = 0, blink_start_ms = 0; + + if (blink_interval_ms == LED_OFF) { WRITE(EASYTHREED_LED_PIN, HIGH); return; } // OFF + if (blink_interval_ms >= LED_ON) { WRITE(EASYTHREED_LED_PIN, LOW); return; } // ON + + const millis_t ms = millis(); + if (prev_blink_interval_ms != blink_interval_ms) { + prev_blink_interval_ms = blink_interval_ms; + blink_start_ms = ms; + } + if (PENDING(ms, blink_start_ms + blink_interval_ms)) + WRITE(EASYTHREED_LED_PIN, LOW); + else if (PENDING(ms, blink_start_ms + 2 * blink_interval_ms)) + WRITE(EASYTHREED_LED_PIN, HIGH); + else + blink_start_ms = ms; +} + +// +// Filament Load/Unload Button +// Load/Unload buttons are a 3 position switch with a common center ground. +// +void EasythreedUI::loadButton() { + if (printingIsActive()) return; + + enum FilamentStatus : uint8_t { FS_IDLE, FS_PRESS, FS_CHECK, FS_PROCEED }; + static uint8_t filament_status = FS_IDLE; + static millis_t filament_time = 0; + + switch (filament_status) { + + case FS_IDLE: + if (!READ(BTN_RETRACT) || !READ(BTN_FEED)) { // If feed/retract switch is toggled... + filament_status++; // ...proceed to next test. + filament_time = millis(); + } + break; + + case FS_PRESS: + if (ELAPSED(millis(), filament_time + BTN_DEBOUNCE_MS)) { // After a short debounce delay... + if (!READ(BTN_RETRACT) || !READ(BTN_FEED)) { // ...if switch still toggled... + thermalManager.setTargetHotend(EXTRUDE_MINTEMP + 10, 0); // Start heating up + blink_interval_ms = LED_BLINK_7; // Set the LED to blink fast + filament_status++; + } + else + filament_status = FS_IDLE; // Switch not toggled long enough + } + break; + + case FS_CHECK: + if (READ(BTN_RETRACT) && READ(BTN_FEED)) { // Switch in center position (stop) + blink_interval_ms = LED_ON; // LED on steady + filament_status = FS_IDLE; + thermalManager.disable_all_heaters(); + } + else if (thermalManager.hotEnoughToExtrude(0)) { // Is the hotend hot enough to move material? + filament_status++; // Proceed to feed / retract. + blink_interval_ms = LED_BLINK_5; // Blink ~3 times per second + } + break; + + case FS_PROCEED: { + // Feed or Retract just once. Hard abort all moves and return to idle on swicth release. + static bool flag = false; + if (READ(BTN_RETRACT) && READ(BTN_FEED)) { // Switch in center position (stop) + flag = false; // Restore flag to false + filament_status = FS_IDLE; // Go back to idle state + quickstop_stepper(); // Hard-stop all the steppers ... now! + thermalManager.disable_all_heaters(); // And disable all the heaters + blink_interval_ms = LED_ON; + } + else if (!flag) { + flag = true; + queue.inject(!READ(BTN_RETRACT) ? F("G91\nG0 E10 F180\nG0 E-120 F180\nM104 S0") : F("G91\nG0 E100 F120\nM104 S0")); + } + } break; + } + +} + +#if HAS_STEPPER_RESET + void disableStepperDrivers(); +#endif + +// +// Print Start/Pause/Resume Button +// +void EasythreedUI::printButton() { + enum KeyStatus : uint8_t { KS_IDLE, KS_PRESS, KS_PROCEED }; + static uint8_t key_status = KS_IDLE; + static millis_t key_time = 0; + + enum PrintFlag : uint8_t { PF_START, PF_PAUSE, PF_RESUME }; + static PrintFlag print_key_flag = PF_START; + + const millis_t ms = millis(); + + switch (key_status) { + case KS_IDLE: + if (!READ(BTN_PRINT)) { // Print/Pause/Resume button pressed? + key_time = ms; // Save start time + key_status++; // Go to debounce test + } + break; + + case KS_PRESS: + if (ELAPSED(ms, key_time + BTN_DEBOUNCE_MS)) // Wait for debounce interval to expire + key_status = READ(BTN_PRINT) ? KS_IDLE : KS_PROCEED; // Proceed if still pressed + break; + + case KS_PROCEED: + if (!READ(BTN_PRINT)) break; // Wait for the button to be released + key_status = KS_IDLE; // Ready for the next press + if (PENDING(ms, key_time + 1200 - BTN_DEBOUNCE_MS)) { // Register a press < 1.2 seconds + switch (print_key_flag) { + case PF_START: { // The "Print" button starts an SD card print + if (printingIsActive()) break; // Already printing? (find another line that checks for 'is planner doing anything else right now?') + blink_interval_ms = LED_BLINK_2; // Blink the indicator LED at 1 second intervals + print_key_flag = PF_PAUSE; // The "Print" button now pauses the print + card.mount(); // Force SD card to mount - now! + if (!card.isMounted) { // Failed to mount? + blink_interval_ms = LED_OFF; // Turn off LED + print_key_flag = PF_START; + return; // Bail out + } + card.ls(); // List all files to serial output + const uint16_t filecnt = card.countFilesInWorkDir(); // Count printable files in cwd + if (filecnt == 0) return; // None are printable? + card.selectFileByIndex(filecnt); // Select the last file according to current sort options + card.openAndPrintFile(card.filename); // Start printing it + break; + } + case PF_PAUSE: { // Pause printing (not currently firing) + if (!printingIsActive()) break; + blink_interval_ms = LED_ON; // Set indicator to steady ON + queue.inject(F("M25")); // Queue Pause + print_key_flag = PF_RESUME; // The "Print" button now resumes the print + break; + } + case PF_RESUME: { // Resume printing + if (printingIsActive()) break; + blink_interval_ms = LED_BLINK_2; // Blink the indicator LED at 1 second intervals + queue.inject(F("M24")); // Queue resume + print_key_flag = PF_PAUSE; // The "Print" button now pauses the print + break; + } + } + } + else { // Register a longer press + if (print_key_flag == PF_START && !printingIsActive()) { // While not printing, this moves Z up 10mm + blink_interval_ms = LED_ON; + queue.inject(F("G91\nG0 Z10 F600\nG90")); // Raise Z soon after returning to main loop + } + else { // While printing, cancel print + card.abortFilePrintSoon(); // There is a delay while the current steps play out + blink_interval_ms = LED_OFF; // Turn off LED + } + planner.synchronize(); // Wait for commands already in the planner to finish + TERN_(HAS_STEPPER_RESET, disableStepperDrivers()); // Disable all steppers - now! + print_key_flag = PF_START; // The "Print" button now starts a new print + } + break; + } +} +#endif // EASYTHREED_UI diff --git a/Marlin/src/feature/easythreed_ui.h b/Marlin/src/feature/easythreed_ui.h new file mode 100644 index 000000000000..af9ad2d090b1 --- /dev/null +++ b/Marlin/src/feature/easythreed_ui.h @@ -0,0 +1,35 @@ +/** + * 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 + +class EasythreedUI { + public: + static void init(); + static void run(); + + private: + static void blinkLED(); + static void loadButton(); + static void printButton(); +}; + +extern EasythreedUI easythreed_ui; diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index 87e611f86c23..2ccd686a992d 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -756,7 +756,7 @@ int8_t I2CPositionEncodersMgr::parse() { if (!parser.has_value()) { SERIAL_ECHOLNPGM("?A seen, but no address specified! [30-200]"); return I2CPE_PARSE_ERR; - }; + } I2CPE_addr = parser.value_byte(); if (!WITHIN(I2CPE_addr, 30, 200)) { // reserve the first 30 and last 55 @@ -775,7 +775,7 @@ int8_t I2CPositionEncodersMgr::parse() { if (!parser.has_value()) { SERIAL_ECHOLNPGM("?I seen, but no index specified! [0-", I2CPE_ENCODER_CNT - 1, "]"); return I2CPE_PARSE_ERR; - }; + } I2CPE_idx = parser.value_byte(); if (I2CPE_idx >= I2CPE_ENCODER_CNT) { @@ -791,7 +791,7 @@ int8_t I2CPositionEncodersMgr::parse() { I2CPE_anyaxis = parser.seen_axis(); return I2CPE_PARSE_OK; -}; +} /** * M860: Report the position(s) of position encoder module(s). @@ -934,7 +934,7 @@ void I2CPositionEncodersMgr::M864() { if (!parser.has_value()) { SERIAL_ECHOLNPGM("?S seen, but no address specified! [30-200]"); return; - }; + } newAddress = parser.value_byte(); if (!WITHIN(newAddress, 30, 200)) { diff --git a/Marlin/src/feature/fancheck.cpp b/Marlin/src/feature/fancheck.cpp new file mode 100644 index 000000000000..1b47fadecc31 --- /dev/null +++ b/Marlin/src/feature/fancheck.cpp @@ -0,0 +1,207 @@ +/** + * 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 . + * + */ + +/** + * fancheck.cpp - fan tachometer check + */ + +#include "../inc/MarlinConfig.h" + +#if HAS_FANCHECK + +#include "fancheck.h" +#include "../module/temperature.h" + +#if HAS_AUTO_FAN && EXTRUDER_AUTO_FAN_SPEED != 255 && DISABLED(FOURWIRES_FANS) + bool FanCheck::measuring = false; +#endif +bool FanCheck::tacho_state[TACHO_COUNT]; +uint16_t FanCheck::edge_counter[TACHO_COUNT]; +uint8_t FanCheck::rps[TACHO_COUNT]; +FanCheck::TachoError FanCheck::error = FanCheck::TachoError::NONE; +bool FanCheck::enabled; + +void FanCheck::init() { + #define _TACHINIT(N) TERN(E##N##_FAN_TACHO_PULLUP, SET_INPUT_PULLUP, TERN(E##N##_FAN_TACHO_PULLDOWN, SET_INPUT_PULLDOWN, SET_INPUT))(E##N##_FAN_TACHO_PIN) + #if HAS_E0_FAN_TACHO + _TACHINIT(0); + #endif + #if HAS_E1_FAN_TACHO + _TACHINIT(1); + #endif + #if HAS_E2_FAN_TACHO + _TACHINIT(2); + #endif + #if HAS_E3_FAN_TACHO + _TACHINIT(3); + #endif + #if HAS_E4_FAN_TACHO + _TACHINIT(4); + #endif + #if HAS_E5_FAN_TACHO + _TACHINIT(5); + #endif + #if HAS_E6_FAN_TACHO + _TACHINIT(6); + #endif + #if HAS_E7_FAN_TACHO + _TACHINIT(7); + #endif +} + +void FanCheck::update_tachometers() { + bool status; + + #define _TACHO_CASE(N) case N: status = READ(E##N##_FAN_TACHO_PIN); break; + LOOP_L_N(f, TACHO_COUNT) { + switch (f) { + #if HAS_E0_FAN_TACHO + _TACHO_CASE(0) + #endif + #if HAS_E1_FAN_TACHO + _TACHO_CASE(1) + #endif + #if HAS_E2_FAN_TACHO + _TACHO_CASE(2) + #endif + #if HAS_E3_FAN_TACHO + _TACHO_CASE(3) + #endif + #if HAS_E4_FAN_TACHO + _TACHO_CASE(4) + #endif + #if HAS_E5_FAN_TACHO + _TACHO_CASE(5) + #endif + #if HAS_E6_FAN_TACHO + _TACHO_CASE(6) + #endif + #if HAS_E7_FAN_TACHO + _TACHO_CASE(7) + #endif + default: continue; + } + + if (status != tacho_state[f]) { + if (measuring) ++edge_counter[f]; + tacho_state[f] = status; + } + } +} + +void FanCheck::compute_speed(uint16_t elapsedTime) { + static uint8_t errors_count[TACHO_COUNT]; + static uint8_t fan_reported_errors_msk = 0; + + uint8_t fan_error_msk = 0; + LOOP_L_N(f, TACHO_COUNT) { + switch (f) { + TERN_(HAS_E0_FAN_TACHO, case 0:) + TERN_(HAS_E1_FAN_TACHO, case 1:) + TERN_(HAS_E2_FAN_TACHO, case 2:) + TERN_(HAS_E3_FAN_TACHO, case 3:) + TERN_(HAS_E4_FAN_TACHO, case 4:) + TERN_(HAS_E5_FAN_TACHO, case 5:) + TERN_(HAS_E6_FAN_TACHO, case 6:) + TERN_(HAS_E7_FAN_TACHO, case 7:) + // Compute fan speed + rps[f] = edge_counter[f] * float(250) / elapsedTime; + edge_counter[f] = 0; + + // Check fan speed + constexpr int8_t max_extruder_fan_errors = TERN(HAS_PWMFANCHECK, 10000, 5000) / Temperature::fan_update_interval_ms; + + if (rps[f] >= 20 || TERN0(HAS_AUTO_FAN, thermalManager.autofan_speed[f] == 0)) + errors_count[f] = 0; + else if (errors_count[f] < max_extruder_fan_errors) + ++errors_count[f]; + else if (enabled) + SBI(fan_error_msk, f); + break; + } + } + + // Drop the error when all fans are ok + if (!fan_error_msk && error == TachoError::REPORTED) error = TachoError::FIXED; + + if (error == TachoError::FIXED && !printJobOngoing() && !printingIsPaused()) { + error = TachoError::NONE; // if the issue has been fixed while the printer is idle, reenable immediately + ui.reset_alert_level(); + } + + if (fan_error_msk & ~fan_reported_errors_msk) { + // Handle new faults only + LOOP_L_N(f, TACHO_COUNT) if (TEST(fan_error_msk, f)) report_speed_error(f); + } + fan_reported_errors_msk = fan_error_msk; +} + +void FanCheck::report_speed_error(uint8_t fan) { + if (printJobOngoing()) { + if (error == TachoError::NONE) { + if (thermalManager.degTargetHotend(fan) != 0) { + kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT)); + error = TachoError::REPORTED; + } + else + error = TachoError::DETECTED; // Plans error for next processed command + } + } + else if (!printingIsPaused()) { + thermalManager.setTargetHotend(0, fan); // Always disable heating + if (error == TachoError::NONE) error = TachoError::REPORTED; + } + + SERIAL_ERROR_MSG(STR_ERR_FANSPEED, fan); + LCD_ALERTMESSAGE(MSG_FAN_SPEED_FAULT); +} + +void FanCheck::print_fan_states() { + LOOP_L_N(s, 2) { + LOOP_L_N(f, TACHO_COUNT) { + switch (f) { + TERN_(HAS_E0_FAN_TACHO, case 0:) + TERN_(HAS_E1_FAN_TACHO, case 1:) + TERN_(HAS_E2_FAN_TACHO, case 2:) + TERN_(HAS_E3_FAN_TACHO, case 3:) + TERN_(HAS_E4_FAN_TACHO, case 4:) + TERN_(HAS_E5_FAN_TACHO, case 5:) + TERN_(HAS_E6_FAN_TACHO, case 6:) + TERN_(HAS_E7_FAN_TACHO, case 7:) + SERIAL_ECHOPGM("E", f); + if (s == 0) + SERIAL_ECHOPGM(":", 60 * rps[f], " RPM "); + else + SERIAL_ECHOPGM("@:", TERN(HAS_AUTO_FAN, thermalManager.autofan_speed[f], 255), " "); + break; + } + } + } + SERIAL_EOL(); +} + +#if ENABLED(AUTO_REPORT_FANS) + AutoReporter FanCheck::auto_reporter; + void FanCheck::AutoReportFan::report() { print_fan_states(); } +#endif + +#endif // HAS_FANCHECK diff --git a/Marlin/src/feature/fancheck.h b/Marlin/src/feature/fancheck.h new file mode 100644 index 000000000000..c8665a0e96e8 --- /dev/null +++ b/Marlin/src/feature/fancheck.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 + +#include "../inc/MarlinConfig.h" + +#if HAS_FANCHECK + +#include "../MarlinCore.h" +#include "../lcd/marlinui.h" + +#if ENABLED(AUTO_REPORT_FANS) + #include "../libs/autoreport.h" +#endif + +#if ENABLED(PARK_HEAD_ON_PAUSE) + #include "../gcode/queue.h" +#endif + +/** + * fancheck.h + */ +#define TACHO_COUNT TERN(HAS_E7_FAN_TACHO, 8, TERN(HAS_E6_FAN_TACHO, 7, TERN(HAS_E5_FAN_TACHO, 6, TERN(HAS_E4_FAN_TACHO, 5, TERN(HAS_E3_FAN_TACHO, 4, TERN(HAS_E2_FAN_TACHO, 3, TERN(HAS_E1_FAN_TACHO, 2, 1))))))) + +class FanCheck { + private: + + enum class TachoError : uint8_t { NONE, DETECTED, REPORTED, FIXED }; + + #if HAS_PWMFANCHECK + static bool measuring; // For future use (3 wires PWM controlled fans) + #else + static constexpr bool measuring = true; + #endif + static bool tacho_state[TACHO_COUNT]; + static uint16_t edge_counter[TACHO_COUNT]; + static uint8_t rps[TACHO_COUNT]; + static TachoError error; + + static void report_speed_error(uint8_t fan); + + public: + + static bool enabled; + + static void init(); + static void update_tachometers(); + static void compute_speed(uint16_t elapsedTime); + static void print_fan_states(); + #if HAS_PWMFANCHECK + static void toggle_measuring() { measuring = !measuring; } + static bool is_measuring() { return measuring; } + #endif + + static void check_deferred_error() { + if (error == TachoError::DETECTED) { + error = TachoError::REPORTED; + TERN(PARK_HEAD_ON_PAUSE, queue.inject(F("M125")), kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT))); + } + } + + #if ENABLED(AUTO_REPORT_FANS) + struct AutoReportFan { static void report(); }; + static AutoReporter auto_reporter; + #endif +}; + +extern FanCheck fan_check; + +#endif // HAS_FANCHECK diff --git a/Marlin/src/feature/filwidth.h b/Marlin/src/feature/filwidth.h index e63d3d719ffb..e234380e981a 100644 --- a/Marlin/src/feature/filwidth.h +++ b/Marlin/src/feature/filwidth.h @@ -41,9 +41,9 @@ class FilamentWidthSensor { FilamentWidthSensor() { init(); } static void init(); - static inline void enable(const bool ena) { enabled = ena; } + static void enable(const bool ena) { enabled = ena; } - static inline void set_delay_cm(const uint8_t cm) { + static void set_delay_cm(const uint8_t cm) { meas_delay_cm = _MIN(cm, MAX_MEASUREMENT_DELAY); } @@ -67,18 +67,18 @@ class FilamentWidthSensor { } // Convert raw measurement to mm - static inline float raw_to_mm(const uint16_t v) { return v * 5.0f * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } - static inline float raw_to_mm() { return raw_to_mm(raw); } + static float raw_to_mm(const uint16_t v) { return v * 5.0f * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } + static float raw_to_mm() { return raw_to_mm(raw); } // A scaled reading is ready // Divide to get to 0-16384 range since we used 1/128 IIR filter approach - static inline void reading_ready() { raw = accum >> 10; } + static void reading_ready() { raw = accum >> 10; } // Update mm from the raw measurement - static inline void update_measured_mm() { measured_mm = raw_to_mm(); } + static void update_measured_mm() { measured_mm = raw_to_mm(); } // Update ring buffer used to delay filament measurements - static inline void advance_e(const_float_t e_move) { + static void advance_e(const_float_t e_move) { // Increment counters with the E distance e_count += e_move; @@ -106,7 +106,7 @@ class FilamentWidthSensor { } // Dynamically set the volumetric multiplier based on the delayed width measurement. - static inline void update_volumetric() { + static void update_volumetric() { if (enabled) { int8_t read_index = index_r - meas_delay_cm; if (read_index < 0) read_index += MMD_CM; // Loop around buffer if needed diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index be7b055b55f7..c03a6bc5976e 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -39,10 +39,7 @@ HostUI hostui; -flag_t HostUI::flag; - void HostUI::action(FSTR_P const fstr, const bool eol) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); SERIAL_ECHOPGM("//action:"); SERIAL_ECHOF(fstr); @@ -96,21 +93,18 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { #endif void HostUI::notify(const char * const cstr) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("notification "), false); SERIAL_ECHOLN(cstr); } void HostUI::notify_P(PGM_P const pstr) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("notification "), false); SERIAL_ECHOLNPGM_P(pstr); } void HostUI::prompt(FSTR_P const ptype, const bool eol/*=true*/) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("prompt_"), false); SERIAL_ECHOF(ptype); @@ -118,7 +112,6 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { } void HostUI::prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char/*='\0'*/) { - if (!flag.bits) return; prompt(ptype, false); PORT_REDIRECT(SerialMask::All); SERIAL_CHAR(' '); @@ -127,7 +120,6 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { SERIAL_EOL(); } void HostUI::prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) { - if (!flag.bits) return; prompt_end(); host_prompt_reason = reason; prompt_plus(F("begin"), fstr, extra_char); diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index 45379afc29ec..41d66b82ec9b 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -24,11 +24,6 @@ #include "../inc/MarlinConfigPre.h" #include "../HAL/shared/Marduino.h" -typedef union { - uint8_t bits; - struct { bool info:1, errors:1, debug:1; }; -} flag_t; - #if ENABLED(HOST_PROMPT_SUPPORT) enum PromptReason : uint8_t { @@ -45,9 +40,6 @@ typedef union { class HostUI { public: - static flag_t flag; - HostUI() { flag.bits = 0xFF; } - static void action(FSTR_P const fstr, const bool eol=true); #ifdef ACTION_ON_KILL @@ -97,7 +89,7 @@ class HostUI { static void handle_response(const uint8_t response); static void notify_P(PGM_P const message); - static inline void notify(FSTR_P const fmsg) { notify_P(FTOP(fmsg)); } + static void notify(FSTR_P const fmsg) { notify_P(FTOP(fmsg)); } static void notify(const char * const message); static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0'); @@ -105,7 +97,7 @@ class HostUI { static void prompt_end(); static void prompt_do(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); - static inline void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) { + static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) { if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2); } diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index 7f91c1549b9e..c68a2b8df90a 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -68,13 +68,13 @@ Joystick joystick; void Joystick::report() { SERIAL_ECHOPGM("Joystick"); #if HAS_JOY_ADC_X - SERIAL_ECHOPGM_P(SP_X_STR, JOY_X(x.raw)); + SERIAL_ECHOPGM_P(SP_X_STR, JOY_X(x.getraw())); #endif #if HAS_JOY_ADC_Y - SERIAL_ECHOPGM_P(SP_Y_STR, JOY_Y(y.raw)); + SERIAL_ECHOPGM_P(SP_Y_STR, JOY_Y(y.getraw())); #endif #if HAS_JOY_ADC_Z - SERIAL_ECHOPGM_P(SP_Z_STR, JOY_Z(z.raw)); + SERIAL_ECHOPGM_P(SP_Z_STR, JOY_Z(z.getraw())); #endif #if HAS_JOY_ADC_EN SERIAL_ECHO_TERNARY(READ(JOY_EN_PIN), " EN=", "HIGH (dis", "LOW (en", "abled)"); @@ -91,29 +91,29 @@ Joystick joystick; if (READ(JOY_EN_PIN)) return; #endif - auto _normalize_joy = [](float &axis_jog, const int16_t raw, const int16_t (&joy_limits)[4]) { + auto _normalize_joy = [](float &axis_jog, const raw_adc_t raw, const raw_adc_t (&joy_limits)[4]) { if (WITHIN(raw, joy_limits[0], joy_limits[3])) { // within limits, check deadzone if (raw > joy_limits[2]) axis_jog = (raw - joy_limits[2]) / float(joy_limits[3] - joy_limits[2]); else if (raw < joy_limits[1]) - axis_jog = (raw - joy_limits[1]) / float(joy_limits[1] - joy_limits[0]); // negative value + axis_jog = int16_t(raw - joy_limits[1]) / float(joy_limits[1] - joy_limits[0]); // negative value // Map normal to jog value via quadratic relationship axis_jog = SIGN(axis_jog) * sq(axis_jog); } }; #if HAS_JOY_ADC_X - static constexpr int16_t joy_x_limits[4] = JOY_X_LIMITS; - _normalize_joy(norm_jog.x, JOY_X(x.raw), joy_x_limits); + static constexpr raw_adc_t joy_x_limits[4] = JOY_X_LIMITS; + _normalize_joy(norm_jog.x, JOY_X(x.getraw()), joy_x_limits); #endif #if HAS_JOY_ADC_Y - static constexpr int16_t joy_y_limits[4] = JOY_Y_LIMITS; - _normalize_joy(norm_jog.y, JOY_Y(y.raw), joy_y_limits); + static constexpr raw_adc_t joy_y_limits[4] = JOY_Y_LIMITS; + _normalize_joy(norm_jog.y, JOY_Y(y.getraw()), joy_y_limits); #endif #if HAS_JOY_ADC_Z - static constexpr int16_t joy_z_limits[4] = JOY_Z_LIMITS; - _normalize_joy(norm_jog.z, JOY_Z(z.raw), joy_z_limits); + static constexpr raw_adc_t joy_z_limits[4] = JOY_Z_LIMITS; + _normalize_joy(norm_jog.z, JOY_Z(z.getraw()), joy_z_limits); #endif } diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 17d790b8cc9a..2a53a7c884e6 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -42,7 +42,7 @@ #include "pca9533.h" #endif -#if ENABLED(CASE_LIGHT_USE_RGB_LED) +#if EITHER(CASE_LIGHT_USE_RGB_LED, CASE_LIGHT_USE_NEOPIXEL) #include "../../feature/caselight.h" #endif @@ -95,6 +95,10 @@ void LEDLights::set_color(const LEDColor &incol #endif #endif + #if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + // Update brightness only if caselight is ON or switching leds off + if (caselight.on || incol.is_off()) + #endif neo.set_brightness(incol.i); #if ENABLED(NEOPIXEL_IS_SEQUENTIAL) @@ -106,6 +110,10 @@ void LEDLights::set_color(const LEDColor &incol } #endif + #if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + // Update color only if caselight is ON or switching leds off + if (caselight.on || incol.is_off()) + #endif neo.set_color(neocolor); #endif @@ -121,11 +129,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)) \ - set_pwm_duty(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)) \ + hal.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); @@ -150,7 +158,7 @@ void LEDLights::set_color(const LEDColor &incol void LEDLights::toggle() { if (lights_on) set_off(); else update(); } #endif -#ifdef LED_BACKLIGHT_TIMEOUT +#if LED_POWEROFF_TIMEOUT > 0 millis_t LEDLights::led_off_time; // = 0 diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 74964b51a8e4..bce9052424a8 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -118,7 +118,7 @@ class LEDLights { OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false) ); - static inline void set_color(uint8_t r, uint8_t g, uint8_t b + static void set_color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false) @@ -126,23 +126,23 @@ class LEDLights { set_color(LEDColor(r, g, b OPTARG(HAS_WHITE_LED, w) OPTARG(NEOPIXEL_LED, i)) OPTARG(NEOPIXEL_IS_SEQUENTIAL, isSequence)); } - static inline void set_off() { set_color(LEDColorOff()); } - static inline void set_green() { set_color(LEDColorGreen()); } - static inline void set_white() { set_color(LEDColorWhite()); } + static void set_off() { set_color(LEDColorOff()); } + static void set_green() { set_color(LEDColorGreen()); } + static void set_white() { set_color(LEDColorWhite()); } #if ENABLED(LED_COLOR_PRESETS) static const LEDColor defaultLEDColor; - static inline void set_default() { set_color(defaultLEDColor); } - static inline void set_red() { set_color(LEDColorRed()); } - static inline void set_orange() { set_color(LEDColorOrange()); } - static inline void set_yellow() { set_color(LEDColorYellow()); } - static inline void set_blue() { set_color(LEDColorBlue()); } - static inline void set_indigo() { set_color(LEDColorIndigo()); } - static inline void set_violet() { set_color(LEDColorViolet()); } + static void set_default() { set_color(defaultLEDColor); } + static void set_red() { set_color(LEDColorRed()); } + static void set_orange() { set_color(LEDColorOrange()); } + static void set_yellow() { set_color(LEDColorYellow()); } + static void set_blue() { set_color(LEDColorBlue()); } + static void set_indigo() { set_color(LEDColorIndigo()); } + static void set_violet() { set_color(LEDColorViolet()); } #endif #if ENABLED(PRINTER_EVENT_LEDS) - static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); } + static LEDColor get_color() { return lights_on ? color : LEDColorOff(); } #endif #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) @@ -154,15 +154,15 @@ class LEDLights { static void toggle(); // swap "off" with color #endif #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) - static inline void update() { set_color(color); } + static void update() { set_color(color); } #endif - #ifdef LED_BACKLIGHT_TIMEOUT + #if LED_POWEROFF_TIMEOUT > 0 private: static millis_t led_off_time; public: - static inline void reset_timeout(const millis_t &ms) { - led_off_time = ms + LED_BACKLIGHT_TIMEOUT; + static void reset_timeout(const millis_t &ms) { + led_off_time = ms + LED_POWEROFF_TIMEOUT; if (!lights_on) update(); } static void update_timeout(const bool power_on); @@ -181,7 +181,7 @@ extern LEDLights leds; static void set_color(const LEDColor &color); - static inline void set_color(uint8_t r, uint8_t g, uint8_t b + static void set_color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) ) { @@ -191,26 +191,26 @@ extern LEDLights leds; )); } - static inline void set_off() { set_color(LEDColorOff()); } - static inline void set_green() { set_color(LEDColorGreen()); } - static inline void set_white() { set_color(LEDColorWhite()); } + static void set_off() { set_color(LEDColorOff()); } + static void set_green() { set_color(LEDColorGreen()); } + static void set_white() { set_color(LEDColorWhite()); } #if ENABLED(NEO2_COLOR_PRESETS) static const LEDColor defaultLEDColor; - static inline void set_default() { set_color(defaultLEDColor); } - static inline void set_red() { set_color(LEDColorRed()); } - static inline void set_orange() { set_color(LEDColorOrange()); } - static inline void set_yellow() { set_color(LEDColorYellow()); } - static inline void set_blue() { set_color(LEDColorBlue()); } - static inline void set_indigo() { set_color(LEDColorIndigo()); } - static inline void set_violet() { set_color(LEDColorViolet()); } + static void set_default() { set_color(defaultLEDColor); } + static void set_red() { set_color(LEDColorRed()); } + static void set_orange() { set_color(LEDColorOrange()); } + static void set_yellow() { set_color(LEDColorYellow()); } + static void set_blue() { set_color(LEDColorBlue()); } + static void set_indigo() { set_color(LEDColorIndigo()); } + static void set_violet() { set_color(LEDColorViolet()); } #endif #if ENABLED(NEOPIXEL2_SEPARATE) static LEDColor color; // last non-off color static bool lights_on; // the last set color was "on" static void toggle(); // swap "off" with color - static inline void update() { set_color(color); } + static void update() { set_color(color); } #endif }; diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 2654e9a1df5a..3569cb180d53 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -35,7 +35,7 @@ #endif Marlin_NeoPixel neo; -int8_t Marlin_NeoPixel::neoindex; +pixel_index_t Marlin_NeoPixel::neoindex; Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); #if CONJOINED_NEOPIXEL @@ -116,7 +116,7 @@ void Marlin_NeoPixel::init() { Marlin_NeoPixel2 neo2; - int8_t Marlin_NeoPixel2::neoindex; + pixel_index_t Marlin_NeoPixel2::neoindex; Adafruit_NeoPixel Marlin_NeoPixel2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); void Marlin_NeoPixel2::set_color(const uint32_t color) { diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index b2c16459f504..1a38ed1a196d 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -63,7 +63,13 @@ #endif // ------------------------ -// Function prototypes +// Types +// ------------------------ + +typedef IF<(TERN0(NEOPIXEL_LED, NEOPIXEL_PIXELS > 127)), int16_t, int8_t>::type pixel_index_t; + +// ------------------------ +// Classes // ------------------------ class Marlin_NeoPixel { @@ -74,7 +80,7 @@ class Marlin_NeoPixel { #endif public: - static int8_t neoindex; + static pixel_index_t neoindex; static void init(); static void set_color_startup(const uint32_t c); @@ -86,12 +92,12 @@ class Marlin_NeoPixel { static void reset_background_color(); #endif - static inline void begin() { + static void begin() { adaneo1.begin(); TERN_(CONJOINED_NEOPIXEL, adaneo2.begin()); } - static inline void set_pixel_color(const uint16_t n, const uint32_t c) { + static void set_pixel_color(const uint16_t n, const uint32_t c) { #if ENABLED(NEOPIXEL2_INSERIES) if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c); else adaneo1.setPixelColor(n, c); @@ -101,12 +107,12 @@ class Marlin_NeoPixel { #endif } - static inline void set_brightness(const uint8_t b) { + static void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b)); } - static inline void show() { + static void show() { // Some platforms cannot maintain PWM output when NeoPixel disables interrupts for long durations. TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); adaneo1.show(); @@ -122,11 +128,11 @@ class Marlin_NeoPixel { } // Accessors - static inline uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); } + static uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); } - static inline uint8_t brightness() { return adaneo1.getBrightness(); } + static uint8_t brightness() { return adaneo1.getBrightness(); } - static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) { + static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) { return adaneo1.Color(r, g, b OPTARG(HAS_WHITE_LED, w)); } }; @@ -150,25 +156,25 @@ extern Marlin_NeoPixel neo; static Adafruit_NeoPixel adaneo; public: - static int8_t neoindex; + static pixel_index_t neoindex; static void init(); static void set_color_startup(const uint32_t c); static void set_color(const uint32_t c); - static inline void begin() { adaneo.begin(); } - static inline void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } - static inline void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } - static inline void show() { + static void begin() { adaneo.begin(); } + static void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } + static void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } + static void show() { adaneo.show(); adaneo.setPin(NEOPIXEL2_PIN); } // Accessors - static inline uint16_t pixels() { return adaneo.numPixels();} - static inline uint8_t brightness() { return adaneo.getBrightness(); } - static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) { + static uint16_t pixels() { return adaneo.numPixels();} + static uint8_t brightness() { return adaneo.getBrightness(); } + static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) { return adaneo.Color(r, g, b OPTARG(HAS_WHITE_LED2, w)); } }; diff --git a/Marlin/src/feature/leds/printer_event_leds.h b/Marlin/src/feature/leds/printer_event_leds.h index b2201433d821..2a4342e8f55c 100644 --- a/Marlin/src/feature/leds/printer_event_leds.h +++ b/Marlin/src/feature/leds/printer_event_leds.h @@ -36,32 +36,32 @@ class PrinterEventLEDs { static bool leds_off_after_print; #endif - static inline void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); } + static void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); } public: #if HAS_TEMP_HOTEND - static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); } + static LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); } static void onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_HEATED_BED - static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); } + static LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); } static void onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_HEATED_CHAMBER - static inline LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); } + static LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); } static void onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER - static inline void onHeatingDone() { leds.set_white(); } - static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); } + static void onHeatingDone() { leds.set_white(); } + static void onPidTuningDone(LEDColor c) { leds.set_color(c); } #endif #if ENABLED(SDSUPPORT) - static inline void onPrintCompleted() { + static void onPrintCompleted() { leds.set_green(); #if HAS_LEDS_OFF_FLAG leds_off_after_print = true; @@ -71,7 +71,7 @@ class PrinterEventLEDs { #endif } - static inline void onResumeAfterWait() { + static void onResumeAfterWait() { #if HAS_LEDS_OFF_FLAG if (leds_off_after_print) { set_done(); diff --git a/Marlin/src/feature/max7219.h b/Marlin/src/feature/max7219.h index c25fef173060..809bda6d4b35 100644 --- a/Marlin/src/feature/max7219.h +++ b/Marlin/src/feature/max7219.h @@ -88,13 +88,13 @@ class Max7219 { static void send(const uint8_t reg, const uint8_t data); // Refresh all units - static inline void refresh() { for (uint8_t i = 0; i < 8; i++) refresh_line(i); } + static void refresh() { for (uint8_t i = 0; i < 8; i++) refresh_line(i); } // Suspend / resume updates to the LED unit // Use these methods to speed up multiple changes // or to apply updates from interrupt context. - static inline void suspend() { suspended++; } - static inline void resume() { suspended--; suspended |= 0x80; } + static void suspend() { suspended++; } + static void resume() { suspended--; suspended |= 0x80; } // Update a single native line on all units static void refresh_line(const uint8_t line); diff --git a/Marlin/src/feature/mixing.cpp b/Marlin/src/feature/mixing.cpp index 9ebc90127f43..b1a069e3205e 100644 --- a/Marlin/src/feature/mixing.cpp +++ b/Marlin/src/feature/mixing.cpp @@ -63,7 +63,7 @@ void Mixer::normalize(const uint8_t tool_index) { #ifdef MIXER_NORMALIZER_DEBUG SERIAL_ECHOPGM("Mixer: Old relation : [ "); MIXER_STEPPER_LOOP(i) { - SERIAL_ECHO_F(collector[i] / csum, 3); + SERIAL_DECIMAL(collector[i] / csum); SERIAL_CHAR(' '); } SERIAL_ECHOLNPGM("]"); diff --git a/Marlin/src/feature/mixing.h b/Marlin/src/feature/mixing.h index f700c7b65b7d..85d52d69c8f3 100644 --- a/Marlin/src/feature/mixing.h +++ b/Marlin/src/feature/mixing.h @@ -126,7 +126,7 @@ class Mixer { static mixer_perc_t mix[MIXING_STEPPERS]; // Scratch array for the Mix in proportion to 100 - static inline void copy_mix_to_color(mixer_comp_t (&tcolor)[MIXING_STEPPERS]) { + static void copy_mix_to_color(mixer_comp_t (&tcolor)[MIXING_STEPPERS]) { // Scale each component to the largest one in terms of COLOR_A_MASK // So the largest component will be COLOR_A_MASK and the other will be in proportion to it const float scale = (COLOR_A_MASK) * RECIPROCAL(_MAX( @@ -145,7 +145,7 @@ class Mixer { #endif } - static inline void update_mix_from_vtool(const uint8_t j=selected_vtool) { + static void update_mix_from_vtool(const uint8_t j=selected_vtool) { float ctot = 0; MIXER_STEPPER_LOOP(i) ctot += color[j][i]; //MIXER_STEPPER_LOOP(i) mix[i] = 100.0f * color[j][i] / ctot; @@ -165,7 +165,7 @@ class Mixer { #if HAS_DUAL_MIXING // Update the virtual tool from an edited mix - static inline void update_vtool_from_mix() { + static void update_vtool_from_mix() { copy_mix_to_color(color[selected_vtool]); TERN_(GRADIENT_MIX, refresh_gradient()); // MIXER_STEPPER_LOOP(i) collector[i] = mix[i]; @@ -182,7 +182,7 @@ class Mixer { // Update the current mix from the gradient for a given Z static void update_gradient_for_z(const_float_t z); static void update_gradient_for_planner_z(); - static inline void gradient_control(const_float_t z) { + static void gradient_control(const_float_t z) { if (gradient.enabled) { if (z >= gradient.end_z) T(gradient.end_vtool); @@ -191,7 +191,7 @@ class Mixer { } } - static inline void update_mix_from_gradient() { + static void update_mix_from_gradient() { float ctot = 0; MIXER_STEPPER_LOOP(i) ctot += gradient.color[i]; MIXER_STEPPER_LOOP(i) mix[i] = (mixer_perc_t)CEIL(100.0f * gradient.color[i] / ctot); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 2813337c635b..28dea681ef47 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -143,6 +143,8 @@ uint8_t MMU2::get_current_tool() { #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE) #endif +inline void ATTN_BUZZ(const bool two=false) { BUZZ(200, 404); if (two) { BUZZ(10, 0); BUZZ(200, 404); } } + void MMU2::mmu_loop() { switch (state) { @@ -525,7 +527,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -544,7 +546,7 @@ static void mmu2_not_responding() { active_extruder = 0; } #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -613,7 +615,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -633,7 +635,7 @@ static void mmu2_not_responding() { extruder = index; active_extruder = 0; #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -707,7 +709,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -726,7 +728,7 @@ static void mmu2_not_responding() { extruder = index; active_extruder = 0; #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -811,25 +813,21 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { if (turn_off_nozzle && resume_hotend_temp) { thermalManager.setTargetHotend(resume_hotend_temp, active_extruder); LCD_MESSAGE(MSG_HEATING); - BUZZ(200, 40); + ERR_BUZZ(); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(1000); } - if (move_axes && all_axes_homed()) { - LCD_MESSAGE(MSG_MMU2_RESUMING); - BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); + LCD_MESSAGE(MSG_MMU2_RESUMING); + ATTN_BUZZ(true); + if (move_axes && all_axes_homed()) { // Move XY to starting position, then Z do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE)); // Move Z_AXIS to saved position do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); } - else { - BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); - LCD_MESSAGE(MSG_MMU2_RESUMING); - } } } } @@ -898,7 +896,7 @@ void MMU2::load_filament(const uint8_t index) { command(MMU_CMD_L0 + index); manage_response(false, false); - BUZZ(200, 404); + ATTN_BUZZ(); } /** @@ -909,7 +907,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + ATTN_BUZZ(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -924,7 +922,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { extruder = index; active_extruder = 0; load_to_nozzle(); - BUZZ(200, 404); + ATTN_BUZZ(); } return success; } @@ -945,7 +943,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + ATTN_BUZZ(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -961,12 +959,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (recover) { LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); - BUZZ(200, 404); + ATTN_BUZZ(); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover"))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); - BUZZ(200, 404); - BUZZ(200, 404); + ATTN_BUZZ(true); command(MMU_CMD_R0); manage_response(false, false); @@ -979,7 +976,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { set_runout_valid(false); - BUZZ(200, 404); + ATTN_BUZZ(); stepper.disable_extruder(); @@ -994,7 +991,7 @@ bool MMU2::unload() { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + ATTN_BUZZ(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -1005,7 +1002,7 @@ bool MMU2::unload() { command(MMU_CMD_U0); manage_response(false, true); - BUZZ(200, 404); + ATTN_BUZZ(); // no active tool extruder = MMU2_NO_TOOL; diff --git a/Marlin/src/feature/mmu/mmu2.h b/Marlin/src/feature/mmu/mmu2.h index 9574e2217f82..7d3d9ec4df38 100644 --- a/Marlin/src/feature/mmu/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -43,7 +43,7 @@ class MMU2 { static void init(); static void reset(); - static inline bool enabled() { return _enabled; } + static bool enabled() { return _enabled; } static void mmu_loop(); static void tool_change(const uint8_t index); static void tool_change(const char *special); @@ -57,10 +57,10 @@ class MMU2 { static bool eject_filament(const uint8_t index, const bool recover); private: - static inline bool rx_str(FSTR_P fstr); - static inline void tx_str(FSTR_P fstr); - static inline void tx_printf(FSTR_P ffmt, const int argument); - static inline void tx_printf(FSTR_P ffmt, const int argument1, const int argument2); + static bool rx_str(FSTR_P fstr); + static void tx_str(FSTR_P fstr); + static void tx_printf(FSTR_P ffmt, const int argument); + static void tx_printf(FSTR_P ffmt, const int argument1, const int argument2); static void clear_rx_buffer(); static bool rx_ok(); @@ -99,7 +99,7 @@ class MMU2 { static millis_t prev_request, prev_P0_request; static char rx_buffer[MMU_RX_SIZE], tx_buffer[MMU_TX_SIZE]; - static inline void set_runout_valid(const bool valid) { + static void set_runout_valid(const bool valid) { finda_runout_valid = valid; #if HAS_FILAMENT_SENSOR if (valid) runout.reset(); diff --git a/Marlin/src/feature/password/password.cpp b/Marlin/src/feature/password/password.cpp index 4e841c243cf0..1d376cc586cd 100644 --- a/Marlin/src/feature/password/password.cpp +++ b/Marlin/src/feature/password/password.cpp @@ -40,7 +40,7 @@ uint32_t Password::value, Password::value_entry; // void Password::lock_machine() { is_locked = true; - TERN_(HAS_LCD_MENU, authenticate_user(ui.status_screen, screen_password_entry)); + TERN_(HAS_MARLINUI_MENU, authenticate_user(ui.status_screen, screen_password_entry)); } // @@ -55,7 +55,7 @@ void Password::authentication_check() { is_locked = true; SERIAL_ECHOLNPGM(STR_WRONG_PASSWORD); } - TERN_(HAS_LCD_MENU, authentication_done()); + TERN_(HAS_MARLINUI_MENU, authentication_done()); } #endif // PASSWORD_FEATURE diff --git a/Marlin/src/feature/password/password.h b/Marlin/src/feature/password/password.h index 829d222e20b9..208765b21225 100644 --- a/Marlin/src/feature/password/password.h +++ b/Marlin/src/feature/password/password.h @@ -33,7 +33,7 @@ class Password { static void lock_machine(); static void authentication_check(); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU static void access_menu_password(); static void authentication_done(); static void media_gatekeeper(); diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 191c0e4b08ef..636ac32042b6 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -39,6 +39,10 @@ #include "../module/printcounter.h" #include "../module/temperature.h" +#if ENABLED(AUTO_BED_LEVELING_UBL) + #include "bedlevel/bedlevel.h" +#endif + #if ENABLED(FWRETRACT) #include "fwretract.h" #endif @@ -53,8 +57,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif #include "../lcd/marlinui.h" @@ -97,7 +101,7 @@ fil_change_settings_t fc_settings[EXTRUDERS]; #if HAS_BUZZER static void impatient_beep(const int8_t max_beep_count, const bool restart=false) { - if (TERN0(HAS_LCD_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return; + if (TERN0(HAS_MARLINUI_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return; static millis_t next_buzz = 0; static int8_t runout_beep = 0; @@ -277,7 +281,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load // Show "Purge More" / "Resume" menu and wait for reply KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = false; - #if EITHER(HAS_LCD_MENU, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) ui.pause_show_message(PAUSE_MESSAGE_OPTION); // Also sets PAUSE_RESPONSE_WAIT_FOR #else pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; @@ -403,6 +407,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool #endif TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR))); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); // Indicate that the printer is paused ++did_pause_print; @@ -440,7 +445,15 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool // Initial retract before move to filament change position if (retract && thermalManager.hotEnoughToExtrude(active_extruder)) { DEBUG_ECHOLNPGM("... retract:", retract); + + #if ENABLED(AUTO_BED_LEVELING_UBL) + const bool leveling_was_enabled = planner.leveling_active; // save leveling state + set_bed_leveling_enabled(false); // turn off leveling + #endif + unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE); + + TERN_(AUTO_BED_LEVELING_UBL, set_bed_leveling_enabled(leveling_was_enabled)); // restore leveling } // If axes don't need to home then the nozzle can park @@ -537,7 +550,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(GET_TEXT_F(MSG_REHEATING))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATING)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATING)); // Re-enable the heaters if they timed out HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e); @@ -555,7 +568,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_REHEATDONE), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_REHEATDONE))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATDONE)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATDONE)); IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true); @@ -640,9 +653,16 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE); } + #if ENABLED(AUTO_BED_LEVELING_UBL) + const bool leveling_was_enabled = planner.leveling_active; // save leveling state + set_bed_leveling_enabled(false); // turn off leveling + #endif + // Unretract unscaled_e_move(PAUSE_PARK_RETRACT_LENGTH, feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE)); + TERN_(AUTO_BED_LEVELING_UBL, set_bed_leveling_enabled(leveling_was_enabled)); // restore leveling + // Intelligent resuming #if ENABLED(FWRETRACT) // If retracted before goto pause @@ -690,9 +710,9 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HAS_FILAMENT_SENSOR, runout.reset()); - TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); - TERN_(HAS_LCD_MENU, ui.return_to_status()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, HMI_ReturnScreen()); + TERN(DWIN_LCD_PROUI, DWIN_Print_Resume(), ui.reset_status()); + TERN_(HAS_MARLINUI_MENU, ui.return_to_status()); + TERN_(DWIN_LCD_PROUI, HMI_ReturnScreen()); } #endif // ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index d2c45e44a5df..134b1d1b3294 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -73,17 +73,10 @@ extern fil_change_settings_t fc_settings[EXTRUDERS]; extern uint8_t did_pause_print; -#if ENABLED(DUAL_X_CARRIAGE) - #define DXC_PARAMS , const int8_t DXC_ext=-1 - #define DXC_ARGS , const int8_t DXC_ext - #define DXC_PASS , DXC_ext - #define DXC_SAY , " dxc:", int(DXC_ext) -#else - #define DXC_PARAMS - #define DXC_ARGS - #define DXC_PASS - #define DXC_SAY -#endif +#define DXC_PARAMS OPTARG(DUAL_X_CARRIAGE, const int8_t DXC_ext=-1) +#define DXC_ARGS OPTARG(DUAL_X_CARRIAGE, const int8_t DXC_ext) +#define DXC_PASS OPTARG(DUAL_X_CARRIAGE, DXC_ext) +#define DXC_SAY OPTARG(DUAL_X_CARRIAGE, " dxc:", int(DXC_ext)) // Pause the print. If unload_length is set, do a Filament Unload bool pause_print( diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index fabe35b989c7..c2ed169aa809 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -24,10 +24,14 @@ * power.cpp - power control */ -#include "../inc/MarlinConfig.h" +#include "../inc/MarlinConfigPre.h" + +#if EITHER(PSU_CONTROL, AUTO_POWER_CONTROL) #include "power.h" +#include "../module/planner.h" #include "../module/stepper.h" +#include "../module/temperature.h" #include "../MarlinCore.h" #if ENABLED(PS_OFF_SOUND) @@ -38,8 +42,6 @@ #include "../gcode/gcode.h" #endif -#if EITHER(PSU_CONTROL, AUTO_POWER_CONTROL) - Power powerManager; bool Power::psu_on; @@ -75,6 +77,10 @@ void Power::power_on() { if (psu_on) return; + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + cancelAutoPowerOff(); + #endif + OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_STATE); psu_on = true; safe_delay(PSU_POWERUP_DELAY); @@ -89,9 +95,12 @@ void Power::power_on() { /** * Power off if the power is currently on. * Processes any PSU_POWEROFF_GCODE and makes a PS_OFF_SOUND if enabled. - * */ void Power::power_off() { + SERIAL_ECHOLNPGM(STR_POWEROFF); + + TERN_(HAS_SUICIDE, suicide()); + if (!psu_on) return; #ifdef PSU_POWEROFF_GCODE @@ -104,8 +113,57 @@ void Power::power_off() { OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_STATE); psu_on = false; + + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + cancelAutoPowerOff(); + #endif } +#if EITHER(AUTO_POWER_CONTROL, POWER_OFF_WAIT_FOR_COOLDOWN) + + bool Power::is_cooling_needed() { + #if HAS_HOTEND && AUTO_POWER_E_TEMP + HOTEND_LOOP() if (thermalManager.degHotend(e) >= (AUTO_POWER_E_TEMP)) return true; + #endif + + #if HAS_HEATED_CHAMBER && AUTO_POWER_CHAMBER_TEMP + if (thermalManager.degChamber() >= (AUTO_POWER_CHAMBER_TEMP)) return true; + #endif + + #if HAS_COOLER && AUTO_POWER_COOLER_TEMP + if (thermalManager.degCooler() >= (AUTO_POWER_COOLER_TEMP)) return true; + #endif + + return false; + } + +#endif + +#if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + + #if ENABLED(POWER_OFF_TIMER) + millis_t Power::power_off_time = 0; + void Power::setPowerOffTimer(const millis_t delay_ms) { power_off_time = millis() + delay_ms; } + #endif + + #if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + bool Power::power_off_on_cooldown = false; + void Power::setPowerOffOnCooldown(const bool ena) { power_off_on_cooldown = ena; } + #endif + + void Power::cancelAutoPowerOff() { + TERN_(POWER_OFF_TIMER, power_off_time = 0); + TERN_(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown = false); + } + + void Power::checkAutoPowerOff() { + if (TERN1(POWER_OFF_TIMER, !power_off_time) && TERN1(POWER_OFF_WAIT_FOR_COOLDOWN, !power_off_on_cooldown)) return; + if (TERN0(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown && is_cooling_needed())) return; + if (TERN0(POWER_OFF_TIMER, power_off_time && PENDING(millis(), power_off_time))) return; + power_off(); + } + +#endif // POWER_OFF_TIMER || POWER_OFF_WAIT_FOR_COOLDOWN #if ENABLED(AUTO_POWER_CONTROL) @@ -149,19 +207,7 @@ void Power::power_off() { if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0 || thermalManager.temp_bed.soft_pwm_amount > 0)) return true; - #if HAS_HOTEND && AUTO_POWER_E_TEMP - HOTEND_LOOP() if (thermalManager.degHotend(e) >= (AUTO_POWER_E_TEMP)) return true; - #endif - - #if HAS_HEATED_CHAMBER && AUTO_POWER_CHAMBER_TEMP - if (thermalManager.degChamber() >= (AUTO_POWER_CHAMBER_TEMP)) return true; - #endif - - #if HAS_COOLER && AUTO_POWER_COOLER_TEMP - if (thermalManager.degCooler() >= (AUTO_POWER_COOLER_TEMP)) return true; - #endif - - return false; + return is_cooling_needed(); } /** @@ -193,7 +239,6 @@ void Power::power_off() { /** * Power off with a delay. Power off is triggered by check() after the delay. - * */ void Power::power_off_soon() { lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY); diff --git a/Marlin/src/feature/power.h b/Marlin/src/feature/power.h index 7f5a97e6df83..839366ca602b 100644 --- a/Marlin/src/feature/power.h +++ b/Marlin/src/feature/power.h @@ -25,7 +25,7 @@ * power.h - power control */ -#if ENABLED(AUTO_POWER_CONTROL) +#if EITHER(AUTO_POWER_CONTROL, POWER_OFF_TIMER) #include "../core/millis_t.h" #endif @@ -37,20 +37,36 @@ class Power { static void power_on(); static void power_off(); - #if ENABLED(AUTO_POWER_CONTROL) && POWER_OFF_DELAY > 0 - static void power_off_soon(); - #else - static inline void power_off_soon() { power_off(); } - #endif + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + #if ENABLED(POWER_OFF_TIMER) + static millis_t power_off_time; + static void setPowerOffTimer(const millis_t delay_ms); + #endif + #if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + static bool power_off_on_cooldown; + static void setPowerOffOnCooldown(const bool ena); + #endif + static void cancelAutoPowerOff(); + static void checkAutoPowerOff(); + #endif - #if ENABLED(AUTO_POWER_CONTROL) - static void check(const bool pause); + #if ENABLED(AUTO_POWER_CONTROL) && POWER_OFF_DELAY > 0 + static void power_off_soon(); + #else + static void power_off_soon() { power_off(); } + #endif - private: - static millis_t lastPowerOn; - static bool is_power_needed(); + #if ENABLED(AUTO_POWER_CONTROL) + static void check(const bool pause); - #endif + private: + static millis_t lastPowerOn; + static bool is_power_needed(); + static bool is_cooling_needed(); + #elif ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + private: + static bool is_cooling_needed(); + #endif }; extern Power powerManager; diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 1937a54102a8..504f1ea48e3b 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -26,7 +26,7 @@ #include "power_monitor.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../lcd/marlinui.h" #include "../lcd/lcdprint.h" #endif diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 723ec1903bc8..214c248d359c 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -54,6 +54,10 @@ uint32_t PrintJobRecovery::cmd_sdpos, // = 0 #include "../module/temperature.h" #include "../core/serial.h" +#if HOMING_Z_WITH_PROBE + #include "../module/probe.h" +#endif + #if ENABLED(FWRETRACT) #include "fwretract.h" #endif @@ -178,7 +182,8 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW info.valid_foot = info.valid_head; // Machine state - info.current_position = current_position; + // info.sdpos and info.current_position are pre-filled from the Stepper ISR + info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s)); info.zraise = zraise; info.flag.raised = raised; // Was Z raised before power-off? @@ -265,6 +270,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW #endif +#endif // POWER_LOSS_PIN + +#if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY) + /** * An outage was detected by a sensor pin. * - If not SD printing, let the machine turn off on its own with no "KILL" screen @@ -273,7 +282,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW * - If backup power is available Retract E and Raise Z * - Go to the KILL screen */ - void PrintJobRecovery::_outage() { + void PrintJobRecovery::_outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated/*=false*/)) { #if ENABLED(BACKUP_POWER_SUPPLY) static bool lock = false; if (lock) return; // No re-entrance from idle() during retract_and_lift() @@ -301,10 +310,16 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW retract_and_lift(zraise); #endif - kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); + if (TERN0(DEBUG_POWER_LOSS_RECOVERY, simulated)) { + card.fileHasFinished(); + current_position.reset(); + sync_plan_position(); + } + else + kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); } -#endif +#endif // POWER_LOSS_PIN || DEBUG_POWER_LOSS_RECOVERY /** * Save the recovery info the recovery file @@ -390,14 +405,12 @@ void PrintJobRecovery::resume() { #if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS) #define HOMING_Z_DOWN 1 - #else - #define HOME_XY_ONLY 1 #endif float z_now = info.flag.raised ? z_raised : z_print; - // Reset E to 0 and set Z to the real position - #if HOME_XY_ONLY + #if !HOMING_Z_DOWN + // Set Z to the real position sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 3, str_1)); gcode.process_subcommands_now(cmd); #endif @@ -409,15 +422,15 @@ void PrintJobRecovery::resume() { gcode.process_subcommands_now(cmd); } - // Home XY with no Z raise, and also home Z here if Z isn't homing down below. - gcode.process_subcommands_now(F("G28R0" TERN_(HOME_XY_ONLY, "XY"))); // No raise during G28 + // Home XY with no Z raise + gcode.process_subcommands_now(F("G28R0XY")); // No raise during G28 #endif #if HOMING_Z_DOWN // Move to a safe XY position and home Z while avoiding the print. - constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS; - sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2)); + const xy_pos_t p = xy_pos_t(POWER_LOSS_ZHOME_POS) TERN_(HOMING_Z_WITH_PROBE, - probe.offset_xy); + sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28HZ"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2)); gcode.process_subcommands_now(cmd); #endif @@ -431,7 +444,7 @@ void PrintJobRecovery::resume() { sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1)); gcode.process_subcommands_now(cmd); - #if HOME_XY_ONLY + #if !HOMING_Z_DOWN // The physical Z was adjusted at power-off so undo the M420S1 correction to Z with G92.9. sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 1, str_1)); gcode.process_subcommands_now(cmd); @@ -513,12 +526,12 @@ void PrintJobRecovery::resume() { // Un-retract if there was a retract at outage #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0 - gcode.process_subcommands_now(F("G1E" STRINGIFY(POWER_LOSS_RETRACT_LEN) "F3000")); + gcode.process_subcommands_now(F("G1F3000E" STRINGIFY(POWER_LOSS_RETRACT_LEN))); #endif // Additional purge on resume if configured #if POWER_LOSS_PURGE_LEN - sprintf_P(cmd, PSTR("G1 E%d F3000"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN)); + sprintf_P(cmd, PSTR("G1F3000E%d"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN)); gcode.process_subcommands_now(cmd); #endif diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 76cb398af2a1..4e97109bb7b9 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -152,7 +152,7 @@ class PrintJobRecovery { static void init(); static void prepare(); - static inline void setup() { + static void setup() { #if PIN_EXISTS(POWER_LOSS) #if ENABLED(POWER_LOSS_PULLUP) SET_INPUT_PULLUP(POWER_LOSS_PIN); @@ -165,28 +165,28 @@ class PrintJobRecovery { } // Track each command's file offsets - static inline uint32_t command_sdpos() { return sdpos[queue_index_r]; } - static inline void commit_sdpos(const uint8_t index_w) { sdpos[index_w] = cmd_sdpos; } + static uint32_t command_sdpos() { return sdpos[queue_index_r]; } + static void commit_sdpos(const uint8_t index_w) { sdpos[index_w] = cmd_sdpos; } static bool enabled; static void enable(const bool onoff); static void changed(); - static inline bool exists() { return card.jobRecoverFileExists(); } - static inline void open(const bool read) { card.openJobRecoveryFile(read); } - static inline void close() { file.close(); } + static bool exists() { return card.jobRecoverFileExists(); } + static void open(const bool read) { card.openJobRecoveryFile(read); } + static void close() { file.close(); } static void check(); static void resume(); static void purge(); - static inline void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); } + static void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); } static void load(); static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false); #if PIN_EXISTS(POWER_LOSS) - static inline void outage() { + static void outage() { static constexpr uint8_t OUTAGE_THRESHOLD = 3; static uint8_t outage_counter = 0; if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) { @@ -199,14 +199,14 @@ class PrintJobRecovery { #endif // The referenced file exists - static inline bool interrupted_file_exists() { return card.fileExists(info.sd_filename); } + static bool interrupted_file_exists() { return card.fileExists(info.sd_filename); } - static inline bool valid() { return info.valid() && interrupted_file_exists(); } + static bool valid() { return info.valid() && interrupted_file_exists(); } #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) static void debug(FSTR_P const prefix); #else - static inline void debug(FSTR_P const) {} + static void debug(FSTR_P const) {} #endif private: @@ -216,9 +216,9 @@ class PrintJobRecovery { static void retract_and_lift(const_float_t zraise); #endif - #if PIN_EXISTS(POWER_LOSS) + #if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY) friend class GcodeSuite; - static void _outage(); + static void _outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated=false)); #endif }; diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index 9a975d6763fa..b5f636e698c9 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -28,6 +28,7 @@ #include "probe_temp_comp.h" #include +#include "../module/temperature.h" ProbeTempComp ptc; @@ -62,6 +63,7 @@ constexpr temp_calib_t ProbeTempComp::cali_info[TSI_COUNT]; uint8_t ProbeTempComp::calib_idx; // = 0 float ProbeTempComp::init_measurement; // = 0.0 +bool ProbeTempComp::enabled = true; void ProbeTempComp::reset() { TERN_(PTC_PROBE, LOOP_L_N(i, PTC_PROBE_COUNT) z_offsets_probe[i] = z_offsets_probe_default[i]); @@ -169,6 +171,13 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { return true; } +void ProbeTempComp::apply_compensation(float &meas_z) { + if (!enabled) return; + TERN_(PTC_BED, compensate_measurement(TSI_BED, thermalManager.degBed(), meas_z)); + TERN_(PTC_PROBE, compensate_measurement(TSI_PROBE, thermalManager.degProbe(), meas_z)); + TERN_(PTC_HOTEND, compensate_measurement(TSI_EXT, thermalManager.degHotend(0), meas_z)); +} + 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, diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 4579f2187cd4..42348db68473 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -74,11 +74,10 @@ class ProbeTempComp { 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_index() { calib_idx = 0; }; + static uint8_t get_index() { return calib_idx; } static void reset(); - static void clear_offsets(const TempSensorID tsi); - static inline void clear_all_offsets() { + static void clear_all_offsets() { TERN_(PTC_PROBE, clear_offsets(TSI_PROBE)); TERN_(PTC_BED, clear_offsets(TSI_BED)); TERN_(PTC_HOTEND, clear_offsets(TSI_EXT)); @@ -88,10 +87,16 @@ class ProbeTempComp { static void prepare_new_calibration(const_float_t init_meas_z); static void push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z); static bool finish_calibration(const TempSensorID tsi); - static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z); + static void set_enabled(const bool ena) { enabled = ena; } + + // Apply all temperature compensation adjustments + static void apply_compensation(float &meas_z); private: static uint8_t calib_idx; + static bool enabled; + + static void clear_offsets(const TempSensorID tsi); /** * Base value. Temperature compensation values will be deltas @@ -104,6 +109,8 @@ class ProbeTempComp { * to allow generating values of higher temperatures. */ static bool linear_regression(const TempSensorID tsi, float &k, float &d); + + static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z); }; extern ProbeTempComp ptc; diff --git a/Marlin/src/feature/repeat.h b/Marlin/src/feature/repeat.h index 0f4d9425b768..fc11e4a9e2cf 100644 --- a/Marlin/src/feature/repeat.h +++ b/Marlin/src/feature/repeat.h @@ -38,8 +38,8 @@ class Repeat { static repeat_marker_t marker[MAX_REPEAT_NESTING]; static uint8_t index; public: - static inline void reset() { index = 0; } - static inline bool is_active() { + static void reset() { index = 0; } + static bool is_active() { LOOP_L_N(i, index) if (marker[i].counter) return true; return false; } diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 9317e3489a83..98b6bd051061 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -68,8 +68,8 @@ bool FilamentMonitorBase::enabled = true, #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif void event_filament_runout(const uint8_t extruder) { @@ -88,7 +88,7 @@ void event_filament_runout(const uint8_t extruder) { #endif TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getTool(extruder))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_FilamentRunout(extruder)); + TERN_(DWIN_LCD_PROUI, DWIN_FilamentRunout(extruder)); #if ANY(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS, MULTI_FILAMENT_SENSOR) const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, extruder); diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 8065e515559f..e74d857a79ed 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -83,30 +83,30 @@ class TFilamentMonitor : public FilamentMonitorBase { static sensor_t sensor; public: - static inline void setup() { + static void setup() { sensor.setup(); reset(); } - static inline void reset() { + static void reset() { filament_ran_out = false; response.reset(); } // Call this method when filament is present, // so the response can reset its counter. - static inline void filament_present(const uint8_t extruder) { + static void filament_present(const uint8_t extruder) { response.filament_present(extruder); } #if HAS_FILAMENT_RUNOUT_DISTANCE - static inline float& runout_distance() { return response.runout_distance_mm; } - static inline void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; } + static float& runout_distance() { return response.runout_distance_mm; } + static void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; } #endif // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. - static inline void block_completed(const block_t * const b) { + static void block_completed(const block_t * const b) { if (enabled) { response.block_completed(b); sensor.block_completed(b); @@ -114,7 +114,7 @@ class TFilamentMonitor : public FilamentMonitorBase { } // Give the response a chance to update its counter. - static inline void run() { + static void run() { if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) { TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); @@ -168,12 +168,12 @@ class FilamentSensorBase { * Called by FilamentSensorSwitch::run when filament is detected. * Called by FilamentSensorEncoder::block_completed when motion is detected. */ - static inline void filament_present(const uint8_t extruder) { + static void filament_present(const uint8_t extruder) { runout.filament_present(extruder); // ...which calls response.filament_present(extruder) } public: - static inline void setup() { + static void setup() { #define _INIT_RUNOUT_PIN(P,S,U,D) do{ if (ENABLED(U)) SET_INPUT_PULLUP(P); else if (ENABLED(D)) SET_INPUT_PULLDOWN(P); else SET_INPUT(P); }while(0) #define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULLUP, FIL_RUNOUT##N##_PULLDOWN) #if NUM_RUNOUT_SENSORS >= 1 @@ -205,14 +205,14 @@ class FilamentSensorBase { } // Return a bitmask of runout pin states - static inline uint8_t poll_runout_pins() { + static uint8_t poll_runout_pins() { #define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0) return (0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_RUNOUT)); #undef _OR_RUNOUT } // Return a bitmask of runout flag states (1 bits always indicates runout) - static inline uint8_t poll_runout_states() { + static uint8_t poll_runout_states() { return poll_runout_pins() ^ uint8_t(0 #if NUM_RUNOUT_SENSORS >= 1 | (FIL_RUNOUT1_STATE ? 0 : _BV(1 - 1)) @@ -254,7 +254,7 @@ class FilamentSensorBase { private: static uint8_t motion_detected; - static inline void poll_motion_sensor() { + static void poll_motion_sensor() { static uint8_t old_state; const uint8_t new_state = poll_runout_pins(), change = old_state ^ new_state; @@ -273,7 +273,7 @@ class FilamentSensorBase { } public: - static inline void block_completed(const block_t * const b) { + static void block_completed(const block_t * const b) { // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. if (TEST(motion_detected, b->extruder)) @@ -283,7 +283,7 @@ class FilamentSensorBase { motion_detected = 0; } - static inline void run() { poll_motion_sensor(); } + static void run() { poll_motion_sensor(); } }; #else @@ -294,7 +294,7 @@ class FilamentSensorBase { */ class FilamentSensorSwitch : public FilamentSensorBase { private: - static inline bool poll_runout_state(const uint8_t extruder) { + static bool poll_runout_state(const uint8_t extruder) { const uint8_t runout_states = poll_runout_states(); #if MULTI_FILAMENT_SENSOR if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) @@ -307,9 +307,9 @@ class FilamentSensorBase { } public: - static inline void block_completed(const block_t * const) {} + static void block_completed(const block_t * const) {} - static inline void run() { + static void run() { LOOP_L_N(s, NUM_RUNOUT_SENSORS) { const bool out = poll_runout_state(s); if (!out) filament_present(s); @@ -341,11 +341,11 @@ class FilamentSensorBase { public: static float runout_distance_mm; - static inline void reset() { + static void reset() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); } - static inline void run() { + static void run() { #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) static millis_t t = 0; const millis_t ms = millis(); @@ -358,17 +358,17 @@ class FilamentSensorBase { #endif } - static inline uint8_t has_run_out() { + static uint8_t has_run_out() { uint8_t runout_flags = 0; LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_mm_countdown[i] < 0) SBI(runout_flags, i); return runout_flags; } - static inline void filament_present(const uint8_t extruder) { + static void filament_present(const uint8_t extruder) { runout_mm_countdown[extruder] = runout_distance_mm; } - static inline void block_completed(const block_t * const b) { + static void block_completed(const block_t * const b) { if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. const uint8_t e = b->extruder; @@ -389,23 +389,23 @@ class FilamentSensorBase { static int8_t runout_count[NUM_RUNOUT_SENSORS]; public: - static inline void reset() { + static void reset() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); } - static inline void run() { + static void run() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] >= 0) runout_count[i]--; } - static inline uint8_t has_run_out() { + static uint8_t has_run_out() { uint8_t runout_flags = 0; LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] < 0) SBI(runout_flags, i); return runout_flags; } - static inline void block_completed(const block_t * const) { } + static void block_completed(const block_t * const) { } - static inline void filament_present(const uint8_t extruder) { + static void filament_present(const uint8_t extruder) { runout_count[extruder] = runout_threshold; } }; diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 9297e9b95c8a..52bb471b0f7e 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -62,14 +62,14 @@ void SpindleLaser::init() { OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off #endif #if ENABLED(SPINDLE_CHANGE_DIR) - OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR ? 255 : 0); // Init rotation to clockwise (M3) + OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR); // Init rotation to clockwise (M3) #endif #if ENABLED(SPINDLE_LASER_USE_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); - set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed + hal.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); + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY); #endif #if ENABLED(AIR_EVACUATION) @@ -78,9 +78,7 @@ void SpindleLaser::init() { #if ENABLED(AIR_ASSIST) OUT_WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_ACTIVE); // Init Air Assist OFF #endif - #if ENABLED(I2C_AMMETER) - ammeter.init(); // Init I2C Ammeter - #endif + TERN_(I2C_AMMETER, ammeter.init()); // Init I2C Ammeter } #if ENABLED(SPINDLE_LASER_USE_PWM) @@ -90,10 +88,10 @@ void SpindleLaser::init() { * @param ocr Power value */ 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)); + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY)); #endif - set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); + hal.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/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index ba82c4d7319a..e948d2d37b73 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -41,18 +41,10 @@ #define PCT_TO_PWM(X) ((X) * 255 / 100) #define PCT_TO_SERVO(X) ((X) * 180 / 100) -#ifndef SPEED_POWER_INTERCEPT - #define SPEED_POWER_INTERCEPT 0 -#endif - // #define _MAP(N,S1,S2,D1,D2) ((N)*_MAX((D2)-(D1),0)/_MAX((S2)-(S1),1)+(D1)) class SpindleLaser { public: - static constexpr float - min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), - max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); - static const inline uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); } // cpower = configured values (e.g., SPEED_POWER_MAX) @@ -111,12 +103,12 @@ class SpindleLaser { static void init(); #if ENABLED(MARLIN_DEV_MODE) - static inline void refresh_frequency() { set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } + static void refresh_frequency() { hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } #endif // Modifying this function should update everywhere - static inline bool enabled(const cutter_power_t opwr) { return opwr > 0; } - static inline bool enabled() { return enabled(power); } + static bool enabled(const cutter_power_t opwr) { return opwr > 0; } + static bool enabled() { return enabled(power); } static void apply_power(const uint8_t inpow); @@ -132,13 +124,13 @@ class SpindleLaser { public: static void set_ocr(const uint8_t ocr); - static inline void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); } + static void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); } static void ocr_off(); /** * Update output for power->OCR translation */ - static inline uint8_t upower_to_ocr(const cutter_power_t upwr) { + static uint8_t upower_to_ocr(const cutter_power_t upwr) { return uint8_t( #if CUTTER_UNIT_IS(PWM255) upwr @@ -153,11 +145,14 @@ class SpindleLaser { /** * Correct power to configured range */ - static inline cutter_power_t power_to_range(const cutter_power_t pwr) { + static cutter_power_t power_to_range(const cutter_power_t pwr) { return power_to_range(pwr, _CUTTER_POWER(CUTTER_POWER_UNIT)); } - static inline cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) { + static cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) { + static constexpr float + min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), + max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); if (pwr <= 0) return 0; cutter_power_t upwr; switch (pwrUnit) { @@ -186,13 +181,14 @@ class SpindleLaser { } return upwr; } + #endif // SPINDLE_LASER_USE_PWM /** * Enable/Disable spindle/laser * @param enable true = enable; false = disable */ - static inline void set_enabled(const bool enable) { + static void set_enabled(const bool enable) { uint8_t value = 0; if (enable) { #if ENABLED(SPINDLE_LASER_USE_PWM) @@ -207,14 +203,14 @@ class SpindleLaser { set_power(value); } - static inline void disable() { isReady = false; set_enabled(false); } + static void disable() { isReady = false; set_enabled(false); } /** * Wait for spindle to spin up or spin down * * @param on true = state to on; false = state to off. */ - static inline void power_delay(const bool on) { + static void power_delay(const bool on) { #if DISABLED(LASER_POWER_INLINE) safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); #endif @@ -224,7 +220,7 @@ class SpindleLaser { static void set_reverse(const bool reverse); static bool is_reverse() { return READ(SPINDLE_DIR_PIN) == SPINDLE_INVERT_DIR; } #else - static inline void set_reverse(const bool) {} + static void set_reverse(const bool) {} static bool is_reverse() { return false; } #endif @@ -232,7 +228,7 @@ class SpindleLaser { static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor - static inline bool air_evac_state() { // Get current state + static bool air_evac_state() { // Get current state return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE); } #endif @@ -241,13 +237,13 @@ class SpindleLaser { static void air_assist_enable(); // Turn on air assist static void air_assist_disable(); // Turn off air assist static void air_assist_toggle(); // Toggle air assist - static inline bool air_assist_state() { // Get current state + static bool air_assist_state() { // Get current state return (READ(AIR_ASSIST_PIN) == AIR_ASSIST_ACTIVE); } #endif - #if HAS_LCD_MENU - static inline void enable_with_dir(const bool reverse) { + #if HAS_MARLINUI_MENU + static void enable_with_dir(const bool reverse) { isReady = true; const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); if (menuPower) @@ -263,7 +259,7 @@ class SpindleLaser { FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } #if ENABLED(SPINDLE_LASER_USE_PWM) - static inline void update_from_mpower() { + static void update_from_mpower() { if (isReady) power = upower_to_ocr(menuPower); unitPower = menuPower; } @@ -275,7 +271,7 @@ class SpindleLaser { * Also fires with any PWM power that was previous set * If not set defaults to 80% power */ - static inline void test_fire_pulse() { + static void test_fire_pulse() { TERN_(USE_BEEPER, buzzer.tone(30, 3000)); enable_forward(); // Turn Laser on (Spindle speak but same funct) delay(testPulse); // Delay for time set by user in pulse ms menu screen. @@ -283,7 +279,7 @@ class SpindleLaser { } #endif - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU #if ENABLED(LASER_POWER_INLINE) /** @@ -292,7 +288,7 @@ class SpindleLaser { */ // Force disengage planner power control - static inline void inline_disable() { + static void inline_disable() { isReady = false; unitPower = 0; planner.laser_inline.status.isPlanned = false; @@ -301,7 +297,7 @@ class SpindleLaser { } // Inline modes of all other functions; all enable planner inline power control - static inline void set_inline_enabled(const bool enable) { + static void set_inline_enabled(const bool enable) { if (enable) inline_power(255); else { @@ -330,10 +326,10 @@ class SpindleLaser { #endif } - static inline void inline_direction(const bool) { /* never */ } + static void inline_direction(const bool) { /* never */ } #if ENABLED(SPINDLE_LASER_USE_PWM) - static inline void inline_ocr_power(const uint8_t ocrpwr) { + static void inline_ocr_power(const uint8_t ocrpwr) { isReady = ocrpwr > 0; planner.laser_inline.status.isEnabled = ocrpwr > 0; planner.laser_inline.power = ocrpwr; @@ -341,7 +337,7 @@ class SpindleLaser { #endif #endif // LASER_POWER_INLINE - static inline void kill() { + static void kill() { TERN_(LASER_POWER_INLINE, inline_disable()); disable(); } diff --git a/Marlin/src/feature/spindle_laser_types.h b/Marlin/src/feature/spindle_laser_types.h index 0075e5481900..d249a20e7531 100644 --- a/Marlin/src/feature/spindle_laser_types.h +++ b/Marlin/src/feature/spindle_laser_types.h @@ -28,12 +28,34 @@ #include "../inc/MarlinConfigPre.h" +#define MSG_CUTTER(M) _MSG_CUTTER(M) + +#ifndef SPEED_POWER_INTERCEPT + #define SPEED_POWER_INTERCEPT 0 +#endif #if ENABLED(SPINDLE_FEATURE) #define _MSG_CUTTER(M) MSG_SPINDLE_##M + #ifndef SPEED_POWER_MIN + #define SPEED_POWER_MIN 5000 + #endif + #ifndef SPEED_POWER_MAX + #define SPEED_POWER_MAX 30000 + #endif + #ifndef SPEED_POWER_STARTUP + #define SPEED_POWER_STARTUP 25000 + #endif #else #define _MSG_CUTTER(M) MSG_LASER_##M + #ifndef SPEED_POWER_MIN + #define SPEED_POWER_MIN 0 + #endif + #ifndef SPEED_POWER_MAX + #define SPEED_POWER_MAX 255 + #endif + #ifndef SPEED_POWER_STARTUP + #define SPEED_POWER_STARTUP 255 + #endif #endif -#define MSG_CUTTER(M) _MSG_CUTTER(M) typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t; diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index 82c10e6e8ec2..c69772bebcaf 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -40,7 +40,7 @@ #endif #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../module/stepper.h" #endif @@ -421,12 +421,10 @@ if (monitor_tmc_driver(stepperI, need_update_error_counters, need_debug_reporting)) step_current_down(stepperI); #endif - #if AXIS_IS_TMC(J) if (monitor_tmc_driver(stepperJ, need_update_error_counters, need_debug_reporting)) step_current_down(stepperJ); #endif - #if AXIS_IS_TMC(K) if (monitor_tmc_driver(stepperK, need_update_error_counters, need_debug_reporting)) step_current_down(stepperK); @@ -472,12 +470,8 @@ void tmc_set_report_interval(const uint16_t update_interval) { if ((report_tmc_status_interval = update_interval)) SERIAL_ECHOLNPGM("axis:pwm_scale" - #if HAS_STEALTHCHOP - "/curr_scale" - #endif - #if HAS_STALLGUARD - "/mech_load" - #endif + TERN_(HAS_STEALTHCHOP, "/curr_scale") + TERN_(HAS_STALLGUARD, "/mech_load") "|flags|warncount" ); } @@ -1184,69 +1178,6 @@ #endif // USE_SENSORLESS -#if HAS_TMC_SPI - #define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) - void tmc_init_cs_pins() { - #if AXIS_HAS_SPI(X) - SET_CS_PIN(X); - #endif - #if AXIS_HAS_SPI(Y) - SET_CS_PIN(Y); - #endif - #if AXIS_HAS_SPI(Z) - SET_CS_PIN(Z); - #endif - #if AXIS_HAS_SPI(X2) - SET_CS_PIN(X2); - #endif - #if AXIS_HAS_SPI(Y2) - SET_CS_PIN(Y2); - #endif - #if AXIS_HAS_SPI(Z2) - SET_CS_PIN(Z2); - #endif - #if AXIS_HAS_SPI(Z3) - SET_CS_PIN(Z3); - #endif - #if AXIS_HAS_SPI(Z4) - SET_CS_PIN(Z4); - #endif - #if AXIS_HAS_SPI(I) - SET_CS_PIN(I); - #endif - #if AXIS_HAS_SPI(J) - SET_CS_PIN(J); - #endif - #if AXIS_HAS_SPI(K) - SET_CS_PIN(K); - #endif - #if AXIS_HAS_SPI(E0) - SET_CS_PIN(E0); - #endif - #if AXIS_HAS_SPI(E1) - SET_CS_PIN(E1); - #endif - #if AXIS_HAS_SPI(E2) - SET_CS_PIN(E2); - #endif - #if AXIS_HAS_SPI(E3) - SET_CS_PIN(E3); - #endif - #if AXIS_HAS_SPI(E4) - SET_CS_PIN(E4); - #endif - #if AXIS_HAS_SPI(E5) - SET_CS_PIN(E5); - #endif - #if AXIS_HAS_SPI(E6) - SET_CS_PIN(E6); - #endif - #if AXIS_HAS_SPI(E7) - SET_CS_PIN(E7); - #endif - } -#endif // HAS_TMC_SPI - template static bool test_connection(TMC &st) { SERIAL_ECHOPGM("Testing "); @@ -1345,3 +1276,66 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) { } #endif // HAS_TRINAMIC_CONFIG + +#if HAS_TMC_SPI + #define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) + void tmc_init_cs_pins() { + #if AXIS_HAS_SPI(X) + SET_CS_PIN(X); + #endif + #if AXIS_HAS_SPI(Y) + SET_CS_PIN(Y); + #endif + #if AXIS_HAS_SPI(Z) + SET_CS_PIN(Z); + #endif + #if AXIS_HAS_SPI(X2) + SET_CS_PIN(X2); + #endif + #if AXIS_HAS_SPI(Y2) + SET_CS_PIN(Y2); + #endif + #if AXIS_HAS_SPI(Z2) + SET_CS_PIN(Z2); + #endif + #if AXIS_HAS_SPI(Z3) + SET_CS_PIN(Z3); + #endif + #if AXIS_HAS_SPI(Z4) + SET_CS_PIN(Z4); + #endif + #if AXIS_HAS_SPI(I) + SET_CS_PIN(I); + #endif + #if AXIS_HAS_SPI(J) + SET_CS_PIN(J); + #endif + #if AXIS_HAS_SPI(K) + SET_CS_PIN(K); + #endif + #if AXIS_HAS_SPI(E0) + SET_CS_PIN(E0); + #endif + #if AXIS_HAS_SPI(E1) + SET_CS_PIN(E1); + #endif + #if AXIS_HAS_SPI(E2) + SET_CS_PIN(E2); + #endif + #if AXIS_HAS_SPI(E3) + SET_CS_PIN(E3); + #endif + #if AXIS_HAS_SPI(E4) + SET_CS_PIN(E4); + #endif + #if AXIS_HAS_SPI(E5) + SET_CS_PIN(E5); + #endif + #if AXIS_HAS_SPI(E6) + SET_CS_PIN(E6); + #endif + #if AXIS_HAS_SPI(E7) + SET_CS_PIN(E7); + #endif + } +#endif // HAS_TMC_SPI diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 1f7d5cf1a543..fc333b09dd99 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -45,6 +45,12 @@ constexpr uint16_t _tmc_thrs(const uint16_t msteps, const uint32_t thrs, const u return 12650000UL * msteps / (256 * thrs * spmm); } +typedef struct { + uint8_t toff; + int8_t hend; + uint8_t hstrt; +} chopper_timing_t; + template class TMCStorage { protected: @@ -58,13 +64,13 @@ class TMCStorage { uint8_t otpw_count = 0, error_count = 0; bool flag_otpw = false; - inline bool getOTPW() { return flag_otpw; } - inline void clear_otpw() { flag_otpw = 0; } + bool getOTPW() { return flag_otpw; } + void clear_otpw() { flag_otpw = 0; } #endif - inline uint16_t getMilliamps() { return val_mA; } + uint16_t getMilliamps() { return val_mA; } - inline void printLabel() { + void printLabel() { SERIAL_CHAR(AXIS_LETTER); if (DRIVER_ID > '0') SERIAL_CHAR(DRIVER_ID); } @@ -91,55 +97,61 @@ class TMCMarlin : public TMC, public TMCStorage { TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t axis_chain_index) : TMC(CS, RS, pinMOSI, pinMISO, pinSCK, axis_chain_index) {} - inline uint16_t rms_current() { return TMC::rms_current(); } - inline void rms_current(uint16_t mA) { + uint16_t rms_current() { return TMC::rms_current(); } + void rms_current(uint16_t mA) { this->val_mA = mA; TMC::rms_current(mA); } - inline void rms_current(const uint16_t mA, const float mult) { + void rms_current(const uint16_t mA, const float mult) { this->val_mA = mA; TMC::rms_current(mA, mult); } - inline uint16_t get_microstep_counter() { return TMC::MSCNT(); } + uint16_t get_microstep_counter() { return TMC::MSCNT(); } #if HAS_STEALTHCHOP - inline bool get_stealthChop() { return this->en_pwm_mode(); } - inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } - inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); } - inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } - inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } + bool get_stealthChop() { return this->en_pwm_mode(); } + bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } + void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); } + void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } + bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } #endif + void set_chopper_times(const chopper_timing_t &ct) { + TMC::toff(ct.toff); + TMC::hysteresis_end(ct.hend); + TMC::hysteresis_start(ct.hstrt); + } + #if ENABLED(HYBRID_THRESHOLD) uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } void set_pwm_thrs(const uint32_t thrs) { TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + TERN_(HAS_MARLINUI_MENU, this->stored.hybrid_thrs = thrs); } #endif #if USE_SENSORLESS - inline int16_t homing_threshold() { return TMC::sgt(); } + int16_t homing_threshold() { return TMC::sgt(); } void homing_threshold(int16_t sgt_val) { sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); TMC::sgt(sgt_val); - TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val); + TERN_(HAS_MARLINUI_MENU, this->stored.homing_thrs = sgt_val); } #if ENABLED(SPI_ENDSTOPS) bool test_stall_status(); #endif #endif - #if HAS_LCD_MENU - inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if HAS_MARLINUI_MENU + void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) - inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } + void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } #endif #if USE_SENSORLESS - inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } + void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } #endif #endif @@ -161,39 +173,45 @@ class TMCMarlin : public TMC220 {} uint16_t rms_current() { return TMC2208Stepper::rms_current(); } - inline void rms_current(const uint16_t mA) { + void rms_current(const uint16_t mA) { this->val_mA = mA; TMC2208Stepper::rms_current(mA); } - inline void rms_current(const uint16_t mA, const float mult) { + void rms_current(const uint16_t mA, const float mult) { this->val_mA = mA; TMC2208Stepper::rms_current(mA, mult); } - inline uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); } + uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); } #if HAS_STEALTHCHOP - inline bool get_stealthChop() { return !this->en_spreadCycle(); } - inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } - inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } - inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } - inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } + bool get_stealthChop() { return !this->en_spreadCycle(); } + bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } + void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } + void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } + bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } #endif + void set_chopper_times(const chopper_timing_t &ct) { + TMC2208Stepper::toff(ct.toff); + TMC2208Stepper::hysteresis_end(ct.hend); + TMC2208Stepper::hysteresis_start(ct.hstrt); + } + #if ENABLED(HYBRID_THRESHOLD) uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } void set_pwm_thrs(const uint32_t thrs) { TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + TERN_(HAS_MARLINUI_MENU, this->stored.hybrid_thrs = thrs); } #endif - #if HAS_LCD_MENU - inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if HAS_MARLINUI_MENU + void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) - inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } + void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } #endif #endif }; @@ -209,50 +227,56 @@ class TMCMarlin : public TMC220 {} uint8_t get_address() { return slave_address; } uint16_t rms_current() { return TMC2209Stepper::rms_current(); } - inline void rms_current(const uint16_t mA) { + void rms_current(const uint16_t mA) { this->val_mA = mA; TMC2209Stepper::rms_current(mA); } - inline void rms_current(const uint16_t mA, const float mult) { + void rms_current(const uint16_t mA, const float mult) { this->val_mA = mA; TMC2209Stepper::rms_current(mA, mult); } - inline uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); } + uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); } #if HAS_STEALTHCHOP - inline bool get_stealthChop() { return !this->en_spreadCycle(); } - inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } - inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } - inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } - inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } + bool get_stealthChop() { return !this->en_spreadCycle(); } + bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } + void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } + void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } + bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } #endif + void set_chopper_times(const chopper_timing_t &ct) { + TMC2209Stepper::toff(ct.toff); + TMC2209Stepper::hysteresis_end(ct.hend); + TMC2209Stepper::hysteresis_start(ct.hstrt); + } + #if ENABLED(HYBRID_THRESHOLD) uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } void set_pwm_thrs(const uint32_t thrs) { TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + TERN_(HAS_MARLINUI_MENU, this->stored.hybrid_thrs = thrs); } #endif #if USE_SENSORLESS - inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); } + int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); } void homing_threshold(int16_t sgt_val) { sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); TMC2209Stepper::SGTHRS(sgt_val); - TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val); + TERN_(HAS_MARLINUI_MENU, this->stored.homing_thrs = sgt_val); } #endif - #if HAS_LCD_MENU - inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if HAS_MARLINUI_MENU + void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) - inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } + void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } #endif #if USE_SENSORLESS - inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } + void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } #endif #endif @@ -269,27 +293,33 @@ class TMCMarlin : public TMC266 TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t) : TMC2660Stepper(CS, RS, pinMOSI, pinMISO, pinSCK) {} - inline uint16_t rms_current() { return TMC2660Stepper::rms_current(); } - inline void rms_current(const uint16_t mA) { + uint16_t rms_current() { return TMC2660Stepper::rms_current(); } + void rms_current(const uint16_t mA) { this->val_mA = mA; TMC2660Stepper::rms_current(mA); } - inline uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); } + uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); } + + void set_chopper_times(const chopper_timing_t &ct) { + TMC2660Stepper::toff(ct.toff); + TMC2660Stepper::hysteresis_end(ct.hend); + TMC2660Stepper::hysteresis_start(ct.hstrt); + } #if USE_SENSORLESS - inline int16_t homing_threshold() { return TMC2660Stepper::sgt(); } + int16_t homing_threshold() { return TMC2660Stepper::sgt(); } void homing_threshold(int16_t sgt_val) { sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); TMC2660Stepper::sgt(sgt_val); - TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val); + TERN_(HAS_MARLINUI_MENU, this->stored.homing_thrs = sgt_val); } #endif - #if HAS_LCD_MENU - inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if HAS_MARLINUI_MENU + void refresh_stepper_current() { rms_current(this->val_mA); } #if USE_SENSORLESS - inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } + void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } #endif #endif @@ -297,43 +327,6 @@ class TMCMarlin : public TMC266 sgt_max = 63; }; -template -void tmc_print_current(TMC &st) { - st.printLabel(); - SERIAL_ECHOLNPGM(" driver current: ", st.getMilliamps()); -} - -#if ENABLED(MONITOR_DRIVER_STATUS) - template - void tmc_report_otpw(TMC &st) { - st.printLabel(); - SERIAL_ECHOPGM(" temperature prewarn triggered: "); - serialprint_truefalse(st.getOTPW()); - SERIAL_EOL(); - } - template - void tmc_clear_otpw(TMC &st) { - st.clear_otpw(); - st.printLabel(); - SERIAL_ECHOLNPGM(" prewarn flag cleared"); - } -#endif -#if ENABLED(HYBRID_THRESHOLD) - template - void tmc_print_pwmthrs(TMC &st) { - st.printLabel(); - SERIAL_ECHOLNPGM(" stealthChop max speed: ", st.get_pwm_thrs()); - } -#endif -#if USE_SENSORLESS - template - void tmc_print_sgt(TMC &st) { - st.printLabel(); - SERIAL_ECHOPGM(" homing sensitivity: "); - SERIAL_PRINTLN(st.homing_threshold(), PrintBase::Dec); - } -#endif - void monitor_tmc_drivers(); void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true)); @@ -389,8 +382,8 @@ void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true)); #endif // USE_SENSORLESS +#endif // HAS_TRINAMIC_CONFIG + #if HAS_TMC_SPI void tmc_init_cs_pins(); #endif - -#endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/feature/twibus.cpp b/Marlin/src/feature/twibus.cpp index e33581676c4a..9aec6b030537 100644 --- a/Marlin/src/feature/twibus.cpp +++ b/Marlin/src/feature/twibus.cpp @@ -34,13 +34,18 @@ TWIBus i2c; TWIBus::TWIBus() { #if I2C_SLAVE_ADDRESS == 0 - Wire.begin( // No address joins the BUS as the master - #if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) - pin_t(I2C_SDA_PIN), pin_t(I2C_SCL_PIN) - #endif - ); + + #if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) + Wire.setSDA(pin_t(I2C_SDA_PIN)); + Wire.setSCL(pin_t(I2C_SCL_PIN)); + #endif + + Wire.begin(); // No address joins the BUS as the master + #else - Wire.begin(I2C_SLAVE_ADDRESS); // Join the bus as a slave + + Wire.begin(I2C_SLAVE_ADDRESS); // Join the bus as a slave + #endif reset(); } @@ -51,9 +56,8 @@ void TWIBus::reset() { } void TWIBus::address(const uint8_t adr) { - if (!WITHIN(adr, 8, 127)) { + if (!WITHIN(adr, 8, 127)) SERIAL_ECHO_MSG("Bad I2C address (8-127)"); - } addr = adr; diff --git a/Marlin/src/feature/twibus.h b/Marlin/src/feature/twibus.h index d2c7270303c7..806e2a147a7d 100644 --- a/Marlin/src/feature/twibus.h +++ b/Marlin/src/feature/twibus.h @@ -244,11 +244,11 @@ class TWIBus { static void debug(FSTR_P const func, char c); static void debug(FSTR_P const func, char adr[]); #else - static inline void debug(FSTR_P const, uint32_t) {} - static inline void debug(FSTR_P const, char) {} - static inline void debug(FSTR_P const, char[]) {} + static void debug(FSTR_P const, uint32_t) {} + static void debug(FSTR_P const, char) {} + static void debug(FSTR_P const, char[]) {} #endif - static inline void debug(FSTR_P const func, uint8_t v) { debug(func, (uint32_t)v); } + static void debug(FSTR_P const func, uint8_t v) { debug(func, (uint32_t)v); } }; extern TWIBus i2c; diff --git a/Marlin/src/feature/x_twist.cpp b/Marlin/src/feature/x_twist.cpp new file mode 100644 index 000000000000..b5ad25cba87d --- /dev/null +++ b/Marlin/src/feature/x_twist.cpp @@ -0,0 +1,67 @@ +/** + * 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 . + * + */ +#include "../inc/MarlinConfig.h" + +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + +#include "x_twist.h" +#include "../module/probe.h" + +XATC xatc; + +bool XATC::enabled; +float XATC::spacing, XATC::start; +xatc_array_t XATC::z_offset; // Initialized by settings.load() + +void XATC::reset() { + constexpr float xzo[] = XATC_Z_OFFSETS; + static_assert(COUNT(xzo) == XATC_MAX_POINTS, "XATC_Z_OFFSETS is the wrong size."); + COPY(z_offset, xzo); + start = probe.min_x(); + spacing = (probe.max_x() - start) / (XATC_MAX_POINTS - 1); + enabled = true; +} + +void XATC::print_points() { + SERIAL_ECHOLNPGM(" X-Twist Correction:"); + LOOP_L_N(x, XATC_MAX_POINTS) { + SERIAL_CHAR(' '); + if (!isnan(z_offset[x])) + serial_offset(z_offset[x]); + else + LOOP_L_N(i, 6) SERIAL_CHAR(i ? '=' : ' '); + } + SERIAL_EOL(); +} + +float lerp(const_float_t t, const_float_t a, const_float_t b) { return a + t * (b - a); } + +float XATC::compensation(const xy_pos_t &raw) { + if (!enabled) return 0; + if (NEAR_ZERO(spacing)) return 0; + float t = (raw.x - start) / spacing; + const int i = constrain(FLOOR(t), 0, XATC_MAX_POINTS - 2); + t -= i; + return lerp(t, z_offset[i], z_offset[i + 1]); +} + +#endif // X_AXIS_TWIST_COMPENSATION diff --git a/Marlin/src/feature/x_twist.h b/Marlin/src/feature/x_twist.h new file mode 100644 index 000000000000..6a2ff279013a --- /dev/null +++ b/Marlin/src/feature/x_twist.h @@ -0,0 +1,40 @@ +/** + * 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 "../inc/MarlinConfigPre.h" + +typedef float xatc_array_t[XATC_MAX_POINTS]; + +class XATC { + static bool enabled; +public: + static float spacing, start; + static xatc_array_t z_offset; + + static void reset(); + static void set_enabled(const bool ena) { enabled = ena; } + static float compensation(const xy_pos_t &raw); + static void print_points(); +}; + +extern XATC xatc; diff --git a/Marlin/src/feature/z_stepper_align.cpp b/Marlin/src/feature/z_stepper_align.cpp index 1b4eb4474903..fdbd464ea1b4 100644 --- a/Marlin/src/feature/z_stepper_align.cpp +++ b/Marlin/src/feature/z_stepper_align.cpp @@ -35,7 +35,7 @@ ZStepperAlign z_stepper_align; xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPER_DRIVERS]; -#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) +#if HAS_Z_STEPPER_ALIGN_STEPPER_XY xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPER_DRIVERS]; #endif @@ -103,7 +103,7 @@ void ZStepperAlign::reset_to_default() { COPY(xy, xy_init); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY; static_assert( COUNT(stepper_xy_init) == NUM_Z_STEPPER_DRIVERS, diff --git a/Marlin/src/feature/z_stepper_align.h b/Marlin/src/feature/z_stepper_align.h index e1b235b52cb3..8a12cd18b0bd 100644 --- a/Marlin/src/feature/z_stepper_align.h +++ b/Marlin/src/feature/z_stepper_align.h @@ -31,7 +31,7 @@ class ZStepperAlign { public: static xy_pos_t xy[NUM_Z_STEPPER_DRIVERS]; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY static xy_pos_t stepper_xy[NUM_Z_STEPPER_DRIVERS]; #endif diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 728771d5809d..6691d6c9ab55 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -71,8 +71,8 @@ * pliers while holding the LCD Click wheel in a depressed state. If you do not have * an LCD, you must specify a value if you use P. * - * Q # Multiplier Retraction Multiplier. Normally not needed. Retraction defaults to 1.0mm and - * un-retraction is at 1.2mm These numbers will be scaled by the specified amount + * Q # Multiplier Retraction Multiplier. (Normally not needed.) During G26 retraction will use the length + * specified by this parameter (1mm by default). Recover will be 1.2x the retract distance. * * R # Repeat Prints the number of patterns given as a parameter, starting at the current location. * If a parameter isn't given, every point will be printed unless G26 is interrupted. @@ -156,7 +156,7 @@ constexpr float g26_e_axis_feedrate = 0.025; static MeshFlags circle_flags; float g26_random_deviation = 0.0; -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU /** * If the LCD is clicked, cancel, wait for release, return true @@ -164,7 +164,7 @@ float g26_random_deviation = 0.0; bool user_canceled() { if (!ui.button_pressed()) return false; // Return if the button isn't pressed ui.set_status(GET_TEXT_F(MSG_G26_CANCELED), 99); - TERN_(HAS_LCD_MENU, ui.quick_feedback()); + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); ui.wait_for_release(); return true; } @@ -325,7 +325,7 @@ typedef struct { #if HAS_WIRED_LCD ui.set_status(GET_TEXT_F(MSG_G26_HEATING_BED), 99); ui.quick_feedback(); - TERN_(HAS_LCD_MENU, ui.capture()); + TERN_(HAS_MARLINUI_MENU, ui.capture()); #endif thermalManager.setTargetBed(bed_temp); @@ -365,7 +365,7 @@ typedef struct { bool prime_nozzle() { const feedRate_t fr_slow_e = planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0f; - #if HAS_LCD_MENU && !HAS_TOUCH_BUTTONS // ui.button_pressed issue with touchscreen + #if HAS_MARLINUI_MENU && !HAS_TOUCH_BUTTONS // ui.button_pressed issue with touchscreen #if ENABLED(PREVENT_LENGTHY_EXTRUDE) float Total_Prime = 0.0; #endif @@ -579,7 +579,7 @@ void GcodeSuite::G26() { if (parser.seen('P')) { if (!parser.has_value()) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU g26.prime_flag = -1; #else SERIAL_ECHOLNPGM("?Prime length must be specified when not using an LCD."); @@ -638,7 +638,7 @@ void GcodeSuite::G26() { // Get repeat from 'R', otherwise do one full circuit int16_t g26_repeats; - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1); #else if (parser.seen('R')) @@ -699,7 +699,7 @@ void GcodeSuite::G26() { move_to(destination, 0.0); move_to(destination, g26.ooze_amount); - TERN_(HAS_LCD_MENU, ui.capture()); + TERN_(HAS_MARLINUI_MENU, ui.capture()); #if DISABLED(ARC_SUPPORT) @@ -795,7 +795,7 @@ void GcodeSuite::G26() { destination = current_position; } - if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation + if (TERN0(HAS_MARLINUI_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation #else // !ARC_SUPPORT @@ -819,7 +819,7 @@ void GcodeSuite::G26() { for (int8_t ind = start_ind; ind <= end_ind; ind++) { - if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation + if (TERN0(HAS_MARLINUI_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation xyz_float_t p = { circle.x + _COS(ind ), circle.y + _SIN(ind ), g26.layer_height }, q = { circle.x + _COS(ind + 1), circle.y + _SIN(ind + 1), g26.layer_height }; @@ -846,7 +846,7 @@ void GcodeSuite::G26() { g26.connect_neighbor_with_line(location.pos, 0, 1); planner.synchronize(); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_POINT_FINISH)); - if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; + if (TERN0(HAS_MARLINUI_MENU, user_canceled())) goto LEAVE; } SERIAL_FLUSH(); // Prevent host M105 buffer overrun. @@ -866,7 +866,7 @@ void GcodeSuite::G26() { planner.calculate_volumetric_multipliers(); #endif - TERN_(HAS_LCD_MENU, ui.release()); // Give back control of the LCD + TERN_(HAS_MARLINUI_MENU, ui.release()); // Give back control of the LCD if (!g26.keep_heaters_on) { TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0)); diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index e45e18b7fbc2..dd828bf0c873 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -33,6 +33,10 @@ #include "../../module/tool_change.h" #endif +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" @@ -102,7 +106,9 @@ void GcodeSuite::G35() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G35 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7)); + + // Unsure if this is even required. The probe seems to lift correctly after probe done. + do_blocking_move_to_z(SUM_TERN(BLTOUCH, Z_CLEARANCE_BETWEEN_PROBES, bltouch.z_extra_clearance())); const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { @@ -149,7 +155,7 @@ void GcodeSuite::G35() { // Restore the active tool after homing #if HAS_MULTI_HOTEND - tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER + if (old_tool_index != 0) tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER #endif #if BOTH(HAS_LEVELING, RESTORE_LEVELING_AFTER_G35) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 14da38c8fe2b..1868c636ee36 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -36,15 +36,6 @@ #include "../../../module/probe.h" #include "../../queue.h" -#if HAS_PTC - #include "../../../feature/probe_temp_comp.h" - #include "../../../module/temperature.h" -#endif - -#if HAS_STATUS_MESSAGE - #include "../../../lcd/marlinui.h" -#endif - #if ENABLED(AUTO_BED_LEVELING_LINEAR) #include "../../../libs/least_squares_fit.h" #endif @@ -53,21 +44,22 @@ #include "../../../libs/vector_3.h" #endif -#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) -#include "../../../core/debug_out.h" - +#include "../../../lcd/marlinui.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../../lcd/e3v2/proui/dwin.h" #endif #if HAS_MULTI_HOTEND #include "../../../module/tool_change.h" #endif +#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +#include "../../../core/debug_out.h" + #if ABL_USES_GRID #if ENABLED(PROBE_Y_FIRST) #define PR_OUTER_VAR abl.meshCount.x @@ -82,7 +74,12 @@ #endif #endif -#define G29_RETURN(b) return TERN_(G29_RETRY_AND_RECOVER, b) +#define G29_RETURN(retry) do{ \ + if (TERN(G29_RETRY_AND_RECOVER, !retry, true)) { \ + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false)); \ + } \ + return TERN_(G29_RETRY_AND_RECOVER, retry); \ +}while(0) // For manual probing values persist over multiple G29 class G29_State { @@ -93,6 +90,10 @@ class G29_State { bool dryrun, reenable; + #if HAS_MULTI_HOTEND + uint8_t tool_index; + #endif + #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) int abl_probe_index; #endif @@ -219,12 +220,13 @@ class G29_State { G29_TYPE GcodeSuite::G29() { DEBUG_SECTION(log_G29, "G29", DEBUGGING(LEVELING)); + // Leveling state is persistent when done manually with multiple G29 commands TERN_(PROBE_MANUALLY, static) G29_State abl; - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); - + // Keep powered steppers from timing out reset_stepper_timeout(); + // Q = Query leveling and G29 state const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen_test('Q'); // G29 Q is also available if debugging @@ -233,11 +235,14 @@ G29_TYPE GcodeSuite::G29() { if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false); #endif + // A = Abort manual probing + // C = Generate fake probe points (DEBUG_LEVELING_FEATURE) const bool seenA = TERN0(PROBE_MANUALLY, parser.seen_test('A')), no_action = seenA || seenQ, faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action; - if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed + // O = Don't level if leveling is already active + if (!no_action && planner.leveling_active && parser.boolval('O')) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip"); G29_RETURN(false); } @@ -249,21 +254,29 @@ G29_TYPE GcodeSuite::G29() { // Don't allow auto-leveling without homing first if (homing_needed_error()) G29_RETURN(false); + // 3-point leveling gets points from the probe class #if ENABLED(AUTO_BED_LEVELING_3POINT) vector_3 points[3]; probe.get_three_points(points); #endif + // Storage for ABL Linear results #if ENABLED(AUTO_BED_LEVELING_LINEAR) struct linear_fit_data lsf_results; #endif + // Set and report "probing" state to host + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE, false)); + /** * On the initial G29 fetch command parameters. */ if (!g29_in_progress) { - TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); + #if HAS_MULTI_HOTEND + abl.tool_index = active_extruder; + if (active_extruder != 0) tool_change(0, true); + #endif #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) abl.abl_probe_index = -1; @@ -290,6 +303,9 @@ G29_TYPE GcodeSuite::G29() { ry = RAW_Y_POSITION(parser.linearval('Y', NAN)); int8_t i = parser.byteval('I', -1), j = parser.byteval('J', -1); + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + if (!isnan(rx) && !isnan(ry)) { // Get nearest i / j from rx / ry i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x; @@ -297,6 +313,9 @@ G29_TYPE GcodeSuite::G29() { LIMIT(i, 0, (GRID_MAX_POINTS_X) - 1); LIMIT(j, 0, (GRID_MAX_POINTS_Y) - 1); } + + #pragma GCC diagnostic pop + if (WITHIN(i, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(j, 0, (GRID_MAX_POINTS_Y) - 1)) { set_bed_leveling_enabled(false); z_values[i][j] = rz; @@ -400,12 +419,13 @@ G29_TYPE GcodeSuite::G29() { planner.synchronize(); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); + #if ENABLED(AUTO_BED_LEVELING_3POINT) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling"); points[0].z = points[1].z = points[2].z = 0; // Probe at 3 arbitrary points #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshLevelingStart()); + TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LevelingStart()); #endif if (!faux) { @@ -421,10 +441,10 @@ G29_TYPE GcodeSuite::G29() { if (!no_action) set_bed_leveling_enabled(false); // Deploy certain probes before starting probing - #if HAS_BED_PROBE - if (ENABLED(BLTOUCH)) - do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); - else if (probe.deploy()) { + #if ENABLED(BLTOUCH) + do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); + #elif HAS_BED_PROBE + if (probe.deploy()) { // (returns true on deploy failure) set_bed_leveling_enabled(abl.reenable); G29_RETURN(false); } @@ -475,6 +495,7 @@ G29_TYPE GcodeSuite::G29() { SERIAL_ECHOLNPGM("idle"); } + // For 'A' or 'Q' exit with success state if (no_action) G29_RETURN(false); if (abl.abl_probe_index == 0) { @@ -557,6 +578,7 @@ G29_TYPE GcodeSuite::G29() { SERIAL_ECHOLNPGM("Grid probing done."); // Re-enable software endstops, if needed SET_SOFT_ENDSTOP_LOOSE(false); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } #elif ENABLED(AUTO_BED_LEVELING_3POINT) @@ -586,6 +608,8 @@ G29_TYPE GcodeSuite::G29() { abl.reenable = false; } + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); + } #endif // AUTO_BED_LEVELING_3POINT @@ -645,10 +669,6 @@ G29_TYPE GcodeSuite::G29() { break; // Breaks out of both loops } - 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) abl.mean += abl.measured_z; @@ -883,11 +903,11 @@ G29_TYPE GcodeSuite::G29() { process_subcommands_now(F(Z_PROBE_END_SCRIPT)); #endif - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling()); + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone()); - report_current_position(); + TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index)); - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); + report_current_position(); G29_RETURN(isnan(abl.measured_z)); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index eec89f73acff..74843235f437 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -40,8 +40,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../../lcd/e3v2/proui/dwin.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) @@ -75,8 +75,6 @@ void GcodeSuite::G29() { } #endif - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); - static int mbl_probe_index = -1; MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport); @@ -85,6 +83,8 @@ void GcodeSuite::G29() { return; } + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); + int8_t ix, iy; ix = iy = 0; @@ -104,7 +104,8 @@ void GcodeSuite::G29() { mbl_probe_index = 0; if (!ui.wait_for_move) { queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2")); - TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); + TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); return; } state = MeshNext; @@ -117,9 +118,11 @@ void GcodeSuite::G29() { // For each G29 S2... if (mbl_probe_index == 0) { // Move close to the bed before the first point - do_blocking_move_to_z(0.4f + do_blocking_move_to_z( #ifdef MANUAL_PROBE_START_Z - + (MANUAL_PROBE_START_Z) - 0.4f + MANUAL_PROBE_START_Z + #else + 0.4f #endif ); } @@ -127,6 +130,7 @@ void GcodeSuite::G29() { // Save Z for the previous mesh position mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z)); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(_MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS), current_position.z)); SET_SOFT_ENDSTOP_LOOSE(false); } // If there's another point to sample, move there with optional lift. @@ -153,8 +157,7 @@ void GcodeSuite::G29() { mbl_probe_index = -1; SERIAL_ECHOLNPGM("Mesh probing done."); TERN_(HAS_STATUS_MESSAGE, LCD_MESSAGE(MSG_MESH_DONE)); - BUZZ(100, 659); - BUZZ(100, 698); + OKAY_BUZZ(); home_all_axes(); set_bed_leveling_enabled(true); @@ -166,6 +169,7 @@ void GcodeSuite::G29() { #endif TERN_(LCD_BED_LEVELING, ui.wait_for_move = false); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } break; @@ -193,7 +197,7 @@ void GcodeSuite::G29() { if (parser.seenval('Z')) { mbl.z_values[ix][iy] = parser.value_linear_units(); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy])); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ix, iy, mbl.z_values[ix][iy])); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(ix, iy, mbl.z_values[ix][iy])); } else return echo_not_entered('Z'); diff --git a/Marlin/src/gcode/bedlevel/ubl/M421.cpp b/Marlin/src/gcode/bedlevel/ubl/M421.cpp index e6f0ef1f8907..c11a20ebf33c 100644 --- a/Marlin/src/gcode/bedlevel/ubl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/M421.cpp @@ -33,8 +33,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../../lcd/e3v2/proui/dwin.h" #endif /** @@ -69,7 +69,7 @@ void GcodeSuite::M421() { float &zval = ubl.z_values[ij.x][ij.y]; // Altering this Mesh Point zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); // N=NAN, Z=NEWVAL, or Q=ADDVAL TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval)); // Ping ExtUI in case it's showing the mesh - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ij.x, ij.y, zval)); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(ij.x, ij.y, zval)); } } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 95f2a9b17614..9361790d74cf 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -51,8 +51,8 @@ #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif #if HAS_L64XX // set L6470 absolute position registers to counts @@ -76,16 +76,13 @@ const int x_axis_home_dir = TOOL_X_HOME_DIR(active_extruder); - const float mlx = max_length(X_AXIS), - mly = max_length(Y_AXIS), - mlratio = mlx > mly ? mly / mlx : mlx / mly, - fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0); + // Use a higher diagonal feedrate so axes move at homing speed + const float minfr = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)), + fr_mm_s = HYPOT(minfr, minfr); #if ENABLED(SENSORLESS_HOMING) sensorless_t stealth_states { - tmc_enable_stallguard(stepperX) - , tmc_enable_stallguard(stepperY) - , false + LINEAR_AXIS_LIST(tmc_enable_stallguard(stepperX), tmc_enable_stallguard(stepperY), false, false, false, false) , false #if AXIS_HAS_STALLGUARD(X2) || tmc_enable_stallguard(stepperX2) @@ -97,7 +94,7 @@ }; #endif - do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * Y_HOME_DIR, fr_mm_s); + do_blocking_move_to_xy(1.5 * max_length(X_AXIS) * x_axis_home_dir, 1.5 * max_length(Y_AXIS) * Y_HOME_DIR, fr_mm_s); endstops.validate_homing_move(); @@ -216,8 +213,6 @@ void GcodeSuite::G28() { TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_HOMING)); - #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; DualXMode IDEX_saved_mode = dual_x_carriage_mode; @@ -239,7 +234,12 @@ void GcodeSuite::G28() { return; } - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StartHoming()); + #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) + const M_StateEnum old_grblstate = M_State_grbl; + set_and_report_grblstate(M_HOMING); + #endif + + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingStart()); TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart()); planner.synchronize(); // Wait for planner moves to finish! @@ -264,7 +264,7 @@ void GcodeSuite::G28() { reset_stepper_timeout(); #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) + #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) #define HAS_HOMING_CURRENT 1 #endif @@ -275,27 +275,57 @@ void GcodeSuite::G28() { #if HAS_CURRENT_HOME(X) const int16_t tmc_save_current_X = stepperX.getMilliamps(); stepperX.rms_current(X_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("X"), tmc_save_current_X, X_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_X), tmc_save_current_X, X_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(X2) const int16_t tmc_save_current_X2 = stepperX2.getMilliamps(); stepperX2.rms_current(X2_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("X2"), tmc_save_current_X2, X2_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_X2), tmc_save_current_X2, X2_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Y) const int16_t tmc_save_current_Y = stepperY.getMilliamps(); stepperY.rms_current(Y_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("Y"), tmc_save_current_Y, Y_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_Y), tmc_save_current_Y, Y_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Y2) const int16_t tmc_save_current_Y2 = stepperY2.getMilliamps(); stepperY2.rms_current(Y2_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_Y2), tmc_save_current_Y2, Y2_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(I) + const int16_t tmc_save_current_I = stepperI.getMilliamps(); + stepperI.rms_current(I_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_I), tmc_save_current_I, I_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(J) + const int16_t tmc_save_current_J = stepperJ.getMilliamps(); + stepperJ.rms_current(J_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_J), tmc_save_current_J, J_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(K) + const int16_t tmc_save_current_K = stepperK.getMilliamps(); + stepperK.rms_current(K_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_K), tmc_save_current_K, K_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) const int16_t tmc_save_current_Z = stepperZ.getMilliamps(); stepperZ.rms_current(Z_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("Z"), tmc_save_current_Z, Z_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_Z), tmc_save_current_Z, Z_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(I) + const int16_t tmc_save_current_I = stepperI.getMilliamps(); + stepperI.rms_current(I_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_I), tmc_save_current_I, I_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(J) + const int16_t tmc_save_current_J = stepperJ.getMilliamps(); + stepperJ.rms_current(J_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_J), tmc_save_current_J, J_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(K) + const int16_t tmc_save_current_K = stepperK.getMilliamps(); + stepperK.rms_current(K_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_K), tmc_save_current_K, K_CURRENT_HOME); #endif #endif @@ -348,7 +378,7 @@ void GcodeSuite::G28() { homeX = needX || parser.seen_test('X'), homeY = needY || parser.seen_test('Y'), homeZZ = homeZ, - homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), homeK = needK || parser.seen_test(AXIS6_NAME), + homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), homeK = needK || parser.seen_test(AXIS6_NAME) ), home_all = LINEAR_AXIS_GANG( // Home-all if all or none are flagged homeX == homeX, && homeY == homeX, && homeZ == homeX, @@ -367,9 +397,10 @@ void GcodeSuite::G28() { TERN_(HOME_Z_FIRST, if (doZ) homeaxis(Z_AXIS)); - const float z_homing_height = parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT; + const bool seenR = parser.seenval('R'); + const float z_homing_height = seenR ? parser.value_linear_units() : Z_HOMING_HEIGHT; - if (z_homing_height && (LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { + if (z_homing_height && (seenR || LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { // Raise Z before homing any other axes and z is not already high enough (never lower z) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Raise Z (before homing) by ", z_homing_height); do_z_clearance(z_homing_height); @@ -423,20 +454,18 @@ void GcodeSuite::G28() { stepper.set_separate_multi_axis(false); #endif - TERN(Z_SAFE_HOMING, home_z_safely(), homeaxis(Z_AXIS)); + #if ENABLED(Z_SAFE_HOMING) + if (TERN1(POWER_LOSS_RECOVERY, !parser.seen_test('H'))) home_z_safely(); else homeaxis(Z_AXIS); + #else + homeaxis(Z_AXIS); + #endif probe.move_z_after_homing(); } #endif - #if LINEAR_AXES >= 4 - if (doI) homeaxis(I_AXIS); - #endif - #if LINEAR_AXES >= 5 - if (doJ) homeaxis(J_AXIS); - #endif - #if LINEAR_AXES >= 6 - if (doK) homeaxis(K_AXIS); - #endif + TERN_(HAS_I_AXIS, if (doI) homeaxis(I_AXIS)); + TERN_(HAS_J_AXIS, if (doJ) homeaxis(J_AXIS)); + TERN_(HAS_K_AXIS, if (doK) homeaxis(K_AXIS)); sync_plan_position(); @@ -523,15 +552,15 @@ void GcodeSuite::G28() { ui.refresh(); - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedHoming()); - TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete()); + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingDone()); + TERN_(EXTENSIBLE_UI, ExtUI::onHomingDone()); report_current_position(); if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS))) SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP); - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(old_grblstate)); #if HAS_L64XX // Set L6470 absolute position registers to counts diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 779ae99d0adf..506f367947df 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -69,8 +69,6 @@ enum CalEnum : char { // the 7 main calibration points - float lcd_probe_pt(const xy_pos_t &xy); -float dcr; - void ac_home() { endstops.enable(true); TERN_(HAS_DELTA_SENSORLESS_PROBING, probe.set_homing_current(true)); @@ -100,8 +98,7 @@ void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) { void print_signed_float(FSTR_P const prefix, const_float_t f) { SERIAL_ECHOPGM(" "); SERIAL_ECHOF(prefix, AS_CHAR(':')); - if (f >= 0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(f, 2); + serial_offset(f); } /** @@ -177,7 +174,7 @@ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool */ static float calibration_probe(const xy_pos_t &xy, const bool stow, const bool probe_at_offset) { #if HAS_BED_PROBE - return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true, probe_at_offset); + return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, probe_at_offset, false); #else UNUSED(stow); return lcd_probe_pt(xy); @@ -187,7 +184,7 @@ static float calibration_probe(const xy_pos_t &xy, const bool stow, const bool p /** * - Probe a grid */ -static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_points, const bool towers_set, const bool stow_after_each, const bool probe_at_offset) { +static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_points, const float dcr, const bool towers_set, const bool stow_after_each, const bool probe_at_offset) { const bool _0p_calibration = probe_points == 0, _1p_calibration = probe_points == 1 || probe_points == -1, _4p_calibration = probe_points == 2, @@ -271,7 +268,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi * - formulae for approximative forward kinematics in the end-stop displacement matrix * - definition of the matrix scaling parameters */ -static void reverse_kinematics_probe_points(float z_pt[NPP + 1], abc_float_t mm_at_pt_axis[NPP + 1]) { +static void reverse_kinematics_probe_points(float z_pt[NPP + 1], abc_float_t mm_at_pt_axis[NPP + 1], const float dcr) { xyz_pos_t pos{0}; LOOP_CAL_ALL(rad) { @@ -283,7 +280,7 @@ static void reverse_kinematics_probe_points(float z_pt[NPP + 1], abc_float_t mm_ } } -static void forward_kinematics_probe_points(abc_float_t mm_at_pt_axis[NPP + 1], float z_pt[NPP + 1]) { +static void forward_kinematics_probe_points(abc_float_t mm_at_pt_axis[NPP + 1], float z_pt[NPP + 1], const float dcr) { const float r_quot = dcr / delta_radius; #define ZPP(N,I,A) (((1.0f + r_quot * (N)) / 3.0f) * mm_at_pt_axis[I].A) @@ -302,19 +299,19 @@ static void forward_kinematics_probe_points(abc_float_t mm_at_pt_axis[NPP + 1], z_pt[_AB] = Zp1(_AB, a) + Zp1(_AB, b) + Zm2(_AB, c); } -static void calc_kinematics_diff_probe_points(float z_pt[NPP + 1], abc_float_t delta_e, const float delta_r, abc_float_t delta_t) { +static void calc_kinematics_diff_probe_points(float z_pt[NPP + 1], const float dcr, abc_float_t delta_e, const float delta_r, abc_float_t delta_t) { const float z_center = z_pt[CEN]; abc_float_t diff_mm_at_pt_axis[NPP + 1], new_mm_at_pt_axis[NPP + 1]; - reverse_kinematics_probe_points(z_pt, diff_mm_at_pt_axis); + reverse_kinematics_probe_points(z_pt, diff_mm_at_pt_axis, dcr); delta_radius += delta_r; delta_tower_angle_trim += delta_t; recalc_delta_settings(); - reverse_kinematics_probe_points(z_pt, new_mm_at_pt_axis); + reverse_kinematics_probe_points(z_pt, new_mm_at_pt_axis, dcr); LOOP_CAL_ALL(rad) diff_mm_at_pt_axis[rad] -= new_mm_at_pt_axis[rad] + delta_e; - forward_kinematics_probe_points(diff_mm_at_pt_axis, z_pt); + forward_kinematics_probe_points(diff_mm_at_pt_axis, z_pt, dcr); LOOP_CAL_RAD(rad) z_pt[rad] -= z_pt[CEN] - z_center; z_pt[CEN] = z_center; @@ -324,23 +321,23 @@ static void calc_kinematics_diff_probe_points(float z_pt[NPP + 1], abc_float_t d recalc_delta_settings(); } -static float auto_tune_h() { +static float auto_tune_h(const float dcr) { const float r_quot = dcr / delta_radius; return RECIPROCAL(r_quot / (2.0f / 3.0f)); // (2/3)/CR } -static float auto_tune_r() { +static float auto_tune_r(const float dcr) { constexpr float diff = 0.01f, delta_r = diff; float r_fac = 0.0f, z_pt[NPP + 1] = { 0.0f }; abc_float_t delta_e = { 0.0f }, delta_t = { 0.0f }; - calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t); + calc_kinematics_diff_probe_points(z_pt, dcr, delta_e, delta_r, delta_t); r_fac = -(z_pt[__A] + z_pt[__B] + z_pt[__C] + z_pt[_BC] + z_pt[_CA] + z_pt[_AB]) / 6.0f; r_fac = diff / r_fac / 3.0f; // 1/(3*delta_Z) return r_fac; } -static float auto_tune_a() { +static float auto_tune_a(const float dcr) { constexpr float diff = 0.01f, delta_r = 0.0f; float a_fac = 0.0f, z_pt[NPP + 1] = { 0.0f }; abc_float_t delta_e = { 0.0f }, delta_t = { 0.0f }; @@ -348,7 +345,7 @@ static float auto_tune_a() { delta_t.reset(); LOOP_LINEAR_AXES(axis) { delta_t[axis] = diff; - calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t); + calc_kinematics_diff_probe_points(z_pt, dcr, delta_e, delta_r, delta_t); delta_t[axis] = 0; a_fac += z_pt[uint8_t((axis * _4P_STEP) - _7P_STEP + NPP) % NPP + 1] / 6.0f; a_fac -= z_pt[uint8_t((axis * _4P_STEP) + 1 + _7P_STEP)] / 6.0f; @@ -370,7 +367,7 @@ static float auto_tune_a() { * P3 Probe all positions: center, towers and opposite towers. Calibrate all. * P4-P10 Probe all positions at different intermediate locations and average them. * - * Rn.nn override default calibration Radius + * Rn.nn Temporary reduce the probe grid by the specified amount (mm) * * T Don't calibrate tower angle corrections * @@ -386,7 +383,7 @@ static float auto_tune_a() { * * E Engage the probe for each point * - * O Probe at offset points (this is wrong but it seems to work) + * O Probe at offsetted probe positions (this is wrong but it seems to work) * * With SENSORLESS_PROBING: * Use these flags to calibrate stall sensitivity: (e.g., `G33 P1 Y Z` to calibrate X only.) @@ -404,27 +401,17 @@ void GcodeSuite::G33() { return; } - const bool probe_at_offset = TERN0(HAS_PROBE_XY_OFFSET, parser.boolval('O')), + const bool probe_at_offset = TERN0(HAS_PROBE_XY_OFFSET, parser.seen_test('O')), towers_set = !parser.seen_test('T'); - float max_dcr = dcr = DELTA_PRINTABLE_RADIUS; + // The calibration radius is set to a calculated value + float dcr = probe_at_offset ? DELTA_PRINTABLE_RADIUS : DELTA_PRINTABLE_RADIUS - PROBING_MARGIN; #if HAS_PROBE_XY_OFFSET - // For offset probes the calibration radius is set to a safe but non-optimal value - dcr -= HYPOT(probe.offset_xy.x, probe.offset_xy.y); - if (probe_at_offset) { - // With probe positions both probe and nozzle need to be within the printable area - max_dcr = dcr; - } - // else with nozzle positions there is a risk of the probe being outside the bed - // but as long the nozzle stays within the printable area there is no risk of - // the effector crashing into the towers. + const float total_offset = HYPOT(probe.offset_xy.x, probe.offset_xy.y); + dcr -= probe_at_offset ? _MAX(total_offset, PROBING_MARGIN) : total_offset; #endif - - if (parser.seenval('R')) dcr = parser.value_float(); - if (!WITHIN(dcr, 0, max_dcr)) { - SERIAL_ECHOLNPGM("?calibration (R)adius implausible."); - return; - } + NOMORE(dcr, DELTA_PRINTABLE_RADIUS); + if (parser.seenval('R')) dcr -= _MAX(parser.value_float(),0); const float calibration_precision = parser.floatval('C', 0.0f); if (calibration_precision < 0) { @@ -475,8 +462,9 @@ void GcodeSuite::G33() { SERIAL_ECHOLNPGM("G33 Auto Calibrate"); // Report settings - FSTR_P const checkingac = F("Checking... AC"); - SERIAL_ECHOF(checkingac); + PGM_P const checkingac = PSTR("Checking... AC"); + SERIAL_ECHOPGM_P(checkingac); + SERIAL_ECHOPGM(" at radius:", dcr); if (verbose_level == 0) SERIAL_ECHOPGM(" (DRY-RUN)"); SERIAL_EOL(); ui.set_status(checkingac); @@ -496,7 +484,7 @@ void GcodeSuite::G33() { // Probe the points zero_std_dev_old = zero_std_dev; - if (!probe_calibration_points(z_at_pt, probe_points, towers_set, stow_after_each, probe_at_offset)) { + if (!probe_calibration_points(z_at_pt, probe_points, dcr, towers_set, stow_after_each, probe_at_offset)) { SERIAL_ECHOLNPGM("Correct delta settings with M665 and M666"); return ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index)); } @@ -536,10 +524,10 @@ void GcodeSuite::G33() { // calculate factors if (_7p_9_center) dcr *= 0.9f; - h_factor = auto_tune_h(); - r_factor = auto_tune_r(); - a_factor = auto_tune_a(); - dcr /= 0.9f; + h_factor = auto_tune_h(dcr); + r_factor = auto_tune_r(dcr); + a_factor = auto_tune_a(dcr); + if (_7p_9_center) dcr /= 0.9f; switch (probe_points) { case 0: diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index 98a0bdef8898..ea5d5fa150cf 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -114,10 +114,6 @@ void GcodeSuite::G34() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Final Z Move"); do_blocking_move_to_z(zgrind, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); - // Back off end plate, back to normal motion range - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Backoff"); - do_blocking_move_to_z(zpounce, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); - #if _REDUCE_CURRENT // Reset current to original values if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore Current"); @@ -146,6 +142,10 @@ void GcodeSuite::G34() { #endif #endif + // Back off end plate, back to normal motion range + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Backoff"); + do_blocking_move_to_z(zpounce, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); + #ifdef GANTRY_CALIBRATION_COMMANDS_POST if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Running Post Commands"); process_subcommands_now(F(GANTRY_CALIBRATION_COMMANDS_POST)); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 8f4eab2c9715..d1f82e7e9874 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -41,10 +41,14 @@ #include "../../module/tool_change.h" #endif -#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) +#if HAS_Z_STEPPER_ALIGN_STEPPER_XY #include "../../libs/least_squares_fit.h" #endif +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" @@ -118,7 +122,7 @@ void GcodeSuite::G34() { break; } - const float z_auto_align_amplification = TERN(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP)); + const float z_auto_align_amplification = TERN(HAS_Z_STEPPER_ALIGN_STEPPER_XY, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP)); if (!WITHIN(ABS(z_auto_align_amplification), 0.5f, 2.0f)) { SERIAL_ECHOLNPGM("?(A)mplification out of bounds (0.5-2.0)."); break; @@ -149,7 +153,7 @@ void GcodeSuite::G34() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G34 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE)) + #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance())) // Compute a worst-case clearance height to probe from. After the first // iteration this will be re-calculated based on the actual bed position @@ -175,7 +179,7 @@ void GcodeSuite::G34() { // Now, the Z origin lies below the build plate. That allows to probe deeper, before run_z_probe throws an error. // This hack is un-done at the end of G34 - either by re-homing, or by using the probed heights of the last iteration. - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N_1(NUM_Z_STEPPER_DRIVERS, 10000.0f); #else float last_z_align_level_indicator = 10000.0f; @@ -184,7 +188,7 @@ void GcodeSuite::G34() { z_maxdiff = 0.0f, amplification = z_auto_align_amplification; - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY bool adjustment_reverse = false; #endif @@ -252,7 +256,7 @@ void GcodeSuite::G34() { z_maxdiff = z_measured_max - z_measured_min; z_probe = Z_BASIC_CLEARANCE + z_measured_max + z_maxdiff; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY // Replace the initial values in z_measured with calculated heights at // each stepper position. This allows the adjustment algorithm to be // shared between both possible probing mechanisms. @@ -334,7 +338,7 @@ void GcodeSuite::G34() { return false; }; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY // Check if the applied corrections go in the correct direction. // Calculate the sum of the absolute deviations from the mean of the probe measurements. // Compare to the last iteration to ensure it's getting better. @@ -366,7 +370,7 @@ void GcodeSuite::G34() { float z_align_move = z_measured[zstepper] - z_measured_min; const float z_align_abs = ABS(z_align_move); - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY // Optimize one iteration's correction based on the first measurements if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification; @@ -390,7 +394,7 @@ void GcodeSuite::G34() { // Lock all steppers except one stepper.set_all_z_lock(true, zstepper); - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY // Decreasing accuracy was detected so move was inverted. // Will match reversed Z steppers on dual steppers. Triple will need more work to map. if (adjustment_reverse) { @@ -463,7 +467,7 @@ void GcodeSuite::G34() { * * S : Index of the probe point to set * - * With Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS: + * With Z_STEPPER_ALIGN_STEPPER_XY: * W : Index of the Z stepper position to set * The W and S parameters may not be combined. * @@ -482,42 +486,43 @@ void GcodeSuite::M422() { return; } - const bool is_probe_point = parser.seen('S'); + const bool is_probe_point = parser.seen_test('S'); - if (TERN0(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, is_probe_point && parser.seen('W'))) { + if (TERN0(HAS_Z_STEPPER_ALIGN_STEPPER_XY, is_probe_point && parser.seen_test('W'))) { SERIAL_ECHOLNPGM("?(S) and (W) may not be combined."); return; } - xy_pos_t *pos_dest = ( - TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !is_probe_point ? z_stepper_align.stepper_xy :) + xy_pos_t * const pos_dest = ( + TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !is_probe_point ? z_stepper_align.stepper_xy :) z_stepper_align.xy ); - if (!is_probe_point && TERN1(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !parser.seen('W'))) { - SERIAL_ECHOLNPGM("?(S)" TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, " or (W)") " is required."); + if (!is_probe_point && TERN1(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !parser.seen_test('W'))) { + SERIAL_ECHOLNPGM("?(S)" TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, " or (W)") " is required."); return; } // Get the Probe Position Index or Z Stepper Index - int8_t position_index; - if (is_probe_point) { - position_index = parser.intval('S') - 1; - if (!WITHIN(position_index, 0, int8_t(NUM_Z_STEPPER_DRIVERS) - 1)) { - SERIAL_ECHOLNPGM("?(S) Probe-position index invalid."); - return; - } - } + int8_t position_index = 1; + FSTR_P err_string = F("?(S) Probe-position"); + if (is_probe_point) + position_index = parser.intval('S'); else { - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - position_index = parser.intval('W') - 1; - if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) { - SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid."); - return; - } + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY + err_string = F("?(W) Z-stepper"); + position_index = parser.intval('W'); #endif } + if (!WITHIN(position_index, 1, NUM_Z_STEPPER_DRIVERS)) { + SERIAL_ECHOF(err_string); + SERIAL_ECHOLNPGM(" index invalid (1.." STRINGIFY(NUM_Z_STEPPER_DRIVERS) ")."); + return; + } + + --position_index; + const xy_pos_t pos = { parser.floatval('X', pos_dest[position_index].x), parser.floatval('Y', pos_dest[position_index].y) @@ -547,7 +552,7 @@ void GcodeSuite::M422_report(const bool forReplay/*=true*/) { SP_Y_STR, z_stepper_align.xy[i].y ); } - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { report_echo_start(forReplay); SERIAL_ECHOLNPGM_P( diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 88c906f4937a..a2dec64bc3a8 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -73,16 +73,16 @@ #if BOTH(CALIBRATION_MEASURE_LEFT, CALIBRATION_MEASURE_RIGHT) #define HAS_X_CENTER 1 #endif -#if HAS_Y_AXIS && BOTH(CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK) +#if ALL(HAS_Y_AXIS, CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK) #define HAS_Y_CENTER 1 #endif -#if LINEAR_AXES >= 4 && BOTH(CALIBRATION_MEASURE_IMIN, CALIBRATION_MEASURE_IMAX) +#if ALL(HAS_I_AXIS, CALIBRATION_MEASURE_IMIN, CALIBRATION_MEASURE_IMAX) #define HAS_I_CENTER 1 #endif -#if LINEAR_AXES >= 5 && BOTH(CALIBRATION_MEASURE_JMIN, CALIBRATION_MEASURE_JMAX) +#if ALL(HAS_J_AXIS, CALIBRATION_MEASURE_JMIN, CALIBRATION_MEASURE_JMAX) #define HAS_J_CENTER 1 #endif -#if LINEAR_AXES >= 6 && BOTH(CALIBRATION_MEASURE_KMIN, CALIBRATION_MEASURE_KMAX) +#if ALL(HAS_K_AXIS, CALIBRATION_MEASURE_KMIN, CALIBRATION_MEASURE_KMAX) #define HAS_K_CENTER 1 #endif @@ -105,13 +105,27 @@ struct measurements_t { }; #if ENABLED(BACKLASH_GCODE) - #define TEMPORARY_BACKLASH_CORRECTION(value) REMEMBER(tbst, backlash.correction, value) + class restorer_correction { + const uint8_t val_; + public: + restorer_correction(const uint8_t temp_val) : val_(backlash.get_correction_uint8()) { backlash.set_correction_uint8(temp_val); } + ~restorer_correction() { backlash.set_correction_uint8(val_); } + }; + + #define TEMPORARY_BACKLASH_CORRECTION(value) restorer_correction restorer_tbst(value) #else #define TEMPORARY_BACKLASH_CORRECTION(value) #endif #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - #define TEMPORARY_BACKLASH_SMOOTHING(value) REMEMBER(tbsm, backlash.smoothing_mm, value) + class restorer_smoothing { + const float val_; + public: + restorer_smoothing(const float temp_val) : val_(backlash.get_smoothing_mm()) { backlash.set_smoothing_mm(temp_val); } + ~restorer_smoothing() { backlash.set_smoothing_mm(val_); } + }; + + #define TEMPORARY_BACKLASH_SMOOTHING(value) restorer_smoothing restorer_tbsm(value) #else #define TEMPORARY_BACKLASH_SMOOTHING(value) #endif @@ -241,14 +255,15 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t park_above_object(m, uncertainty); + #define _ACASE(N,A,B) case A: dir = -1; case B: axis = N##_AXIS; break + #define _PCASE(N) _ACASE(N, N##MINIMUM, N##MAXIMUM) + switch (side) { #if AXIS_CAN_CALIBRATE(X) - case RIGHT: dir = -1; - case LEFT: axis = X_AXIS; break; + _ACASE(X, RIGHT, LEFT); #endif - #if LINEAR_AXES >= 2 && AXIS_CAN_CALIBRATE(Y) - case BACK: dir = -1; - case FRONT: axis = Y_AXIS; break; + #if HAS_Y_AXIS && AXIS_CAN_CALIBRATE(Y) + _ACASE(Y, BACK, FRONT); #endif #if HAS_Z_AXIS && AXIS_CAN_CALIBRATE(Z) case TOP: { @@ -258,17 +273,14 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t return; } #endif - #if LINEAR_AXES >= 4 && AXIS_CAN_CALIBRATE(I) - case IMINIMUM: dir = -1; - case IMAXIMUM: axis = I_AXIS; break; + #if HAS_I_AXIS && AXIS_CAN_CALIBRATE(I) + _PCASE(I); #endif - #if LINEAR_AXES >= 5 && AXIS_CAN_CALIBRATE(J) - case JMINIMUM: dir = -1; - case JMAXIMUM: axis = J_AXIS; break; + #if HAS_J_AXIS && AXIS_CAN_CALIBRATE(J) + _PCASE(J); #endif - #if LINEAR_AXES >= 6 && AXIS_CAN_CALIBRATE(K) - case KMINIMUM: dir = -1; - case KMAXIMUM: axis = K_AXIS; break; + #if HAS_K_AXIS && AXIS_CAN_CALIBRATE(K) + _PCASE(K); #endif default: return; } @@ -370,7 +382,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" Back: ", m.obj_side[BACK]); #endif #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS #if ENABLED(CALIBRATION_MEASURE_IMIN) SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.obj_side[IMINIMUM]); #endif @@ -378,7 +390,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.obj_side[IMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS #if ENABLED(CALIBRATION_MEASURE_JMIN) SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.obj_side[JMINIMUM]); #endif @@ -386,7 +398,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.obj_side[JMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS #if ENABLED(CALIBRATION_MEASURE_KMIN) SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.obj_side[KMINIMUM]); #endif @@ -439,7 +451,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { #if HAS_Z_AXIS && AXIS_CAN_CALIBRATE(Z) SERIAL_ECHOLNPGM(" Top: ", m.backlash[TOP]); #endif - #if LINEAR_AXES >= 4 && AXIS_CAN_CALIBRATE(I) + #if HAS_I_AXIS && AXIS_CAN_CALIBRATE(I) #if ENABLED(CALIBRATION_MEASURE_IMIN) SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.backlash[IMINIMUM]); #endif @@ -447,7 +459,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.backlash[IMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 5 && AXIS_CAN_CALIBRATE(J) + #if HAS_J_AXIS && AXIS_CAN_CALIBRATE(J) #if ENABLED(CALIBRATION_MEASURE_JMIN) SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.backlash[JMINIMUM]); #endif @@ -455,7 +467,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.backlash[JMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 6 && AXIS_CAN_CALIBRATE(K) + #if HAS_K_AXIS && AXIS_CAN_CALIBRATE(K) #if ENABLED(CALIBRATION_MEASURE_KMIN) SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.backlash[KMINIMUM]); #endif @@ -526,7 +538,7 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { { // New scope for TEMPORARY_BACKLASH_CORRECTION - TEMPORARY_BACKLASH_CORRECTION(all_off); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_off); TEMPORARY_BACKLASH_SMOOTHING(0.0f); probe_sides(m, uncertainty); @@ -534,45 +546,45 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { #if ENABLED(BACKLASH_GCODE) #if HAS_X_CENTER - backlash.distance_mm.x = (m.backlash[LEFT] + m.backlash[RIGHT]) / 2; + backlash.set_distance_mm(X_AXIS, (m.backlash[LEFT] + m.backlash[RIGHT]) / 2); #elif ENABLED(CALIBRATION_MEASURE_LEFT) - backlash.distance_mm.x = m.backlash[LEFT]; + backlash.set_distance_mm(X_AXIS, m.backlash[LEFT]); #elif ENABLED(CALIBRATION_MEASURE_RIGHT) - backlash.distance_mm.x = m.backlash[RIGHT]; + backlash.set_distance_mm(X_AXIS, m.backlash[RIGHT]); #endif #if HAS_Y_CENTER - backlash.distance_mm.y = (m.backlash[FRONT] + m.backlash[BACK]) / 2; + backlash.set_distance_mm(Y_AXIS, (m.backlash[FRONT] + m.backlash[BACK]) / 2); #elif ENABLED(CALIBRATION_MEASURE_FRONT) - backlash.distance_mm.y = m.backlash[FRONT]; + backlash.set_distance_mm(Y_AXIS, m.backlash[FRONT]); #elif ENABLED(CALIBRATION_MEASURE_BACK) - backlash.distance_mm.y = m.backlash[BACK]; + backlash.set_distance_mm(Y_AXIS, m.backlash[BACK]); #endif - TERN_(HAS_Z_AXIS, if (AXIS_CAN_CALIBRATE(Z)) backlash.distance_mm.z = m.backlash[TOP]); + TERN_(HAS_Z_AXIS, if (AXIS_CAN_CALIBRATE(Z)) backlash.set_distance_mm(Z_AXIS, m.backlash[TOP])); #if HAS_I_CENTER - backlash.distance_mm.i = (m.backlash[IMINIMUM] + m.backlash[IMAXIMUM]) / 2; + backlash.set_distance_mm(I_AXIS, (m.backlash[IMINIMUM] + m.backlash[IMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_IMIN) - backlash.distance_mm.i = m.backlash[IMINIMUM]; + backlash.set_distance_mm(I_AXIS, m.backlash[IMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_IMAX) - backlash.distance_mm.i = m.backlash[IMAXIMUM]; + backlash.set_distance_mm(I_AXIS, m.backlash[IMAXIMUM]); #endif #if HAS_J_CENTER - backlash.distance_mm.j = (m.backlash[JMINIMUM] + m.backlash[JMAXIMUM]) / 2; + backlash.set_distance_mm(J_AXIS, (m.backlash[JMINIMUM] + m.backlash[JMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_JMIN) - backlash.distance_mm.j = m.backlash[JMINIMUM]; + backlash.set_distance_mm(J_AXIS, m.backlash[JMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_JMAX) - backlash.distance_mm.j = m.backlash[JMAXIMUM]; + backlash.set_distance_mm(J_AXIS, m.backlash[JMAXIMUM]); #endif #if HAS_K_CENTER - backlash.distance_mm.k = (m.backlash[KMINIMUM] + m.backlash[KMAXIMUM]) / 2; + backlash.set_distance_mm(K_AXIS, (m.backlash[KMINIMUM] + m.backlash[KMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_KMIN) - backlash.distance_mm.k = m.backlash[KMINIMUM]; + backlash.set_distance_mm(K_AXIS, m.backlash[KMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_KMAX) - backlash.distance_mm.k = m.backlash[KMAXIMUM]; + backlash.set_distance_mm(K_AXIS, m.backlash[KMAXIMUM]); #endif #endif // BACKLASH_GCODE @@ -583,7 +595,7 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { // allowed directions to take up any backlash { // New scope for TEMPORARY_BACKLASH_CORRECTION - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); const xyz_float_t move = LINEAR_AXIS_ARRAY( AXIS_CAN_CALIBRATE(X) * 3, AXIS_CAN_CALIBRATE(Y) * 3, AXIS_CAN_CALIBRATE(Z) * 3, @@ -613,7 +625,7 @@ inline void update_measurements(measurements_t &m, const AxisEnum axis) { * - Call calibrate_backlash() beforehand for best accuracy */ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const uint8_t extruder) { - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); TERN(HAS_MULTI_HOTEND, set_nozzle(m, extruder), UNUSED(extruder)); @@ -650,7 +662,7 @@ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const * uncertainty in - How far away from the object to begin probing */ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty) { - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); HOTEND_LOOP() calibrate_toolhead(m, uncertainty, e); @@ -666,7 +678,7 @@ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty) * 1) For each nozzle, touch top and sides of object to determine object position and * nozzle offsets. Do a fast but rough search over a wider area. * 2) With the first nozzle, touch top and sides of object to determine backlash values - * for all axis (if BACKLASH_GCODE is enabled) + * for all axes (if BACKLASH_GCODE is enabled) * 3) For each nozzle, touch top and sides of object slowly to determine precise * position of object. Adjust coordinate system and nozzle offsets so probed object * location corresponds to known object location with a high degree of precision. @@ -676,7 +688,7 @@ inline void calibrate_all() { TERN_(HAS_HOTEND_OFFSET, reset_hotend_offsets()); - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); // Do a fast and rough calibration of the toolheads diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 21bb2c759006..ad13b20306ae 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -109,7 +109,9 @@ static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibra auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) { do_z_clearance(5.0); // Raise nozzle before probing + ptc.set_enabled(false); const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false + ptc.set_enabled(true); if (isnan(measured_z)) SERIAL_ECHOLNPGM("!Received NAN. Aborting."); else { diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index 190af0f71bbe..6b1f56fcf658 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -55,7 +55,7 @@ void GcodeSuite::M425() { case Z_AXIS: return AXIS_CAN_CALIBRATE(Z), case I_AXIS: return AXIS_CAN_CALIBRATE(I), case J_AXIS: return AXIS_CAN_CALIBRATE(J), - case K_AXIS: return AXIS_CAN_CALIBRATE(K), + case K_AXIS: return AXIS_CAN_CALIBRATE(K) ); } }; @@ -63,7 +63,7 @@ void GcodeSuite::M425() { LOOP_LINEAR_AXES(a) { if (axis_can_calibrate(a) && parser.seen(AXIS_CHAR(a))) { planner.synchronize(); - backlash.distance_mm[a] = parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a)); + backlash.set_distance_mm(AxisEnum(a), parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a))); noArgs = false; } } @@ -77,25 +77,25 @@ void GcodeSuite::M425() { #ifdef BACKLASH_SMOOTHING_MM if (parser.seen('S')) { planner.synchronize(); - backlash.smoothing_mm = parser.value_linear_units(); + backlash.set_smoothing_mm(parser.value_linear_units()); noArgs = false; } #endif if (noArgs) { SERIAL_ECHOPGM("Backlash Correction "); - if (!backlash.correction) SERIAL_ECHOPGM("in"); + if (!backlash.get_correction_uint8()) SERIAL_ECHOPGM("in"); SERIAL_ECHOLNPGM("active:"); SERIAL_ECHOLNPGM(" Correction Amount/Fade-out: F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)"); SERIAL_ECHOPGM(" Backlash Distance (mm): "); LOOP_LINEAR_AXES(a) if (axis_can_calibrate(a)) { SERIAL_CHAR(' ', AXIS_CHAR(a)); - SERIAL_ECHO(backlash.distance_mm[a]); + SERIAL_ECHO(backlash.get_distance_mm(AxisEnum(a))); SERIAL_EOL(); } #ifdef BACKLASH_SMOOTHING_MM - SERIAL_ECHOLNPGM(" Smoothing (mm): S", backlash.smoothing_mm); + SERIAL_ECHOLNPGM(" Smoothing (mm): S", backlash.get_smoothing_mm()); #endif #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) @@ -118,15 +118,15 @@ void GcodeSuite::M425_report(const bool forReplay/*=true*/) { SERIAL_ECHOLNPGM_P( PSTR(" M425 F"), backlash.get_correction() #ifdef BACKLASH_SMOOTHING_MM - , PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm) + , PSTR(" S"), LINEAR_UNIT(backlash.get_smoothing_mm()) #endif , LIST_N(DOUBLE(LINEAR_AXES), - SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x), - SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y), - SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z), - SP_I_STR, LINEAR_UNIT(backlash.distance_mm.i), - SP_J_STR, LINEAR_UNIT(backlash.distance_mm.j), - SP_K_STR, LINEAR_UNIT(backlash.distance_mm.k) + SP_X_STR, LINEAR_UNIT(backlash.get_distance_mm(X_AXIS)), + SP_Y_STR, LINEAR_UNIT(backlash.get_distance_mm(Y_AXIS)), + SP_Z_STR, LINEAR_UNIT(backlash.get_distance_mm(Z_AXIS)), + SP_I_STR, LINEAR_UNIT(backlash.get_distance_mm(I_AXIS)), + SP_J_STR, LINEAR_UNIT(backlash.get_distance_mm(J_AXIS)), + SP_K_STR, LINEAR_UNIT(backlash.get_distance_mm(K_AXIS)) ) ); } diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 913ffe30d478..8b6ea0bf1fae 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -35,11 +35,15 @@ #include "../../module/planner.h" #endif +#if HAS_PTC + #include "../../feature/probe_temp_comp.h" +#endif + /** * M48: Z probe repeatability measurement function. * * Usage: - * M48 + * M48 * P = Number of sampled points (4-50, default 10) * X = Sample X position * Y = Sample Y position @@ -47,6 +51,7 @@ * E = Engage Z probe for each reading * L = Number of legs of movement before probe * S = Schizoid (Or Star if you prefer) + * C = Enable probe temperature compensation (0 or 1, default 1) * * This function requires the machine to be homed before invocation. */ @@ -107,6 +112,8 @@ void GcodeSuite::M48() { set_bed_leveling_enabled(false); #endif + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); + // Work with reasonable feedrates remember_feedrate_scaling_off(); @@ -269,6 +276,9 @@ void GcodeSuite::M48() { // Re-enable bed level correction if it had been on TERN_(HAS_LEVELING, set_bed_leveling_enabled(was_enabled)); + // Re-enable probe temperature correction + TERN_(HAS_PTC, ptc.set_enabled(true)); + report_current_position(); } diff --git a/Marlin/src/gcode/calibrate/M852.cpp b/Marlin/src/gcode/calibrate/M852.cpp index b24a449652a3..6c661dcd61d9 100644 --- a/Marlin/src/gcode/calibrate/M852.cpp +++ b/Marlin/src/gcode/calibrate/M852.cpp @@ -93,7 +93,7 @@ void GcodeSuite::M852() { void GcodeSuite::M852_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_SKEW_FACTOR)); - SERIAL_ECHOPAIR_F(" M851 I", planner.skew_factor.xy, 6); + SERIAL_ECHOPAIR_F(" M852 I", planner.skew_factor.xy, 6); #if ENABLED(SKEW_CORRECTION_FOR_Z) SERIAL_ECHOPAIR_F(" J", planner.skew_factor.xz, 6); SERIAL_ECHOPAIR_F(" K", planner.skew_factor.yz, 6); diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index 7b7ce5e10d7f..9490e3c625f3 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -253,7 +253,7 @@ void GcodeSuite::M205() { if (parser.seenval('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units(); if (parser.seenval('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units(); #if HAS_JUNCTION_DEVIATION - #if HAS_CLASSIC_JERK && (AXIS4_NAME == 'J' || AXIS5_NAME == 'J' || AXIS6_NAME == 'J') + #if HAS_CLASSIC_JERK && AXIS_COLLISION('J') #error "Can't set_max_jerk for 'J' axis because 'J' is used for Junction Deviation." #endif if (parser.seenval('J')) { @@ -288,8 +288,13 @@ void GcodeSuite::M205_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F( "Advanced (B S T" TERN_(HAS_JUNCTION_DEVIATION, " J") - TERN_(HAS_CLASSIC_JERK, " X Y Z") - TERN_(HAS_CLASSIC_E_JERK, " E") + #if HAS_CLASSIC_JERK + LINEAR_AXIS_GANG( + " X", " Y", " Z", + " " STR_I "", " " STR_J "", " " STR_K "" + ) + #endif + TERN_(HAS_CLASSIC_E_JERK, " E") ")" )); SERIAL_ECHOLNPGM_P( diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 7576272a48b6..344adc34e320 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -50,6 +50,9 @@ * W[linear] 0/1 Enable park & Z Raise * X[linear] Park X (Requires TOOLCHANGE_PARK) * Y[linear] Park Y (Requires TOOLCHANGE_PARK) + * I[linear] Park I (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 4) + * J[linear] Park J (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 5) + * K[linear] Park K (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 6) * Z[linear] Z Raise * F[linear] Fan Speed 0-255 * G[linear/s] Fan time @@ -88,10 +91,23 @@ void GcodeSuite::M217() { #if ENABLED(TOOLCHANGE_PARK) if (parser.seenval('W')) { toolchange_settings.enable_park = parser.value_linear_units(); } if (parser.seenval('X')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.x = constrain(v, X_MIN_POS, X_MAX_POS); } - if (parser.seenval('Y')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.y = constrain(v, Y_MIN_POS, Y_MAX_POS); } + #if HAS_Y_AXIS + if (parser.seenval('Y')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.y = constrain(v, Y_MIN_POS, Y_MAX_POS); } + #endif + #if HAS_I_AXIS + if (parser.seenval('I')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.i = constrain(v, I_MIN_POS, I_MAX_POS); } + #endif + #if HAS_J_AXIS + if (parser.seenval('J')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.j = constrain(v, J_MIN_POS, J_MAX_POS); } + #endif + #if HAS_K_AXIS + if (parser.seenval('K')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.k = constrain(v, K_MIN_POS, K_MAX_POS); } + #endif #endif - if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); } + #if HAS_Z_AXIS + if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); } + #endif #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) migration.target = 0; // 0 = disabled @@ -151,9 +167,24 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { #endif #if ENABLED(TOOLCHANGE_PARK) + { SERIAL_ECHOPGM(" W", LINEAR_UNIT(toolchange_settings.enable_park)); - SERIAL_ECHOPGM_P(SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x)); - SERIAL_ECHOPGM_P(SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y)); + SERIAL_ECHOPGM_P( + SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x) + #if HAS_Y_AXIS + , SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y) + #endif + #if HAS_I_AXIS + , SP_I_STR, LINEAR_UNIT(toolchange_settings.change_point.i) + #endif + #if HAS_J_AXIS + , SP_J_STR, LINEAR_UNIT(toolchange_settings.change_point.j) + #endif + #if HAS_K_AXIS + , SP_K_STR, LINEAR_UNIT(toolchange_settings.change_point.k) + #endif + ); + } #endif #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) diff --git a/Marlin/src/gcode/config/M302.cpp b/Marlin/src/gcode/config/M302.cpp index e271dcd469ee..9f4d569d7b2e 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -27,6 +27,10 @@ #include "../gcode.h" #include "../../module/temperature.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin_defines.h" +#endif + /** * M302: Allow cold extrudes, or set the minimum extrude temperature * @@ -47,6 +51,7 @@ void GcodeSuite::M302() { if (seen_S) { thermalManager.extrude_min_temp = parser.value_celsius(); thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0); + TERN_(DWIN_LCD_PROUI, HMI_data.ExtMinT = thermalManager.extrude_min_temp); } if (parser.seen('P')) diff --git a/Marlin/src/gcode/config/M672.cpp b/Marlin/src/gcode/config/M672.cpp index af74230516e1..257b49471f61 100644 --- a/Marlin/src/gcode/config/M672.cpp +++ b/Marlin/src/gcode/config/M672.cpp @@ -53,7 +53,7 @@ // b7 b6 b5 b4 ~b4 ... hi bits, NOT last bit // b3 b2 b1 b0 ~b0 ... lo bits, NOT last bit // -void M672_send(uint8_t b) { // bit rate requirement: 1KHz +/- 30% +void M672_send(uint8_t b) { // bit rate requirement: 1kHz +/- 30% LOOP_L_N(bits, 14) { switch (bits) { default: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !!(b & 0x80)); b <<= 1; break; } // send bit, shift next into place diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index 54fe698f97b2..8f527919fd83 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -24,7 +24,7 @@ #include "../../module/planner.h" /** - * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E. + * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, [I, [J, [K]]] and E. * (Follows the same syntax as G92) * * With multiple extruders use T to specify which one. diff --git a/Marlin/src/gcode/control/M111.cpp b/Marlin/src/gcode/control/M111.cpp index 08c39b762ea4..d6aeb774108b 100644 --- a/Marlin/src/gcode/control/M111.cpp +++ b/Marlin/src/gcode/control/M111.cpp @@ -34,12 +34,12 @@ void GcodeSuite::M111() { static PGMSTR(str_debug_8, STR_DEBUG_DRYRUN); static PGMSTR(str_debug_16, STR_DEBUG_COMMUNICATION); #if ENABLED(DEBUG_LEVELING_FEATURE) - static PGMSTR(str_debug_lvl, STR_DEBUG_LEVELING); + static PGMSTR(str_debug_detail, STR_DEBUG_DETAIL); #endif static PGM_P const debug_strings[] PROGMEM = { str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16, - TERN_(DEBUG_LEVELING_FEATURE, str_debug_lvl) + TERN_(DEBUG_LEVELING_FEATURE, str_debug_detail) }; SERIAL_ECHO_START(); diff --git a/Marlin/src/gcode/control/M3-M5.cpp b/Marlin/src/gcode/control/M3-M5.cpp index ecae8b06c69f..2cf22e81ce0c 100644 --- a/Marlin/src/gcode/control/M3-M5.cpp +++ b/Marlin/src/gcode/control/M3-M5.cpp @@ -43,7 +43,7 @@ * * If no PWM pin is defined then M3/M4 just turns it on. * - * At least 12.8KHz (50Hz * 256) is needed for Spindle PWM. + * At least 12.8kHz (50Hz * 256) is needed for Spindle PWM. * Hardware PWM is required on AVR. ISRs are too slow. * * NOTE: WGM for timers 3, 4, and 5 must be either Mode 1 or Mode 5. @@ -66,21 +66,23 @@ * PWM duty cycle goes from 0 (off) to 255 (always on). */ void GcodeSuite::M3_M4(const bool is_M4) { - auto get_s_power = [] { - if (parser.seenval('S')) { - const float spwr = parser.value_float(); - #if ENABLED(SPINDLE_SERVO) - cutter.unitPower = spwr; - #else - cutter.unitPower = TERN(SPINDLE_LASER_USE_PWM, - cutter.power_to_range(cutter_power_t(round(spwr))), - spwr > 0 ? 255 : 0); - #endif - } - else - cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); - return cutter.unitPower; - }; + #if EITHER(SPINDLE_LASER_USE_PWM, SPINDLE_SERVO) + auto get_s_power = [] { + if (parser.seenval('S')) { + const float spwr = parser.value_float(); + #if ENABLED(SPINDLE_SERVO) + cutter.unitPower = spwr; + #else + cutter.unitPower = TERN(SPINDLE_LASER_USE_PWM, + cutter.power_to_range(cutter_power_t(round(spwr))), + spwr > 0 ? 255 : 0); + #endif + } + else + cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); + return cutter.unitPower; + }; + #endif #if ENABLED(LASER_POWER_INLINE) if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) { diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index 77c0ccc49b0f..1b3a29d10056 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -52,7 +52,7 @@ void protected_pin_err() { * S Pin status from 0 - 255 * I Flag to ignore Marlin's pin protection * - * M Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN + * T Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN */ void GcodeSuite::M42() { const int pin_index = PARSED_PIN_INDEX('P', GET_PIN_MAP_INDEX(LED_PIN)); @@ -63,7 +63,7 @@ void GcodeSuite::M42() { if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err(); bool avoidWrite = false; - if (parser.seenval('M')) { + if (parser.seenval('T')) { switch (parser.value_byte()) { case 0: pinMode(pin, INPUT); avoidWrite = true; break; case 1: pinMode(pin, OUTPUT); break; @@ -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 set_pwm_duty() + // A simple I/O will be set to 0 by hal.set_pwm_duty() if (pin_status <= 1 && !PWM_PIN(pin)) return; #endif - set_pwm_duty(pin, pin_status); + hal.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 b8be9daa4015..90b25e7ed34d 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -63,7 +63,7 @@ OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_STATE); #endif - TERN_(HAS_LCD_MENU, ui.reset_status()); + TERN_(HAS_MARLINUI_MENU, ui.reset_status()); } #endif // PSU_CONTROL @@ -79,20 +79,42 @@ void GcodeSuite::M81() { print_job_timer.stop(); - #if HAS_FAN - #if ENABLED(PROBING_FANS_OFF) - thermalManager.fans_paused = false; - ZERO(thermalManager.saved_fan_speed); - #endif + #if BOTH(HAS_FAN, PROBING_FANS_OFF) + thermalManager.fans_paused = false; + ZERO(thermalManager.saved_fan_speed); #endif safe_delay(1000); // Wait 1 second before switching off + LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF "."); + + bool delayed_power_off = false; + + #if ENABLED(POWER_OFF_TIMER) + if (parser.seenval('D')) { + uint16_t delay = parser.value_ushort(); + if (delay > 1) { // skip already observed 1s delay + delayed_power_off = true; + powerManager.setPowerOffTimer(SEC_TO_MS(delay - 1)); + } + } + #endif + + #if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + if (parser.boolval('S')) { + delayed_power_off = true; + powerManager.setPowerOffOnCooldown(true); + } + #endif + + if (delayed_power_off) { + SERIAL_ECHOLNPGM(STR_DELAYED_POWEROFF); + return; + } + #if HAS_SUICIDE suicide(); #elif ENABLED(PSU_CONTROL) powerManager.power_off_soon(); #endif - - LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF "."); } diff --git a/Marlin/src/gcode/control/M997.cpp b/Marlin/src/gcode/control/M997.cpp index 73d795bcefc8..74ed8b0d073e 100644 --- a/Marlin/src/gcode/control/M997.cpp +++ b/Marlin/src/gcode/control/M997.cpp @@ -24,8 +24,8 @@ #if ENABLED(PLATFORM_M997_SUPPORT) -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif /** @@ -33,7 +33,7 @@ */ void GcodeSuite::M997() { - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_RebootScreen()); + TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen()); flashFirmware(parser.intval('S')); diff --git a/Marlin/src/gcode/control/M999.cpp b/Marlin/src/gcode/control/M999.cpp index b7219673a3d6..b7d6db9f2312 100644 --- a/Marlin/src/gcode/control/M999.cpp +++ b/Marlin/src/gcode/control/M999.cpp @@ -22,7 +22,7 @@ #include "../gcode.h" -#include "../../lcd/marlinui.h" // for lcd_reset_alert_level +#include "../../lcd/marlinui.h" // for ui.reset_alert_level #include "../../MarlinCore.h" // for marlin_state #include "../queue.h" // for flush_and_request_resend diff --git a/Marlin/src/gcode/eeprom/M500-M504.cpp b/Marlin/src/gcode/eeprom/M500-M504.cpp index a06e98ad1ea7..412d0033558f 100644 --- a/Marlin/src/gcode/eeprom/M500-M504.cpp +++ b/Marlin/src/gcode/eeprom/M500-M504.cpp @@ -25,6 +25,11 @@ #include "../../core/serial.h" #include "../../inc/MarlinConfig.h" +#if ENABLED(CONFIGURATION_EMBEDDING) + #include "../../sd/SdBaseFile.h" + #include "../../mczip.h" +#endif + /** * M500: Store settings in EEPROM */ @@ -50,9 +55,24 @@ void GcodeSuite::M502() { /** * M503: print settings currently in memory + * + * S : Include / exclude header comments in the output. (Default: S1) + * + * With CONFIGURATION_EMBEDDING: + * C : Save the full Marlin configuration to SD Card as "mc.zip" */ void GcodeSuite::M503() { (void)settings.report(!parser.boolval('S', true)); + + #if ENABLED(CONFIGURATION_EMBEDDING) + if (parser.seen_test('C')) { + SdBaseFile file; + const uint16_t size = sizeof(mc_zip); + // Need to create the config size on the SD card + if (file.open("mc.zip", O_WRITE|O_CREAT) && file.write(pgm_read_ptr(mc_zip), size) != -1 && file.close()) + SERIAL_ECHO_MSG("Configuration saved as 'mc.zip'"); + } + #endif } #endif // !DISABLE_M503 diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp index d058ce5501ae..f55405b798ad 100644 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ b/Marlin/src/gcode/feature/L6470/M906.cpp @@ -24,6 +24,10 @@ #if HAS_L64XX +#if AXIS_COLLISION('I') + #error "M906 parameter collision with axis name." +#endif + #include "../../gcode.h" #include "../../../libs/L64XX/L64XX_Marlin.h" #include "../../../module/stepper/indirection.h" @@ -202,12 +206,11 @@ void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) { * On L6474 this sets the TVAL register (same address). * * I - select which driver(s) to change on multi-driver axis - * 0 - (default) all drivers on the axis or E0 - * 1 - monitor only X, Y, Z or E1 - * 2 - monitor only X2, Y2, Z2 or E2 - * 3 - monitor only Z3 or E3 - * 4 - monitor only Z4 or E4 - * 5 - monitor only E5 + * (default) all drivers on the axis + * 0 - monitor only the first XYZ... driver + * 1 - monitor only X2, Y2, Z2 + * 2 - monitor only Z3 + * 3 - monitor only Z4 * Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional) * L6474 - current in mA (4A max) * All others - 0-255 @@ -227,8 +230,10 @@ void GcodeSuite::M906() { uint8_t report_current = true; - #if HAS_L64XX - const uint8_t index = parser.byteval('I'); + #if AXIS_IS_L64XX(X2) || AXIS_IS_L64XX(Y2) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) + const int8_t index = parser.byteval('I', -1); + #else + constexpr int8_t index = -1; #endif LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { @@ -241,73 +246,72 @@ void GcodeSuite::M906() { } switch (i) { - case X_AXIS: - #if AXIS_IS_L64XX(X) - if (index == 0) L6470_SET_KVAL_HOLD(X); - #endif - #if AXIS_IS_L64XX(X2) - if (index == 1) L6470_SET_KVAL_HOLD(X2); - #endif - break; - - #if HAS_Y_AXIS + #if AXIS_IS_L64XX(X) || AXIS_IS_L64XX(X2) + case X_AXIS: + #if AXIS_IS_L64XX(X) + if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(X); + #endif + #if AXIS_IS_L64XX(X2) + if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(X2); + #endif + break; + #endif + + #if AXIS_IS_L64XX(Y) || AXIS_IS_L64XX(Y2) case Y_AXIS: #if AXIS_IS_L64XX(Y) - if (index == 0) L6470_SET_KVAL_HOLD(Y); + if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Y); #endif #if AXIS_IS_L64XX(Y2) - if (index == 1) L6470_SET_KVAL_HOLD(Y2); + if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Y2); #endif break; #endif - #if HAS_Z_AXIS + #if AXIS_IS_L64XX(Z) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) case Z_AXIS: #if AXIS_IS_L64XX(Z) - if (index == 0) L6470_SET_KVAL_HOLD(Z); + if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Z); #endif #if AXIS_IS_L64XX(Z2) - if (index == 1) L6470_SET_KVAL_HOLD(Z2); + if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Z2); #endif #if AXIS_IS_L64XX(Z3) - if (index == 2) L6470_SET_KVAL_HOLD(Z3); + if (index < 0 || index == 2) L6470_SET_KVAL_HOLD(Z3); #endif - #if AXIS_DRIVER_TYPE_Z4(L6470) - if (index == 3) L6470_SET_KVAL_HOLD(Z4); + #if AXIS_IS_L64XX(Z4) + if (index < 0 || index == 3) L6470_SET_KVAL_HOLD(Z4); #endif break; #endif - #if E_STEPPERS + #if AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7) case E_AXIS: { - 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) - case 0: L6470_SET_KVAL_HOLD(E0); break; - #endif - #if AXIS_IS_L64XX(E1) - case 1: L6470_SET_KVAL_HOLD(E1); break; - #endif - #if AXIS_IS_L64XX(E2) - case 2: L6470_SET_KVAL_HOLD(E2); break; - #endif - #if AXIS_IS_L64XX(E3) - case 3: L6470_SET_KVAL_HOLD(E3); break; - #endif - #if AXIS_IS_L64XX(E4) - case 4: L6470_SET_KVAL_HOLD(E4); break; - #endif - #if AXIS_IS_L64XX(E5) - case 5: L6470_SET_KVAL_HOLD(E5); break; - #endif - #if AXIS_IS_L64XX(E6) - case 6: L6470_SET_KVAL_HOLD(E6); break; - #endif - #if AXIS_IS_L64XX(E7) - case 7: L6470_SET_KVAL_HOLD(E7); break; - #endif - } + const int8_t eindex = get_target_e_stepper_from_command(-2); + #if AXIS_IS_L64XX(E0) + if (eindex < 0 || eindex == 0) L6470_SET_KVAL_HOLD(E0); + #endif + #if AXIS_IS_L64XX(E1) + if (eindex < 0 || eindex == 1) L6470_SET_KVAL_HOLD(E1); + #endif + #if AXIS_IS_L64XX(E2) + if (eindex < 0 || eindex == 2) L6470_SET_KVAL_HOLD(E2); + #endif + #if AXIS_IS_L64XX(E3) + if (eindex < 0 || eindex == 3) L6470_SET_KVAL_HOLD(E3); + #endif + #if AXIS_IS_L64XX(E4) + if (eindex < 0 || eindex == 4) L6470_SET_KVAL_HOLD(E4); + #endif + #if AXIS_IS_L64XX(E5) + if (eindex < 0 || eindex == 5) L6470_SET_KVAL_HOLD(E5); + #endif + #if AXIS_IS_L64XX(E6) + if (eindex < 0 || eindex == 6) L6470_SET_KVAL_HOLD(E6); + #endif + #if AXIS_IS_L64XX(E7) + if (eindex < 0 || eindex == 7) L6470_SET_KVAL_HOLD(E7); + #endif } break; #endif } diff --git a/Marlin/src/gcode/feature/L6470/M916-918.cpp b/Marlin/src/gcode/feature/L6470/M916-M918.cpp similarity index 100% rename from Marlin/src/gcode/feature/L6470/M916-918.cpp rename to Marlin/src/gcode/feature/L6470/M916-M918.cpp diff --git a/Marlin/src/gcode/feature/adc/M3426.cpp b/Marlin/src/gcode/feature/adc/M3426.cpp new file mode 100644 index 000000000000..8205fa01f2bd --- /dev/null +++ b/Marlin/src/gcode/feature/adc/M3426.cpp @@ -0,0 +1,63 @@ +/** + * 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 . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if ENABLED(HAS_MCP3426_ADC) + +#include "../../gcode.h" + +#include "../../../feature/adc/adc_mcp3426.h" + +/** + * M3426: Read 16 bit (signed) value from I2C MCP3426 ADC device + * + * M3426 C channel 1 or 2 + * M3426 G gain 1, 2, 4 or 8 + * M3426 I 0 or 1, invert reply + */ +void GcodeSuite::M3426() { + uint8_t channel = parser.byteval('C', 1), // Select the channel 1 or 2 + gain = parser.byteval('G', 1); + const bool inverted = parser.byteval('I') == 1; + + if (channel <= 2 && (gain == 1 || gain == 2 || gain == 4 || gain == 8)) { + int16_t result = mcp3426.ReadValue(channel, gain); + + if (mcp3426.Error == false) { + if (inverted) { + // Should we invert the reading (32767 - ADC value) ? + // Caters to end devices that expect values to increase when in reality they decrease. + // e.g., A pressure sensor in a vacuum when the end device expects a positive pressure. + result = INT16_MAX - result; + } + //SERIAL_ECHOPGM(STR_OK); + SERIAL_ECHOLNPGM("V:", result, " C:", channel, " G:", gain, " I:", inverted ? 1 : 0); + } + else + SERIAL_ERROR_MSG("MCP342X i2c error"); + } + else + SERIAL_ERROR_MSG("MCP342X Bad request"); +} + +#endif // HAS_MCP3426_ADC diff --git a/Marlin/src/gcode/feature/clean/G12.cpp b/Marlin/src/gcode/feature/clean/G12.cpp index a0b87b1abc9e..999a9b10bd85 100644 --- a/Marlin/src/gcode/feature/clean/G12.cpp +++ b/Marlin/src/gcode/feature/clean/G12.cpp @@ -46,7 +46,8 @@ */ void GcodeSuite::G12() { // Don't allow nozzle cleaning without homing first - if (homing_needed_error()) return; + if (homing_needed_error(linear_bits & ~TERN0(NOZZLE_CLEAN_NO_Z, Z_AXIS) & ~TERN0(NOZZLE_CLEAN_NO_Y, Y_AXIS))) + return; #ifdef WIPE_SEQUENCE_COMMANDS if (!parser.seen_any()) { diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index 757cffd47383..95adde3ea532 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -39,7 +39,9 @@ #endif /** - * M907: Set digital trimpot motor current using axis codes X, Y, Z, E, B, S + * M907: Set digital trimpot motor current using axis codes X [Y] [Z] [E] + * B - Special case for 4th (E) axis + * S - Special case to set first 3 axes */ void GcodeSuite::M907() { #if HAS_MOTOR_CURRENT_SPI @@ -75,7 +77,7 @@ void GcodeSuite::M907() { if (parser.seenval('E')) stepper.set_digipot_current(2, parser.value_int()); #endif - #endif + #endif // HAS_MOTOR_CURRENT_PWM #if HAS_MOTOR_CURRENT_I2C // this one uses actual amps in floating point diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 45278fe1f5d6..f01c220d0131 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -54,7 +54,7 @@ */ void GcodeSuite::M150() { #if ENABLED(NEOPIXEL_LED) - const int8_t index = parser.intval('I', -1); + const pixel_index_t index = parser.intval('I', -1); #if ENABLED(NEOPIXEL2_SEPARATE) int8_t brightness = neo.brightness(), unit = parser.intval('S', -1); switch (unit) { diff --git a/Marlin/src/gcode/feature/pause/G60.cpp b/Marlin/src/gcode/feature/pause/G60.cpp index 4c7190091cfc..d4770577a65f 100644 --- a/Marlin/src/gcode/feature/pause/G60.cpp +++ b/Marlin/src/gcode/feature/pause/G60.cpp @@ -47,13 +47,16 @@ void GcodeSuite::G60() { SBI(saved_slots[slot >> 3], slot & 0x07); #if ENABLED(SAVED_POSITIONS_DEBUG) + { DEBUG_ECHOPGM(STR_SAVED_POS " S", slot); const xyze_pos_t &pos = stored_position[slot]; DEBUG_ECHOLNPAIR_F_P( - LIST_N(DOUBLE(LOGICAL_AXES), SP_E_STR, pos.e, - PSTR(" : X"), pos.x, SP_Y_STR, pos.y, SP_Z_STR, pos.z, - SP_I_STR, pos.i, SP_J_STR, pos.j, SP_K_STR, pos.k) + LIST_N(DOUBLE(LINEAR_AXES), PSTR(" : X"), pos.x, SP_Y_STR, pos.y, SP_Z_STR, pos.z, SP_I_STR, pos.i, SP_J_STR, pos.j, SP_K_STR, pos.k) + #if HAS_EXTRUDERS + , SP_E_STR, pos.e + #endif ); + } #endif } diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index f3e5a2ab387a..e0e1983a2574 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -41,7 +41,7 @@ * * If XYZE are not given, default restore uses the smart blocking move. */ -void GcodeSuite::G61(void) { +void GcodeSuite::G61() { const uint8_t slot = parser.byteval('S'); @@ -68,7 +68,7 @@ void GcodeSuite::G61(void) { SYNC_E(stored_position[slot].e); } else { - if (parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR))) { + if (parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K))) { DEBUG_ECHOPGM(STR_RESTORING_POS " S", slot); LOOP_LINEAR_AXES(i) { destination[i] = parser.seen(AXIS_CHAR(i)) diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index bc31e1225d86..940e1b369bc6 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -49,6 +49,9 @@ * L = Override retract Length * X = Override park position X * Y = Override park position Y + * A = Override park position A (requires AXIS*_NAME 'A') + * B = Override park position B (requires AXIS*_NAME 'B') + * C = Override park position C (requires AXIS*_NAME 'C') * Z = Override Z raise * * With an LCD menu: @@ -60,9 +63,15 @@ void GcodeSuite::M125() { xyz_pos_t park_point = NOZZLE_PARK_POINT; - // Move XY axes to filament change position or given position - if (parser.seenval('X')) park_point.x = RAW_X_POSITION(parser.linearval('X')); - if (parser.seenval('Y')) park_point.y = RAW_X_POSITION(parser.linearval('Y')); + // Move to filament change position or given position + LINEAR_AXIS_CODE( + if (parser.seenval('X')) park_point.x = RAW_X_POSITION(parser.linearval('X')), + if (parser.seenval('Y')) park_point.y = RAW_Y_POSITION(parser.linearval('Y')), + NOOP, + if (parser.seenval(AXIS4_NAME)) park_point.i = RAW_I_POSITION(parser.linearval(AXIS4_NAME)), + if (parser.seenval(AXIS5_NAME)) park_point.j = RAW_J_POSITION(parser.linearval(AXIS5_NAME)), + if (parser.seenval(AXIS6_NAME)) park_point.k = RAW_K_POSITION(parser.linearval(AXIS6_NAME)) + ); // Lift Z axis if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); @@ -76,7 +85,7 @@ void GcodeSuite::M125() { ui.pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT); // If possible, show an LCD prompt with the 'P' flag - const bool show_lcd = TERN0(HAS_LCD_MENU, parser.boolval('P')); + const bool show_lcd = TERN0(HAS_MARLINUI_MENU, parser.boolval('P')); if (pause_print(retract, park_point, show_lcd, 0)) { if (ENABLED(EXTENSIBLE_UI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) || !sd_printing || show_lcd) { diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 541fa08350e6..1679c90687bd 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -34,8 +34,11 @@ #include "../../../module/tool_change.h" #endif -#if ENABLED(MMU2_MENUS) - #include "../../../lcd/menu/menu_mmu2.h" +#if ENABLED(HAS_PRUSA_MMU2) + #include "../../../feature/mmu/mmu2.h" + #if ENABLED(MMU2_MENUS) + #include "../../../lcd/menu/menu_mmu2.h" + #endif #endif #if ENABLED(MIXING_EXTRUDER) @@ -64,13 +67,13 @@ void GcodeSuite::M600() { #if ENABLED(MIXING_EXTRUDER) - const int8_t target_e_stepper = get_target_e_stepper_from_command(); - if (target_e_stepper < 0) return; + const int8_t eindex = get_target_e_stepper_from_command(); + if (eindex < 0) return; const uint8_t old_mixing_tool = mixer.get_current_vtool(); mixer.T(MIXER_DIRECT_SET_TOOL); - MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0); + MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0); mixer.normalize(); const int8_t target_extruder = active_extruder; @@ -92,21 +95,20 @@ void GcodeSuite::M600() { } #endif + const bool standardM600 = TERN1(MMU2_MENUS, !mmu2.enabled()); + // Show initial "wait for start" message - #if DISABLED(MMU2_MENUS) + if (standardM600) ui.pause_show_message(PAUSE_MESSAGE_CHANGING, PAUSE_MODE_PAUSE_PRINT, target_extruder); - #endif - #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE) - // If needed, home before parking for filament change - home_if_needed(true); - #endif + // If needed, home before parking for filament change + TERN_(HOME_BEFORE_FILAMENT_CHANGE, home_if_needed(true)); #if HAS_MULTI_EXTRUDER // Change toolhead if specified const uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !idex_is_duplicating())) - tool_change(target_extruder, false); + tool_change(target_extruder); #endif // Initial retract before move to filament change position @@ -114,29 +116,26 @@ void GcodeSuite::M600() { xyz_pos_t park_point NOZZLE_PARK_POINT; - // Lift Z axis - if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); - // Move XY axes to filament change position or given position - if (parser.seenval('X')) park_point.x = parser.linearval('X'); - if (parser.seenval('Y')) park_point.y = parser.linearval('Y'); + LINEAR_AXIS_CODE( + if (parser.seenval('X')) park_point.x = parser.linearval('X'), + if (parser.seenval('Y')) park_point.y = parser.linearval('Y'), + if (parser.seenval('Z')) park_point.z = parser.linearval('Z'), // Lift Z axis + if (parser.seenval(AXIS4_NAME)) park_point.i = parser.linearval(AXIS4_NAME), + if (parser.seenval(AXIS5_NAME)) park_point.j = parser.linearval(AXIS5_NAME), + if (parser.seenval(AXIS6_NAME)) park_point.k = parser.linearval(AXIS6_NAME) + ); #if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA) park_point += hotend_offset[active_extruder]; #endif #if ENABLED(MMU2_MENUS) - // For MMU2 reset retract and load/unload values so they don't mess with MMU filament handling - constexpr float unload_length = 0.5f, - slow_load_length = 0.0f, - fast_load_length = 0.0f; + // For MMU2, when enabled, reset retract value so it doesn't mess with MMU filament handling + const float unload_length = standardM600 ? -ABS(parser.axisunitsval('U', E_AXIS, fc_settings[active_extruder].unload_length)) : 0.5f; #else // Unload filament const float unload_length = -ABS(parser.axisunitsval('U', E_AXIS, fc_settings[active_extruder].unload_length)); - // Slow load filament - constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH; - // Fast load filament - const float fast_load_length = ABS(parser.axisunitsval('L', E_AXIS, fc_settings[active_extruder].load_length)); #endif const int beep_count = parser.intval('B', -1 @@ -146,20 +145,29 @@ void GcodeSuite::M600() { ); if (pause_print(retract, park_point, true, unload_length DXC_PASS)) { - #if ENABLED(MMU2_MENUS) - mmu2_M600(); - resume_print(slow_load_length, fast_load_length, 0, beep_count DXC_PASS); - #else + if (standardM600) { wait_for_confirmation(true, beep_count DXC_PASS); - resume_print(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, - beep_count, (parser.seenval('R') ? parser.value_celsius() : 0) DXC_PASS); - #endif + resume_print( + FILAMENT_CHANGE_SLOW_LOAD_LENGTH, + ABS(parser.axisunitsval('L', E_AXIS, fc_settings[active_extruder].load_length)), + ADVANCED_PAUSE_PURGE_LENGTH, + beep_count, + parser.celsiusval('R') + DXC_PASS + ); + } + else { + #if ENABLED(MMU2_MENUS) + mmu2_M600(); + resume_print(0, 0, 0, beep_count, 0 DXC_PASS); + #endif + } } #if HAS_MULTI_EXTRUDER // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) - tool_change(active_extruder_before_filament_change, false); + tool_change(active_extruder_before_filament_change); #endif TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index d46bb234bceb..135b3d384ec0 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -60,13 +60,13 @@ void GcodeSuite::M701() { if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0; #if ENABLED(MIXING_EXTRUDER) - const int8_t target_e_stepper = get_target_e_stepper_from_command(); - if (target_e_stepper < 0) return; + const int8_t eindex = get_target_e_stepper_from_command(); + if (eindex < 0) return; const uint8_t old_mixing_tool = mixer.get_current_vtool(); mixer.T(MIXER_DIRECT_SET_TOOL); - MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0); + MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0); mixer.normalize(); const int8_t target_extruder = active_extruder; @@ -85,7 +85,7 @@ void GcodeSuite::M701() { // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) - tool_change(target_extruder, false); + tool_change(target_extruder); #endif auto move_z_by = [](const_float_t zdist) { @@ -124,7 +124,7 @@ void GcodeSuite::M701() { #if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) - tool_change(active_extruder_before_filament_change, false); + tool_change(active_extruder_before_filament_change); #endif TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool @@ -165,10 +165,10 @@ void GcodeSuite::M702() { #endif if (seenT) { - const int8_t target_e_stepper = get_target_e_stepper_from_command(); - if (target_e_stepper < 0) return; + const int8_t eindex = get_target_e_stepper_from_command(); + if (eindex < 0) return; mixer.T(MIXER_DIRECT_SET_TOOL); - MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0); + MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0); mixer.normalize(); } @@ -188,7 +188,7 @@ void GcodeSuite::M702() { // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) - tool_change(target_extruder, false); + tool_change(target_extruder); #endif // Lift Z axis @@ -202,7 +202,7 @@ void GcodeSuite::M702() { #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_UNLOAD_ALL_EXTRUDERS) if (!parser.seenval('T')) { HOTEND_LOOP() { - if (e != active_extruder) tool_change(e, false); + if (e != active_extruder) tool_change(e); unload_filament(-fc_settings[e].unload_length, true, PAUSE_MODE_UNLOAD_FILAMENT); } } @@ -228,7 +228,7 @@ void GcodeSuite::M702() { #if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) - tool_change(active_extruder_before_filament_change, false); + tool_change(active_extruder_before_filament_change); #endif TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool diff --git a/Marlin/src/gcode/feature/power_monitor/M430.cpp b/Marlin/src/gcode/feature/power_monitor/M430.cpp index 642a75d0612a..0f3bb4091421 100644 --- a/Marlin/src/gcode/feature/power_monitor/M430.cpp +++ b/Marlin/src/gcode/feature/power_monitor/M430.cpp @@ -53,9 +53,7 @@ void GcodeSuite::M430() { SERIAL_ECHOLNPGM( #if ENABLED(POWER_MONITOR_CURRENT) "Current: ", power_monitor.getAmps(), "A" - #if ENABLED(POWER_MONITOR_VOLTAGE) - " " - #endif + TERN_(POWER_MONITOR_VOLTAGE, " ") #endif #if ENABLED(POWER_MONITOR_VOLTAGE) "Voltage: ", power_monitor.getVolts(), "V" diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index c086ca842c1d..1629a154bce3 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -33,8 +33,8 @@ #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../../lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../../../lcd/e3v2/jyersui/dwin.h" // Temporary fix until it can be better implemented #endif @@ -54,7 +54,7 @@ inline void plr_error(FSTR_P const prefix) { #endif } -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU void lcd_power_loss_recovery_cancel(); #endif @@ -67,7 +67,7 @@ void GcodeSuite::M1000() { if (recovery.valid()) { if (parser.seen_test('S')) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU ui.goto_screen(menu_job_recovery); #elif HAS_DWIN_E3V2_BASIC recovery.dwin_flag = true; @@ -80,7 +80,7 @@ void GcodeSuite::M1000() { #endif } else if (parser.seen_test('C')) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU lcd_power_loss_recovery_cancel(); #else recovery.cancel(); diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 0ccbfe6341ad..4807d3e8f95b 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -48,9 +48,8 @@ void GcodeSuite::M413() { if (parser.seen_test('W')) recovery.save(true); if (parser.seen_test('P')) recovery.purge(); if (parser.seen_test('D')) recovery.debug(F("M413")); - #if PIN_EXISTS(POWER_LOSS) - if (parser.seen_test('O')) recovery._outage(); - #endif + if (parser.seen_test('O')) recovery._outage(true); + if (parser.seen_test('C')) recovery.check(); if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n")); if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n")); #endif diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index cb33d46d2528..7bfedf8c7210 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -24,6 +24,10 @@ #if HAS_STEALTHCHOP +#if AXIS_COLLISION('I') + #error "M569 parameter collision with axis name." +#endif + #include "../../gcode.h" #include "../../../feature/tmc_util.h" #include "../../../module/stepper/indirection.h" @@ -40,35 +44,35 @@ void tmc_set_stealthChop(TMC &st, const bool enable) { st.refresh_stepping_mode(); } -static void set_stealth_status(const bool enable, const int8_t target_e_stepper) { +static void set_stealth_status(const bool enable, const int8_t eindex) { #define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable) - #if X_HAS_STEALTHCHOP || Y_HAS_STEALTHCHOP || Z_HAS_STEALTHCHOP \ - || I_HAS_STEALTHCHOP || J_HAS_STEALTHCHOP || K_HAS_STEALTHCHOP \ - || X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP - const uint8_t index = parser.byteval('I'); + #if X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP + const int8_t index = parser.byteval('I', -1); + #else + constexpr int8_t index = -1; #endif LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) { switch (i) { case X_AXIS: - TERN_(X_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(X)); - TERN_(X2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(X2)); + TERN_(X_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(X)); + TERN_(X2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(X2)); break; #if HAS_Y_AXIS case Y_AXIS: - TERN_(Y_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(Y)); - TERN_(Y2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(Y2)); + TERN_(Y_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(Y)); + TERN_(Y2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(Y2)); break; #endif #if HAS_Z_AXIS case Z_AXIS: - TERN_(Z_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(Z)); - TERN_(Z2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(Z2)); - TERN_(Z3_HAS_STEALTHCHOP, if (index == 2) TMC_SET_STEALTH(Z3)); - TERN_(Z4_HAS_STEALTHCHOP, if (index == 3) TMC_SET_STEALTH(Z4)); + TERN_(Z_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(Z)); + TERN_(Z2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(Z2)); + TERN_(Z3_HAS_STEALTHCHOP, if (index < 0 || index == 2) TMC_SET_STEALTH(Z3)); + TERN_(Z4_HAS_STEALTHCHOP, if (index < 0 || index == 3) TMC_SET_STEALTH(Z4)); break; #endif @@ -84,17 +88,14 @@ static void set_stealth_status(const bool enable, const int8_t target_e_stepper) #if E_STEPPERS case E_AXIS: { - if (target_e_stepper < 0) return; - switch (target_e_stepper) { - TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_STEALTH(E0); break;) - TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_STEALTH(E1); break;) - TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_STEALTH(E2); break;) - TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_STEALTH(E3); break;) - TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_STEALTH(E4); break;) - TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_STEALTH(E5); break;) - TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_STEALTH(E6); break;) - TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_STEALTH(E7); break;) - } + TERN_(E0_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 0) TMC_SET_STEALTH(E0)); + TERN_(E1_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 1) TMC_SET_STEALTH(E1)); + TERN_(E2_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 2) TMC_SET_STEALTH(E2)); + TERN_(E3_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 3) TMC_SET_STEALTH(E3)); + TERN_(E4_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 4) TMC_SET_STEALTH(E4)); + TERN_(E5_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 5) TMC_SET_STEALTH(E5)); + TERN_(E6_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 6) TMC_SET_STEALTH(E6)); + TERN_(E7_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 7) TMC_SET_STEALTH(E7)); } break; #endif } @@ -133,7 +134,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(0)); + set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command(-2)); else say_stealth_status(); } diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index f28718c831ba..c85d0be8a19a 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -28,6 +28,12 @@ #include "../../../feature/tmc_util.h" #include "../../../module/stepper/indirection.h" +template +static void tmc_print_current(TMC &st) { + st.printLabel(); + SERIAL_ECHOLNPGM(" driver current: ", st.getMilliamps()); +} + /** * M906: Set motor current in milliamps. * @@ -35,6 +41,9 @@ * X[current] - Set mA current for X driver(s) * Y[current] - Set mA current for Y driver(s) * Z[current] - Set mA current for Z driver(s) + * A[current] - Set mA current for A driver(s) (Requires AXIS*_NAME 'A') + * B[current] - Set mA current for B driver(s) (Requires AXIS*_NAME 'B') + * C[current] - Set mA current for C driver(s) (Requires AXIS*_NAME 'C') * E[current] - Set mA current for E driver(s) * * I[index] - Axis sub-index (Omit or 0 for X, Y, Z; 1 for X2, Y2, Z2; 2 for Z3; 3 for Z4.) @@ -48,46 +57,50 @@ void GcodeSuite::M906() { bool report = true; - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) - const uint8_t index = parser.byteval('I'); + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + const int8_t index = parser.byteval('I', -1); + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + constexpr int8_t index = -1; #endif LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { report = false; switch (i) { - case X_AXIS: - #if AXIS_IS_TMC(X) - if (index == 0) TMC_SET_CURRENT(X); - #endif - #if AXIS_IS_TMC(X2) - if (index == 1) TMC_SET_CURRENT(X2); - #endif - break; + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) + case X_AXIS: + #if AXIS_IS_TMC(X) + if (index < 0 || index == 0) TMC_SET_CURRENT(X); + #endif + #if AXIS_IS_TMC(X2) + if (index < 0 || index == 1) TMC_SET_CURRENT(X2); + #endif + break; + #endif - #if HAS_Y_AXIS + #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) case Y_AXIS: #if AXIS_IS_TMC(Y) - if (index == 0) TMC_SET_CURRENT(Y); + if (index < 0 || index == 0) TMC_SET_CURRENT(Y); #endif #if AXIS_IS_TMC(Y2) - if (index == 1) TMC_SET_CURRENT(Y2); + if (index < 0 || index == 1) TMC_SET_CURRENT(Y2); #endif break; #endif - #if HAS_Z_AXIS + #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) case Z_AXIS: #if AXIS_IS_TMC(Z) - if (index == 0) TMC_SET_CURRENT(Z); + if (index < 0 || index == 0) TMC_SET_CURRENT(Z); #endif #if AXIS_IS_TMC(Z2) - if (index == 1) TMC_SET_CURRENT(Z2); + if (index < 0 || index == 1) TMC_SET_CURRENT(Z2); #endif #if AXIS_IS_TMC(Z3) - if (index == 2) TMC_SET_CURRENT(Z3); + if (index < 0 || index == 2) TMC_SET_CURRENT(Z3); #endif #if AXIS_IS_TMC(Z4) - if (index == 3) TMC_SET_CURRENT(Z4); + if (index < 0 || index == 3) TMC_SET_CURRENT(Z4); #endif break; #endif @@ -102,36 +115,33 @@ void GcodeSuite::M906() { case K_AXIS: TMC_SET_CURRENT(K); break; #endif - #if E_STEPPERS + #if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7) case E_AXIS: { - 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) - case 0: TMC_SET_CURRENT(E0); break; - #endif - #if AXIS_IS_TMC(E1) - case 1: TMC_SET_CURRENT(E1); break; - #endif - #if AXIS_IS_TMC(E2) - case 2: TMC_SET_CURRENT(E2); break; - #endif - #if AXIS_IS_TMC(E3) - case 3: TMC_SET_CURRENT(E3); break; - #endif - #if AXIS_IS_TMC(E4) - case 4: TMC_SET_CURRENT(E4); break; - #endif - #if AXIS_IS_TMC(E5) - case 5: TMC_SET_CURRENT(E5); break; - #endif - #if AXIS_IS_TMC(E6) - case 6: TMC_SET_CURRENT(E6); break; - #endif - #if AXIS_IS_TMC(E7) - case 7: TMC_SET_CURRENT(E7); break; - #endif - } + const int8_t eindex = get_target_e_stepper_from_command(-2); + #if AXIS_IS_TMC(E0) + if (eindex < 0 || eindex == 0) TMC_SET_CURRENT(E0); + #endif + #if AXIS_IS_TMC(E1) + if (eindex < 0 || eindex == 1) TMC_SET_CURRENT(E1); + #endif + #if AXIS_IS_TMC(E2) + if (eindex < 0 || eindex == 2) TMC_SET_CURRENT(E2); + #endif + #if AXIS_IS_TMC(E3) + if (eindex < 0 || eindex == 3) TMC_SET_CURRENT(E3); + #endif + #if AXIS_IS_TMC(E4) + if (eindex < 0 || eindex == 4) TMC_SET_CURRENT(E4); + #endif + #if AXIS_IS_TMC(E5) + if (eindex < 0 || eindex == 5) TMC_SET_CURRENT(E5); + #endif + #if AXIS_IS_TMC(E6) + if (eindex < 0 || eindex == 6) TMC_SET_CURRENT(E6); + #endif + #if AXIS_IS_TMC(E7) + if (eindex < 0 || eindex == 7) TMC_SET_CURRENT(E7); + #endif } break; #endif } diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 3f83558fd428..b37c81733c7c 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -38,19 +38,19 @@ #if M91x_USE(X) || M91x_USE(X2) #define M91x_SOME_X 1 #endif - #if LINEAR_AXES >= 2 && (M91x_USE(Y) || M91x_USE(Y2)) + #if HAS_Y_AXIS && (M91x_USE(Y) || M91x_USE(Y2)) #define M91x_SOME_Y 1 #endif #if HAS_Z_AXIS && (M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4)) #define M91x_SOME_Z 1 #endif - #if LINEAR_AXES >= 4 && M91x_USE(I) + #if HAS_I_AXIS && M91x_USE(I) #define M91x_USE_I 1 #endif - #if LINEAR_AXES >= 5 && M91x_USE(J) + #if HAS_J_AXIS && M91x_USE(J) #define M91x_USE_J 1 #endif - #if LINEAR_AXES >= 6 && M91x_USE(K) + #if HAS_K_AXIS && M91x_USE(K) #define M91x_USE_K 1 #endif @@ -62,6 +62,21 @@ #error "MONITOR_DRIVER_STATUS requires at least one TMC2130, 2160, 2208, 2209, 2660, 5130, or 5160." #endif + template + static void tmc_report_otpw(TMC &st) { + st.printLabel(); + SERIAL_ECHOPGM(" temperature prewarn triggered: "); + serialprint_truefalse(st.getOTPW()); + SERIAL_EOL(); + } + + template + static void tmc_clear_otpw(TMC &st) { + st.clear_otpw(); + st.printLabel(); + SERIAL_ECHOLNPGM(" prewarn flag cleared"); + } + /** * M911: Report TMC stepper driver overtemperature pre-warn flag * This flag is held by the library, persisting until cleared by M912 @@ -223,11 +238,17 @@ #endif // MONITOR_DRIVER_STATUS -/** - * M913: Set HYBRID_THRESHOLD speed. - */ #if ENABLED(HYBRID_THRESHOLD) + template + static void tmc_print_pwmthrs(TMC &st) { + st.printLabel(); + SERIAL_ECHOLNPGM(" stealthChop max speed: ", st.get_pwm_thrs()); + } + + /** + * M913: Set HYBRID_THRESHOLD speed. + */ void GcodeSuite::M913() { #define TMC_SAY_PWMTHRS(A,Q) tmc_print_pwmthrs(stepper##Q) #define TMC_SET_PWMTHRS(A,Q) stepper##Q.set_pwm_thrs(value) @@ -235,20 +256,36 @@ #define TMC_SET_PWMTHRS_E(E) stepperE##E.set_pwm_thrs(value) bool report = true; - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) - const uint8_t index = parser.byteval('I'); + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + const int8_t index = parser.byteval('I', -1); + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + constexpr int8_t index = -1; #endif LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(axis_codes[i])) { report = false; switch (i) { - case X_AXIS: - TERN_(X_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(X,X)); - TERN_(X2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(X,X2)); - break; - case Y_AXIS: - TERN_(Y_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Y,Y)); - TERN_(Y2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(Y,Y2)); - break; + #if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP + case X_AXIS: + TERN_(X_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_PWMTHRS(X,X)); + TERN_(X2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_PWMTHRS(X,X2)); + break; + #endif + + #if Y_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP + case Y_AXIS: + TERN_(Y_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_PWMTHRS(Y,Y)); + TERN_(Y2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_PWMTHRS(Y,Y2)); + break; + #endif + + #if Z_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP + case Z_AXIS: + TERN_(Z_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_PWMTHRS(Z,Z)); + TERN_(Z2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_PWMTHRS(Z,Z2)); + TERN_(Z3_HAS_STEALTHCHOP, if (index < 0 || index == 2) TMC_SET_PWMTHRS(Z,Z3)); + TERN_(Z4_HAS_STEALTHCHOP, if (index < 0 || index == 3) TMC_SET_PWMTHRS(Z,Z4)); + break; + #endif #if I_HAS_STEALTHCHOP case I_AXIS: TMC_SET_PWMTHRS(I,I); break; @@ -260,26 +297,17 @@ case K_AXIS: TMC_SET_PWMTHRS(K,K); break; #endif - case Z_AXIS: - TERN_(Z_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Z,Z)); - TERN_(Z2_HAS_STEALTHCHOP, if (index == 0 || index == 2) TMC_SET_PWMTHRS(Z,Z2)); - TERN_(Z3_HAS_STEALTHCHOP, if (index == 0 || index == 3) TMC_SET_PWMTHRS(Z,Z3)); - TERN_(Z4_HAS_STEALTHCHOP, if (index == 0 || index == 4) TMC_SET_PWMTHRS(Z,Z4)); - break; - #if E_STEPPERS + #if E0_HAS_STEALTHCHOP || E1_HAS_STEALTHCHOP || E2_HAS_STEALTHCHOP || E3_HAS_STEALTHCHOP || E4_HAS_STEALTHCHOP || E5_HAS_STEALTHCHOP || E6_HAS_STEALTHCHOP || E7_HAS_STEALTHCHOP case E_AXIS: { - 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;) - TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_PWMTHRS_E(1); break;) - TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_PWMTHRS_E(2); break;) - TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_PWMTHRS_E(3); break;) - TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_PWMTHRS_E(4); break;) - TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_PWMTHRS_E(5); break;) - TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_PWMTHRS_E(6); break;) - TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_PWMTHRS_E(7); break;) - } + const int8_t eindex = get_target_e_stepper_from_command(-2); + TERN_(E0_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 0) TMC_SET_PWMTHRS_E(0)); + TERN_(E1_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 1) TMC_SET_PWMTHRS_E(1)); + TERN_(E2_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 2) TMC_SET_PWMTHRS_E(2)); + TERN_(E3_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 3) TMC_SET_PWMTHRS_E(3)); + TERN_(E4_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 4) TMC_SET_PWMTHRS_E(4)); + TERN_(E5_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 5) TMC_SET_PWMTHRS_E(5)); + TERN_(E6_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 6) TMC_SET_PWMTHRS_E(6)); + TERN_(E7_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 7) TMC_SET_PWMTHRS_E(7)); } break; #endif // E_STEPPERS } @@ -407,11 +435,18 @@ #endif // HYBRID_THRESHOLD -/** - * M914: Set StallGuard sensitivity. - */ #if USE_SENSORLESS + template + static void tmc_print_sgt(TMC &st) { + st.printLabel(); + SERIAL_ECHOPGM(" homing sensitivity: "); + SERIAL_PRINTLN(st.homing_threshold(), PrintBase::Dec); + } + + /** + * M914: Set StallGuard sensitivity. + */ void GcodeSuite::M914() { bool report = true; diff --git a/Marlin/src/gcode/feature/trinamic/M919.cpp b/Marlin/src/gcode/feature/trinamic/M919.cpp new file mode 100644 index 000000000000..d4ba4f74eaa1 --- /dev/null +++ b/Marlin/src/gcode/feature/trinamic/M919.cpp @@ -0,0 +1,266 @@ +/** + * 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 . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_TRINAMIC_CONFIG + +#if AXIS_COLLISION('I') + #error "M919 parameter collision with axis name." +#endif + +#include "../../gcode.h" +#include "../../../feature/tmc_util.h" +#include "../../../module/stepper/indirection.h" + +#define DEBUG_OUT ENABLED(MARLIN_DEV_MODE) +#include "../../../core/debug_out.h" + +template +static void tmc_print_chopper_time(TMC &st) { + st.printLabel(); + SERIAL_ECHOLNPGM(" chopper .toff: ", st.toff(), + " .hend: ", st.hysteresis_end(), + " .hstrt: ", st.hysteresis_start()); +} + +/** + * M919: Set TMC stepper driver chopper times + * + * Parameters: + * XYZ...E - Selected axes + * I[index] - Axis sub-index (Omit for all XYZ steppers, 1 for X2, Y2, Z2; 2 for Z3; 3 for Z4) + * T[index] - Extruder index (Zero-based. Omit for all extruders.) + * O - time-off [ 1..15] + * P - hysteresis_end [-3..12] + * S - hysteresis_start [ 1...8] + * + * With no parameters report chopper times for all axes + */ +void GcodeSuite::M919() { + bool err = false; + + int8_t toff = int8_t(parser.intval('O', -127)); + if (toff != -127) { + if (WITHIN(toff, 1, 15)) + DEBUG_ECHOLNPGM(".toff: ", toff); + else { + SERIAL_ECHOLNPGM("?O out of range (1..15)"); + err = true; + } + } + + int8_t hend = int8_t(parser.intval('P', -127)); + if (hend != -127) { + if (WITHIN(hend, -3, 12)) + DEBUG_ECHOLNPGM(".hend: ", hend); + else { + SERIAL_ECHOLNPGM("?P out of range (-3..12)"); + err = true; + } + } + + int8_t hstrt = int8_t(parser.intval('S', -127)); + if (hstrt != -127) { + if (WITHIN(hstrt, 1, 8)) + DEBUG_ECHOLNPGM(".hstrt: ", hstrt); + else { + SERIAL_ECHOLNPGM("?S out of range (1..8)"); + err = true; + } + } + + if (err) return; + + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + const int8_t index = parser.byteval('I'); + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + constexpr int8_t index = -1; + #endif + + auto make_chopper_timing = [](chopper_timing_t bct, const int8_t toff, const int8_t hend, const int8_t hstrt) { + chopper_timing_t uct = bct; + if (toff != -127) uct.toff = toff; + if (hend != -127) uct.hend = hend; + if (hstrt != -127) uct.hstrt = hstrt; + return uct; + }; + + #define TMC_SET_CHOPPER_TIME(Q) stepper##Q.set_chopper_times(make_chopper_timing(CHOPPER_TIMING_##Q, toff, hend, hstrt)) + + #if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7) + #define HAS_E_CHOPPER 1 + int8_t eindex = -1; + #endif + bool report = true; + LOOP_LOGICAL_AXES(i) if (parser.seen_test(axis_codes[i])) { + report = false; + + // Get the chopper timing for the specified axis and index + switch (i) { + default: // A specified axis isn't Trinamic + SERIAL_ECHOLNPGM("?Axis ", AS_CHAR(axis_codes[i]), " has no TMC drivers."); + break; + + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) + case X_AXIS: + #if AXIS_IS_TMC(X) + if (index <= 0) TMC_SET_CHOPPER_TIME(X); + #endif + #if AXIS_IS_TMC(X2) + if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(X2); + #endif + break; + #endif + + #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) + case Y_AXIS: + #if AXIS_IS_TMC(Y) + if (index <= 0) TMC_SET_CHOPPER_TIME(Y); + #endif + #if AXIS_IS_TMC(Y2) + if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Y2); + #endif + break; + #endif + + #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + case Z_AXIS: + #if AXIS_IS_TMC(Z) + if (index <= 0) TMC_SET_CHOPPER_TIME(Z); + #endif + #if AXIS_IS_TMC(Z2) + if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Z2); + #endif + #if AXIS_IS_TMC(Z3) + if (index < 0 || index == 2) TMC_SET_CHOPPER_TIME(Z3); + #endif + #if AXIS_IS_TMC(Z4) + if (index < 0 || index == 3) TMC_SET_CHOPPER_TIME(Z4); + #endif + break; + #endif + + #if AXIS_IS_TMC(I) + case I_AXIS: TMC_SET_CHOPPER_TIME(I); break; + #endif + #if AXIS_IS_TMC(J) + case J_AXIS: TMC_SET_CHOPPER_TIME(J); break; + #endif + #if AXIS_IS_TMC(K) + case K_AXIS: TMC_SET_CHOPPER_TIME(K); break; + #endif + + #if HAS_E_CHOPPER + case E_AXIS: { + #if AXIS_IS_TMC(E0) + if (eindex <= 0) TMC_SET_CHOPPER_TIME(E0); + #endif + #if AXIS_IS_TMC(E1) + if (eindex < 0 || eindex == 1) TMC_SET_CHOPPER_TIME(E1); + #endif + #if AXIS_IS_TMC(E2) + if (eindex < 0 || eindex == 2) TMC_SET_CHOPPER_TIME(E2); + #endif + #if AXIS_IS_TMC(E3) + if (eindex < 0 || eindex == 3) TMC_SET_CHOPPER_TIME(E3); + #endif + #if AXIS_IS_TMC(E4) + if (eindex < 0 || eindex == 4) TMC_SET_CHOPPER_TIME(E4); + #endif + #if AXIS_IS_TMC(E5) + if (eindex < 0 || eindex == 5) TMC_SET_CHOPPER_TIME(E5); + #endif + #if AXIS_IS_TMC(E6) + if (eindex < 0 || eindex == 6) TMC_SET_CHOPPER_TIME(E6); + #endif + #if AXIS_IS_TMC(E7) + if (eindex < 0 || eindex == 7) TMC_SET_CHOPPER_TIME(E7); + #endif + } break; + #endif + } + } + + if (report) { + #define TMC_SAY_CHOPPER_TIME(Q) tmc_print_chopper_time(stepper##Q) + #if AXIS_IS_TMC(X) + TMC_SAY_CHOPPER_TIME(X); + #endif + #if AXIS_IS_TMC(X2) + TMC_SAY_CHOPPER_TIME(X2); + #endif + #if AXIS_IS_TMC(Y) + TMC_SAY_CHOPPER_TIME(Y); + #endif + #if AXIS_IS_TMC(Y2) + TMC_SAY_CHOPPER_TIME(Y2); + #endif + #if AXIS_IS_TMC(Z) + TMC_SAY_CHOPPER_TIME(Z); + #endif + #if AXIS_IS_TMC(Z2) + TMC_SAY_CHOPPER_TIME(Z2); + #endif + #if AXIS_IS_TMC(Z3) + TMC_SAY_CHOPPER_TIME(Z3); + #endif + #if AXIS_IS_TMC(Z4) + TMC_SAY_CHOPPER_TIME(Z4); + #endif + #if AXIS_IS_TMC(I) + TMC_SAY_CHOPPER_TIME(I); + #endif + #if AXIS_IS_TMC(J) + TMC_SAY_CHOPPER_TIME(J); + #endif + #if AXIS_IS_TMC(K) + TMC_SAY_CHOPPER_TIME(K); + #endif + #if AXIS_IS_TMC(E0) + TMC_SAY_CHOPPER_TIME(E0); + #endif + #if AXIS_IS_TMC(E1) + TMC_SAY_CHOPPER_TIME(E1); + #endif + #if AXIS_IS_TMC(E2) + TMC_SAY_CHOPPER_TIME(E2); + #endif + #if AXIS_IS_TMC(E3) + TMC_SAY_CHOPPER_TIME(E3); + #endif + #if AXIS_IS_TMC(E4) + TMC_SAY_CHOPPER_TIME(E4); + #endif + #if AXIS_IS_TMC(E5) + TMC_SAY_CHOPPER_TIME(E5); + #endif + #if AXIS_IS_TMC(E6) + TMC_SAY_CHOPPER_TIME(E6); + #endif + #if AXIS_IS_TMC(E7) + TMC_SAY_CHOPPER_TIME(E7); + #endif + } +} + +#endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index b2cb26122fcf..c365f8a67b42 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -65,6 +65,10 @@ GcodeSuite gcode; #include "../feature/password/password.h" #endif +#if HAS_FANCHECK + #include "../feature/fancheck.h" +#endif + #include "../MarlinCore.h" // for idle, kill // Inactivity shutdown @@ -144,6 +148,7 @@ int8_t GcodeSuite::get_target_extruder_from_command() { 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; + if (dval == -2) return dval; SERIAL_ECHO_START(); SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum); @@ -155,7 +160,7 @@ int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) { } /** - * Set XYZIJKE destination and feedrate from the current GCode command + * Set XYZ...E destination and feedrate from the current GCode command * * - Set destination from included axis codes * - Set to current for missing axis codes @@ -296,6 +301,8 @@ void GcodeSuite::dwell(millis_t time) { * Process the parsed command and dispatch it to its handler */ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { + TERN_(HAS_FANCHECK, fan_check.check_deferred_error()); + KEEPALIVE_STATE(IN_HANDLER); /** @@ -577,6 +584,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 113: M113(); break; // M113: Set Host Keepalive interval #endif + #if HAS_FANCHECK + case 123: M123(); break; // M123: Report fan states or set fans auto-report interval + #endif + #if HAS_HEATED_BED case 140: M140(); break; // M140: Set bed temperature case 190: M190(); break; // M190: Wait for bed temperature to reach target @@ -960,6 +971,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #if USE_SENSORLESS case 914: M914(); break; // M914: Set StallGuard sensitivity. #endif + case 919: M919(); break; // M919: Set stepper Chopper Times #endif #if HAS_L64XX @@ -1044,6 +1056,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 7219: M7219(); break; // M7219: Set LEDs, columns, and rows #endif + #if ENABLED(HAS_MCP3426_ADC) + case 3426: M3426(); break; // M3426: Read MCP3426 ADC (over i2c) + #endif + default: parser.unknown_command_warning(); break; } break; diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index d7bacaef32a8..6e331c127383 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -91,7 +91,7 @@ * *** Print from Media (SDSUPPORT) *** * M20 - List SD card. (Requires SDSUPPORT) - * M21 - Init SD card. (Requires SDSUPPORT) + * M21 - Init SD card. (Requires SDSUPPORT) With MULTI_VOLUME select a drive with `M21 Pn` / 'M21 S' / 'M21 U'. * M22 - Release SD card. (Requires SDSUPPORT) * M23 - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT) * M24 - Start/resume SD print. (Requires SDSUPPORT) @@ -156,6 +156,7 @@ * M121 - Disable endstops detection. * * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) + * M123 - Report fan tachometers. (Requires En_FAN_TACHO_PIN) Optionally set auto-report interval. (Requires AUTO_REPORT_FANS) * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) * * M126 - Solenoid Air Valve Open. (Requires BARICUDA) @@ -283,7 +284,7 @@ * 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) + * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots) * M908 - Control digital trimpot directly. (Requires HAS_MOTOR_CURRENT_DAC or DIGIPOTSS_PIN) * M909 - Print digipot/DAC current value. (Requires HAS_MOTOR_CURRENT_DAC) @@ -295,7 +296,9 @@ * M916 - L6470 tuning: Increase KVAL_HOLD until thermal warning. (Requires at least one _DRIVER_TYPE L6470) * M917 - L6470 tuning: Find minimum current thresholds. (Requires at least one _DRIVER_TYPE L6470) * M918 - L6470 tuning: Increase speed until max or error. (Requires at least one _DRIVER_TYPE L6470) + * M919 - Get or Set motor Chopper Times (time_off, hysteresis_end, hysteresis_start) using axis codes XYZE, etc. If no parameters are given, report. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER) + * M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC) * M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE) * *** SCARA *** @@ -347,7 +350,7 @@ class GcodeSuite { static axis_bits_t axis_relative; - static inline bool axis_is_relative(const AxisEnum a) { + static bool axis_is_relative(const AxisEnum a) { #if HAS_EXTRUDERS if (a == E_AXIS) { if (TEST(axis_relative, E_MODE_REL)) return true; @@ -356,7 +359,7 @@ class GcodeSuite { #endif return TEST(axis_relative, a); } - static inline void set_relative_mode(const bool rel) { + static void set_relative_mode(const bool rel) { axis_relative = rel ? (0 LOGICAL_AXIS_GANG( | _BV(REL_E), | _BV(REL_X), | _BV(REL_Y), | _BV(REL_Z), @@ -364,11 +367,11 @@ class GcodeSuite { )) : 0; } #if HAS_EXTRUDERS - static inline void set_e_relative() { + static void set_e_relative() { CBI(axis_relative, E_MODE_ABS); SBI(axis_relative, E_MODE_REL); } - static inline void set_e_absolute() { + static void set_e_absolute() { CBI(axis_relative, E_MODE_REL); SBI(axis_relative, E_MODE_ABS); } @@ -401,7 +404,7 @@ class GcodeSuite { static void report_echo_start(const bool forReplay); static void report_heading(const bool forReplay, FSTR_P const fstr, const bool eol=true); - static inline void report_heading_etc(const bool forReplay, FSTR_P const fstr, const bool eol=true) { + static void report_heading_etc(const bool forReplay, FSTR_P const fstr, const bool eol=true) { report_heading(forReplay, fstr, eol); report_echo_start(forReplay); } @@ -418,20 +421,20 @@ class GcodeSuite { static void process_subcommands_now(FSTR_P fgcode); static void process_subcommands_now(char * gcode); - static inline void home_all_axes(const bool keep_leveling=false) { + static void home_all_axes(const bool keep_leveling=false) { process_subcommands_now(keep_leveling ? FPSTR(G28_STR) : TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR))); } #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) static bool autoreport_paused; - static inline bool set_autoreport_paused(const bool p) { + static bool set_autoreport_paused(const bool p) { const bool was = autoreport_paused; autoreport_paused = p; return was; } #else static constexpr bool autoreport_paused = false; - static inline bool set_autoreport_paused(const bool) { return false; } + static bool set_autoreport_paused(const bool) { return false; } #endif #if ENABLED(HOST_KEEPALIVE_FEATURE) @@ -451,7 +454,7 @@ class GcodeSuite { static uint8_t host_keepalive_interval; static void host_keepalive(); - static inline bool host_keepalive_is_paused() { return busy_state >= PAUSED_FOR_USER; } + static bool host_keepalive_is_paused() { return busy_state >= PAUSED_FOR_USER; } #define KEEPALIVE_STATE(N) REMEMBER(_KA_, gcode.busy_state, gcode.N) #else @@ -736,6 +739,10 @@ class GcodeSuite { static void M120(); static void M121(); + #if HAS_FANCHECK + static void M123(); + #endif + #if ENABLED(PARK_HEAD_ON_PAUSE) static void M125(); #endif @@ -1134,6 +1141,7 @@ class GcodeSuite { static void M914(); static void M914_report(const bool forReplay=true); #endif + static void M919(); #endif #if HAS_L64XX @@ -1187,6 +1195,11 @@ class GcodeSuite { static void M1000(); #endif + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + static void M423(); + static void M423_report(const bool forReplay=true); + #endif + #if ENABLED(SDSUPPORT) static void M1001(); #endif @@ -1199,6 +1212,10 @@ class GcodeSuite { static void M1004(); #endif + #if ENABLED(HAS_MCP3426_ADC) + static void M3426(); + #endif + #if ENABLED(MAX7219_GCODE) static void M7219(); #endif diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 204455e65ec6..2dd1de00013b 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -38,7 +38,7 @@ #include "../sd/cardreader.h" #include "../MarlinCore.h" // for kill -extern void dump_delay_accuracy_check(); +void dump_delay_accuracy_check(); /** * Dn: G-code for development and testing @@ -54,7 +54,7 @@ void GcodeSuite::D(const int16_t dcode) { for (;;) { /* loop forever (watchdog reset) */ } case 0: - HAL_reboot(); + hal.reboot(); break; case 10: @@ -74,7 +74,7 @@ void GcodeSuite::D(const int16_t dcode) { settings.reset(); settings.save(); #endif - HAL_reboot(); + hal.reboot(); } break; case 2: { // D2 Read / Write SRAM @@ -189,12 +189,12 @@ void GcodeSuite::D(const int16_t dcode) { SERIAL_ECHOLNPGM("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")"); thermalManager.disable_all_heaters(); delay(1000); // Allow time to print - DISABLE_ISRS(); + hal.isr_off(); // Use a low-level delay that does not rely on interrupts to function // Do not spin forever, to avoid thermal risks if heaters are enabled and // watchdog does not work. for (int i = 10000; i--;) DELAY_US(1000UL); - ENABLE_ISRS(); + hal.isr_on(); SERIAL_ECHOLNPGM("FAILURE: Watchdog did not trigger board reset."); } break; diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index 990236c0e878..3c49fe2a2640 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -29,7 +29,7 @@ #endif /** - * G92: Set the Current Position to the given X Y Z E values. + * G92: Set the Current Position to the given X [Y [Z [A [B [C [E]]]]]] values. * * Behind the scenes the G92 command may modify the Current Position * or the Position Shift depending on settings and sub-commands. @@ -37,14 +37,14 @@ * Since E has no Workspace Offset, it is always set directly. * * Without Workspace Offsets (e.g., with NO_WORKSPACE_OFFSETS): - * G92 : Set NATIVE Current Position to the given X Y Z E. + * G92 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [E]]]]]]. * * Using Workspace Offsets (default Marlin behavior): - * G92 : Modify Workspace Offsets so the reported position shows the given X Y Z E. + * G92 : Modify Workspace Offsets so the reported position shows the given X [Y [Z [A [B [C [E]]]]]]. * G92.1 : Zero XYZ Workspace Offsets (so the reported position = the native position). * * With POWER_LOSS_RECOVERY: - * G92.9 : Set NATIVE Current Position to the given X Y Z E. + * G92.9 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [E]]]]]]. */ void GcodeSuite::G92() { diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 131dbecf3343..b32d72996940 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -92,7 +92,7 @@ void GcodeSuite::M428() { if (!WITHIN(diff[i], -20, 20)) { SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR); LCD_ALERTMESSAGE_F("Err: Too far!"); - BUZZ(200, 40); + ERR_BUZZ(); return; } } @@ -100,8 +100,7 @@ void GcodeSuite::M428() { LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]); report_current_position(); LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED); - BUZZ(100, 659); - BUZZ(100, 698); + OKAY_BUZZ(); } #endif // HAS_M206_COMMAND diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 8a9c409764c5..36731c23da16 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -24,7 +24,6 @@ #include "../../inc/MarlinConfig.h" #include "../queue.h" // for getting the command port - #if ENABLED(M115_GEOMETRY_REPORT) #include "../../module/motion.h" #endif @@ -33,13 +32,25 @@ #include "../../feature/caselight.h" #endif +//#define MINIMAL_CAP_LINES // Don't even mention the disabled capabilities + #if ENABLED(EXTENDED_CAPABILITIES_REPORT) - static void cap_line(FSTR_P const name, bool ena=false) { - SERIAL_ECHOPGM("Cap:"); - SERIAL_ECHOF(name); - SERIAL_CHAR(':', '0' + ena); - SERIAL_EOL(); - } + #if ENABLED(MINIMAL_CAP_LINES) + #define cap_line(S,C) if (C) _cap_line(S) + static void _cap_line(FSTR_P const name) { + SERIAL_ECHOPGM("Cap:"); + SERIAL_ECHOF(name); + SERIAL_ECHOLNPGM(":1"); + } + #else + #define cap_line(V...) _cap_line(V) + static void _cap_line(FSTR_P const name, bool ena=false) { + SERIAL_ECHOPGM("Cap:"); + SERIAL_ECHOF(name); + SERIAL_CHAR(':', '0' + ena); + SERIAL_EOL(); + } + #endif #endif /** @@ -131,6 +142,11 @@ void GcodeSuite::M115() { // SDCARD (M20, M23, M24, etc.) cap_line(F("SDCARD"), ENABLED(SDSUPPORT)); + // MULTI_VOLUME (M21 S/M21 U) + #if ENABLED(SDSUPPORT) + cap_line(F("MULTI_VOLUME"), ENABLED(MULTI_VOLUME)); + #endif + // REPEAT (M808) cap_line(F("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS)); @@ -143,6 +159,15 @@ void GcodeSuite::M115() { // LONG_FILENAME_HOST_SUPPORT (M33) cap_line(F("LONG_FILENAME"), ENABLED(LONG_FILENAME_HOST_SUPPORT)); + // LONG_FILENAME_WRITE_SUPPORT (M23, M28, M30...) + cap_line(F("LFN_WRITE"), ENABLED(LONG_FILENAME_WRITE_SUPPORT)); + + // CUSTOM_FIRMWARE_UPLOAD (M20 F) + cap_line(F("CUSTOM_FIRMWARE_UPLOAD"), ENABLED(CUSTOM_FIRMWARE_UPLOAD)); + + // EXTENDED_M20 (M20 L) + cap_line(F("EXTENDED_M20"), ENABLED(LONG_FILENAME_HOST_SUPPORT)); + // THERMAL_PROTECTION cap_line(F("THERMAL_PROTECTION"), ENABLED(THERMALLY_SAFE)); @@ -164,6 +189,9 @@ void GcodeSuite::M115() { // MEATPACK Compression cap_line(F("MEATPACK"), SERIAL_IMPL.has_feature(port, SerialFeature::MeatPack)); + // CONFIG_EXPORT + cap_line(F("CONFIG_EXPORT"), ENABLED(CONFIGURATION_EMBEDDING)); + // Machine Geometry #if ENABLED(M115_GEOMETRY_REPORT) const xyz_pos_t bmin = { 0, 0, 0 }, diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index b1b558b033d3..1feb57996adb 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -162,7 +162,8 @@ void GcodeSuite::M360() { TERN_(DELTA, "Delta") TERN_(IS_SCARA, "SCARA") TERN_(IS_CORE, "Core") - TERN_(MARKFORGED_XY, "MarkForged") + TERN_(MARKFORGED_XY, "MarkForgedXY") + TERN_(MARKFORGED_YX, "MarkForgedYX") TERN_(IS_CARTESIAN, "Cartesian") ); diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 6e3b84c020f0..af03fcb0b1a1 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -31,12 +31,13 @@ #include "../../module/planner.h" // for synchronize() #include "../../MarlinCore.h" // for wait_for_user_response() -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../../lcd/marlinui.h" #elif ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin_popup.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(HOST_PROMPT_SUPPORT) @@ -54,7 +55,7 @@ void GcodeSuite::M0_M1() { planner.synchronize(); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (parser.string_arg) ui.set_status(parser.string_arg, true); @@ -70,7 +71,7 @@ void GcodeSuite::M0_M1() { ExtUI::onUserConfirmRequired(parser.string_arg); // String in an SRAM buffer else ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_USERWAIT)); - #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #elif ENABLED(DWIN_LCD_PROUI) if (parser.string_arg) DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT)); else @@ -88,7 +89,7 @@ void GcodeSuite::M0_M1() { TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms)); - TERN_(HAS_LCD_MENU, ui.reset_status()); + TERN_(HAS_MARLINUI_MENU, ui.reset_status()); } #endif // HAS_RESUME_CONTINUE diff --git a/Marlin/src/gcode/lcd/M250.cpp b/Marlin/src/gcode/lcd/M250.cpp index 25e423278883..58b6dac872a3 100644 --- a/Marlin/src/gcode/lcd/M250.cpp +++ b/Marlin/src/gcode/lcd/M250.cpp @@ -31,7 +31,7 @@ * M250: Read and optionally set the LCD contrast */ void GcodeSuite::M250() { - if (parser.seenval('C')) + if (LCD_CONTRAST_MIN < LCD_CONTRAST_MAX && parser.seenval('C')) ui.set_contrast(parser.value_byte()); else M250_report(); diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index b7a9b3459e52..355445c573b9 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -28,8 +28,8 @@ #include "../../lcd/marlinui.h" #include "../../sd/cardreader.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif /** @@ -40,7 +40,7 @@ */ void GcodeSuite::M73() { - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) DWIN_Progress_Update(); diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index cc6979b74c12..493fd00da187 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -89,7 +89,7 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { if (MIN_AUTORETRACT <= MAX_AUTORETRACT) { // When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves if (fwretract.autoretract_enabled && parser.seen_test('E') - && !parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR)) + && !parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K)) ) { const float echange = destination.e - current_position.e; // Is this a retract or recover move? diff --git a/Marlin/src/gcode/motion/G5.cpp b/Marlin/src/gcode/motion/G5.cpp index 2c98fae84522..316a59b6506c 100644 --- a/Marlin/src/gcode/motion/G5.cpp +++ b/Marlin/src/gcode/motion/G5.cpp @@ -24,6 +24,10 @@ #if ENABLED(BEZIER_CURVE_SUPPORT) +#if AXIS_COLLISION('I') || AXIS_COLLISION('J') + #error "G5 parameter collision with axis name." +#endif + #include "../../module/motion.h" #include "../../module/planner_bezier.h" diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index 747ddd64de19..f3d7b7c8dca2 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -87,7 +87,7 @@ void GcodeSuite::M290() { } #endif - if (!parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR)) || parser.seen('R')) { + if (!parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K)) || parser.seen('R')) { SERIAL_ECHO_START(); #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 83fda5483608..1487c083ec60 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -126,7 +126,7 @@ class GCodeParser { } // Set the flag and pointer for a parameter - static inline void set(const char c, char * const ptr) { + static void set(const char c, char * const ptr) { const uint8_t ind = LETTER_BIT(c); if (ind >= COUNT(param)) return; // Only A-Z SBI32(codebits, ind); // parameter exists @@ -142,7 +142,7 @@ class GCodeParser { // Code seen bit was set. If not found, value_ptr is unchanged. // This allows "if (seen('A')||seen('B'))" to use the last-found value. - static inline bool seen(const char c) { + static bool seen(const char c) { const uint8_t ind = LETTER_BIT(c); if (ind >= COUNT(param)) return false; // Only A-Z const bool b = TEST32(codebits, ind); @@ -183,7 +183,7 @@ class GCodeParser { } #endif - static inline bool seen_any() { return !!codebits; } + static bool seen_any() { return !!codebits; } FORCE_INLINE static bool seen_test(const char c) { return TEST32(codebits, LETTER_BIT(c)); } @@ -204,19 +204,19 @@ class GCodeParser { // Code is found in the string. If not found, value_ptr is unchanged. // This allows "if (seen('A')||seen('B'))" to use the last-found value. - static inline bool seen(const char c) { + static bool seen(const char c) { char *p = strgchr(command_args, c); const bool b = !!p; if (b) value_ptr = valid_number(&p[1]) ? &p[1] : nullptr; return b; } - static inline bool seen_any() { return *command_args == '\0'; } + static bool seen_any() { return *command_args == '\0'; } FORCE_INLINE static bool seen_test(const char c) { return (bool)strgchr(command_args, c); } // At least one of a list of code letters was seen - static inline bool seen(const char * const str) { + static bool seen(const char * const str) { for (uint8_t i = 0; const char c = str[i]; i++) if (seen_test(c)) return true; return false; @@ -225,7 +225,7 @@ class GCodeParser { #endif // !FASTER_GCODE_PARSER // Seen any axis parameter - static inline bool seen_axis() { return seen(LOGICAL_AXES_STRING); } + static bool seen_axis() { return seen(LOGICAL_AXES_STRING); } #if ENABLED(GCODE_QUOTED_STRINGS) static char* unescape_string(char* &src); @@ -243,19 +243,19 @@ class GCodeParser { #endif // Test whether the parsed command matches the input - static inline bool is_command(const char ltr, const uint16_t num) { return command_letter == ltr && codenum == num; } + static bool is_command(const char ltr, const uint16_t num) { return command_letter == ltr && codenum == num; } // The code value pointer was set FORCE_INLINE static bool has_value() { return !!value_ptr; } // Seen a parameter with a value - static inline bool seenval(const char c) { return seen(c) && has_value(); } + static bool seenval(const char c) { return seen(c) && has_value(); } // The value as a string - static inline char* value_string() { return value_ptr; } + static char* value_string() { return value_ptr; } // Float removes 'E' to prevent scientific notation interpretation - static inline float value_float() { + static float value_float() { if (value_ptr) { char *e = value_ptr; for (;;) { @@ -275,31 +275,31 @@ class GCodeParser { } // Code value as a long or ulong - static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; } - static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; } + static int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; } + static uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; } // Code value for use as time - static inline millis_t value_millis() { return value_ulong(); } - static inline millis_t value_millis_from_seconds() { return (millis_t)SEC_TO_MS(value_float()); } + static millis_t value_millis() { return value_ulong(); } + static millis_t value_millis_from_seconds() { return (millis_t)SEC_TO_MS(value_float()); } // Reduce to fewer bits - static inline int16_t value_int() { return (int16_t)value_long(); } - static inline uint16_t value_ushort() { return (uint16_t)value_long(); } - static inline uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); } + static int16_t value_int() { return (int16_t)value_long(); } + static uint16_t value_ushort() { return (uint16_t)value_long(); } + static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); } // Bool is true with no value or non-zero - static inline bool value_bool() { return !has_value() || !!value_byte(); } + static bool value_bool() { return !has_value() || !!value_byte(); } // Units modes: Inches, Fahrenheit, Kelvin #if ENABLED(INCH_MODE_SUPPORT) - static inline float mm_to_linear_unit(const_float_t mm) { return mm / linear_unit_factor; } - static inline float mm_to_volumetric_unit(const_float_t mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } + static float mm_to_linear_unit(const_float_t mm) { return mm / linear_unit_factor; } + static float mm_to_volumetric_unit(const_float_t mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } // Init linear units by constructor GCodeParser() { set_input_linear_units(LINEARUNIT_MM); } - static inline void set_input_linear_units(const LinearUnit units) { + static void set_input_linear_units(const LinearUnit units) { switch (units) { default: case LINEARUNIT_MM: linear_unit_factor = 1.0f; break; @@ -308,7 +308,7 @@ class GCodeParser { volumetric_unit_factor = POW(linear_unit_factor, 3); } - static inline float axis_unit_factor(const AxisEnum axis) { + static float axis_unit_factor(const AxisEnum axis) { return ( #if HAS_EXTRUDERS axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor @@ -318,46 +318,46 @@ class GCodeParser { ); } - static inline float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; } - static inline float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); } - static inline float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); } + static float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; } + static float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); } + static float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); } #else - static inline float mm_to_linear_unit(const_float_t mm) { return mm; } - static inline float mm_to_volumetric_unit(const_float_t mm) { return mm; } + static float mm_to_linear_unit(const_float_t mm) { return mm; } + static float mm_to_volumetric_unit(const_float_t mm) { return mm; } - static inline float linear_value_to_mm(const_float_t v) { return v; } - static inline float axis_value_to_mm(const AxisEnum, const float v) { return v; } - static inline float per_axis_value(const AxisEnum, const float v) { return v; } + static float linear_value_to_mm(const_float_t v) { return v; } + static float axis_value_to_mm(const AxisEnum, const float v) { return v; } + static float per_axis_value(const AxisEnum, const float v) { return v; } #endif - static inline bool using_inch_units() { return mm_to_linear_unit(1.0f) != 1.0f; } + static bool using_inch_units() { return mm_to_linear_unit(1.0f) != 1.0f; } #define IN_TO_MM(I) ((I) * 25.4f) #define MM_TO_IN(M) ((M) / 25.4f) #define LINEAR_UNIT(V) parser.mm_to_linear_unit(V) #define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V) - static inline float value_linear_units() { return linear_value_to_mm(value_float()); } - static inline float value_axis_units(const AxisEnum axis) { return axis_value_to_mm(axis, value_float()); } - static inline float value_per_axis_units(const AxisEnum axis) { return per_axis_value(axis, value_float()); } + static float value_linear_units() { return linear_value_to_mm(value_float()); } + static float value_axis_units(const AxisEnum axis) { return axis_value_to_mm(axis, value_float()); } + static float value_per_axis_units(const AxisEnum axis) { return per_axis_value(axis, value_float()); } #if ENABLED(TEMPERATURE_UNITS_SUPPORT) - static inline void set_input_temp_units(const TempUnit units) { input_temp_units = units; } + static void set_input_temp_units(const TempUnit units) { input_temp_units = units; } - static inline char temp_units_code() { + static char temp_units_code() { return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C'; } - static inline FSTR_P temp_units_name() { + static FSTR_P temp_units_name() { return input_temp_units == TEMPUNIT_K ? F("Kelvin") : input_temp_units == TEMPUNIT_F ? F("Fahrenheit") : F("Celsius"); } - #if HAS_LCD_MENU && DISABLED(DISABLE_M503) + #if HAS_MARLINUI_MENU && DISABLED(DISABLE_M503) - static inline float to_temp_units(celsius_t c) { + static float to_temp_units(celsius_t c) { switch (input_temp_units) { default: case TEMPUNIT_C: return c; @@ -366,9 +366,9 @@ class GCodeParser { } } - #endif // HAS_LCD_MENU && !DISABLE_M503 + #endif // HAS_MARLINUI_MENU && !DISABLE_M503 - static inline celsius_t value_celsius() { + static celsius_t value_celsius() { float f = value_float(); switch (input_temp_units) { default: @@ -379,7 +379,7 @@ class GCodeParser { return LROUND(f); } - static inline celsius_t value_celsius_diff() { + static celsius_t value_celsius_diff() { float f = value_float(); switch (input_temp_units) { default: @@ -392,35 +392,35 @@ class GCodeParser { #else // !TEMPERATURE_UNITS_SUPPORT - static inline float to_temp_units(int16_t c) { return (float)c; } + static float to_temp_units(int16_t c) { return (float)c; } - static inline celsius_t value_celsius() { return value_int(); } - static inline celsius_t value_celsius_diff() { return value_int(); } + static celsius_t value_celsius() { return value_int(); } + static celsius_t value_celsius_diff() { return value_int(); } #endif // !TEMPERATURE_UNITS_SUPPORT - static inline feedRate_t value_feedrate() { return MMM_TO_MMS(value_linear_units()); } + static feedRate_t value_feedrate() { return MMM_TO_MMS(value_linear_units()); } void unknown_command_warning(); // Provide simple value accessors with default option - static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } - static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } - static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } - static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } - static inline int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } - static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } - static inline int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } - static inline uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } - static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } - static inline float axisunitsval(const char c, const AxisEnum a, const float dval=0) + static char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } + static float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } + static bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } + static uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } + static int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } + static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } + static int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } + static uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } + static float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } + static float axisunitsval(const char c, const AxisEnum a, const float dval=0) { return seenval(c) ? value_axis_units(a) : dval; } - static inline celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; } - static inline feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; } + static celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; } + static feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; } #if ENABLED(MARLIN_DEV_MODE) - static inline uint8_t* hex_adr_val(const char c, uint8_t * const dval=nullptr) { + static uint8_t* hex_adr_val(const char c, uint8_t * const dval=nullptr) { if (!seen(c) || *value_ptr != 'x') return dval; uint8_t *out = nullptr; for (char *vp = value_ptr + 1; HEXCHR(*vp) >= 0; vp++) @@ -428,7 +428,7 @@ class GCodeParser { return out; } - static inline uint16_t hex_val(const char c, uint16_t const dval=0) { + static uint16_t hex_val(const char c, uint16_t const dval=0) { if (!seen(c) || *value_ptr != 'x') return dval; uint16_t out = 0; for (char *vp = value_ptr + 1; HEXCHR(*vp) >= 0; vp++) diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index f4152c76e9e5..474f1f252a04 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -29,6 +29,10 @@ #include "../../module/probe.h" #include "../../feature/bedlevel/bedlevel.h" +#if HAS_PTC + #include "../../feature/probe_temp_comp.h" +#endif + /** * G30: Do a single Z probe at the current XY * @@ -37,6 +41,7 @@ * X Probe X position (default current X) * Y Probe Y position (default current Y) * E Engage the probe for each probe (default 1) + * C Enable probe temperature compensation (0 or 1, default 1) */ void GcodeSuite::G30() { @@ -51,7 +56,10 @@ void GcodeSuite::G30() { remember_feedrate_scaling_off(); const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; + + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); const float measured_z = probe.probe_at_point(pos, raise_after, 1); + TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index bd9bb44c4061..33895749193f 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -28,13 +28,33 @@ #include "../../module/motion.h" #include "../../module/probe.h" +#ifdef BLTOUCH_HS_MODE + #include "../../feature/bltouch.h" +#endif + /** * M401: Deploy and activate the Z probe + * + * With BLTOUCH_HS_MODE: + * H Report the current BLTouch HS mode state and exit + * S Set High Speed (HS) Mode and exit without deploy */ void GcodeSuite::M401() { - probe.deploy(); - TERN_(PROBE_TARE, probe.tare()); - report_current_position(); + const bool seenH = parser.seen_test('H'), + seenS = parser.seen('S'); + if (seenH || seenS) { + #ifdef BLTOUCH_HS_MODE + if (seenS) bltouch.high_speed_mode = parser.value_bool(); + SERIAL_ECHO_START(); + SERIAL_ECHOPGM("BLTouch HS mode "); + serialprintln_onoff(bltouch.high_speed_mode); + #endif + } + else { + probe.deploy(); + TERN_(PROBE_TARE, probe.tare()); + report_current_position(); + } } /** diff --git a/Marlin/src/gcode/probe/M423.cpp b/Marlin/src/gcode/probe/M423.cpp new file mode 100644 index 000000000000..fde5aaaf87c9 --- /dev/null +++ b/Marlin/src/gcode/probe/M423.cpp @@ -0,0 +1,99 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * M423.cpp - X-Axis Twist Compensation + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + +#include "../gcode.h" +#include "../../feature/x_twist.h" +#include "../../module/probe.h" + +/** + * M423: Set a Z offset for X-Twist (added to the mesh on future G29). + * M423 [R] [A] [I] [X Z] + * + * R - Reset the twist compensation data + * A - Set the X twist starting X position + * E - Set the X twist ending X position + * I - Set the X twist X-spacing directly + * X - Index of a Z value in the list + * Z - A Z value to set + */ +void GcodeSuite::M423() { + + bool do_report = true; + float new_spacing = 0; + + if (parser.seen_test('R')) { + do_report = false; + xatc.reset(); + } + if (parser.seenval('A')) { + do_report = false; + xatc.start = parser.value_float(); + new_spacing = (probe.max_x() - xatc.start) / (XATC_MAX_POINTS - 1); + } + if (parser.seenval('E')) { + do_report = false; + new_spacing = (parser.value_float() - xatc.start) / (XATC_MAX_POINTS - 1); + } + else if (parser.seenval('I')) { + do_report = false; + new_spacing = parser.value_float(); + } + + if (new_spacing) xatc.spacing = new_spacing; + + if (parser.seenval('X')) { + do_report = false; + const int8_t x = parser.value_int(); + if (!WITHIN(x, 0, XATC_MAX_POINTS - 1)) + SERIAL_ECHOLNPGM("?(X) out of range (0..", XATC_MAX_POINTS - 1, ")."); + else { + if (parser.seenval('Z')) + xatc.z_offset[x] = parser.value_linear_units(); + else + SERIAL_ECHOLNPGM("?(Z) required."); + } + } + + if (do_report) M423_report(); + +} + +void GcodeSuite::M423_report(const bool forReplay/*=true*/) { + report_heading(forReplay, F("X-Twist Correction")); + SERIAL_ECHOLNPGM(" M423 A", xatc.start, " I", xatc.spacing); + LOOP_L_N(x, XATC_MAX_POINTS) { + const float z = xatc.z_offset[x]; + SERIAL_ECHOPGM(" M423 X", x, " Z"); + serial_offset(isnan(z) ? 0 : z); + SERIAL_EOL(); + } +} + +#endif // X_AXIS_TWIST_COMPENSATION diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index fd98a39cd6cb..2250cd3b7452 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -281,7 +281,7 @@ void GCodeQueue::flush_and_request_resend(const serial_index_t serial_ind) { static bool serial_data_available(serial_index_t index) { const int a = SERIAL_IMPL.available(index); - #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE) + #if ENABLED(RX_BUFFER_MONITOR) && RX_BUFFER_SIZE if (a > RX_BUFFER_SIZE - 2) { PORT_REDIRECT(SERIAL_PORTMASK(index)); SERIAL_ERROR_MSG("RX BUF overflow, increase RX_BUFFER_SIZE: ", a); @@ -522,7 +522,7 @@ void GCodeQueue::get_serial_commands() { #if DISABLED(EMERGENCY_PARSER) // Process critical commands early if (command[0] == 'M') switch (command[3]) { - case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_LCD_MENU, wait_for_user = false); } break; + case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_MARLINUI_MENU, wait_for_user = false); } break; case '2': if (command[2] == '1' && command[1] == '1') kill(FPSTR(M112_KILL_STR), nullptr, true); break; case '0': if (command[1] == '4' && command[2] == '1') quickstop_stepper(); break; } diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 82e2a7a0e4da..1a2baaa6bbc4 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -126,14 +126,14 @@ class GCodeQueue { * Don't inject comments or use leading spaces! * Aborts the current PROGMEM queue so only use for one or two commands. */ - static inline void inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; } - static inline void inject(FSTR_P const fgcode) { inject_P(FTOP(fgcode)); } + static void inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; } + static void inject(FSTR_P const fgcode) { inject_P(FTOP(fgcode)); } /** * Enqueue command(s) to run from SRAM. Drained by process_injected_command(). * Aborts the current SRAM queue so only use for one or two commands. */ - static inline void inject(const char * const gcode) { + static void inject(const char * const gcode) { strncpy(injected_commands, gcode, sizeof(injected_commands) - 1); } @@ -158,7 +158,7 @@ class GCodeQueue { * Enqueue from program memory and return only when commands are actually enqueued */ static void enqueue_now_P(PGM_P const pcmd); - static inline void enqueue_now(FSTR_P const fcmd) { enqueue_now_P(FTOP(fcmd)); } + static void enqueue_now(FSTR_P const fcmd) { enqueue_now_P(FTOP(fcmd)); } /** * Check whether there are any commands yet to be executed @@ -192,7 +192,7 @@ class GCodeQueue { * P Planner space remaining * B Block queue space remaining */ - static inline void ok_to_send() { ring_buffer.ok_to_send(); } + static void ok_to_send() { ring_buffer.ok_to_send(); } /** * Clear the serial line and request a resend of @@ -203,7 +203,7 @@ class GCodeQueue { /** * (Re)Set the current line number for the last received command */ - static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; } + static void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; } #if ENABLED(BUFFER_MONITORING) @@ -237,7 +237,7 @@ class GCodeQueue { static void auto_report_buffer_statistics(); - static inline void set_auto_report_interval(uint8_t v) { + static void set_auto_report_interval(uint8_t v) { NOMORE(v, 60); auto_buffer_report_interval = v; next_buffer_report_ms = millis() + 1000UL * v; diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 417f3747c17f..197177882c31 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -49,8 +49,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(HOST_ACTION_COMMANDS) @@ -98,7 +98,7 @@ void GcodeSuite::M1001() { printerEventLEDs.onPrintCompleted(); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE))); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR))); - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30)))); + TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30)))); printerEventLEDs.onResumeAfterWait(); } #endif @@ -108,8 +108,8 @@ void GcodeSuite::M1001() { process_subcommands_now(F(SD_FINISHED_RELEASECOMMAND)); #endif - TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished()); + TERN_(EXTENSIBLE_UI, ExtUI::onPrintDone()); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); // Re-select the last printed file in the UI TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file()); diff --git a/Marlin/src/gcode/sd/M20.cpp b/Marlin/src/gcode/sd/M20.cpp index 573183833854..c640309be8c8 100644 --- a/Marlin/src/gcode/sd/M20.cpp +++ b/Marlin/src/gcode/sd/M20.cpp @@ -33,7 +33,13 @@ void GcodeSuite::M20() { if (card.flag.mounted) { SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST); - card.ls(TERN_(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L'))); + card.ls( + TERN_(CUSTOM_FIRMWARE_UPLOAD, parser.boolval('F')) + #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) + , + #endif + TERN_(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L')) + ); SERIAL_ECHOLNPGM(STR_END_FILE_LIST); } else diff --git a/Marlin/src/gcode/sd/M21_M22.cpp b/Marlin/src/gcode/sd/M21_M22.cpp index f42784d8eb43..aec0de27ca5c 100644 --- a/Marlin/src/gcode/sd/M21_M22.cpp +++ b/Marlin/src/gcode/sd/M21_M22.cpp @@ -26,19 +26,30 @@ #include "../gcode.h" #include "../../sd/cardreader.h" -#include "../../lcd/marlinui.h" /** * M21: Init SD Card + * + * With MULTI_VOLUME: + * P0 or S - Change to the SD Card and mount it + * P1 or U - Change to the USB Drive and mount it */ -void GcodeSuite::M21() { card.mount(); } +void GcodeSuite::M21() { + #if ENABLED(MULTI_VOLUME) + const int8_t vol = parser.intval('P', -1); + if (vol == 0 || parser.seen_test('S')) // "S" for SD Card + card.changeMedia(&card.media_driver_sdcard); + else if (vol == 1 || parser.seen_test('U')) // "U" for USB + card.changeMedia(&card.media_driver_usbFlash); + #endif + card.mount(); +} /** * M22: Release SD Card */ void GcodeSuite::M22() { if (!IS_SD_PRINTING()) card.release(); - IF_ENABLED(TFT_COLOR_UI, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT)); } #endif // SDSUPPORT diff --git a/Marlin/src/gcode/sd/M524.cpp b/Marlin/src/gcode/sd/M524.cpp index e7159155655c..001a1e184263 100644 --- a/Marlin/src/gcode/sd/M524.cpp +++ b/Marlin/src/gcode/sd/M524.cpp @@ -27,15 +27,27 @@ #include "../gcode.h" #include "../../sd/cardreader.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" +#endif + /** * M524: Abort the current SD print job (started with M24) */ void GcodeSuite::M524() { - if (IS_SD_PRINTING()) - card.abortFilePrintSoon(); - else if (card.isMounted()) - card.closefile(); + #if ENABLED(DWIN_LCD_PROUI) + + HMI_flag.abort_flag = true; // The LCD will handle it + + #else + + if (IS_SD_PRINTING()) + card.abortFilePrintSoon(); + else if (card.isMounted()) + card.closefile(); + + #endif } diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 7d16899fd34e..0ed1e6693013 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -29,8 +29,8 @@ #include "../../MarlinCore.h" // for startOrResumeJob -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif /** @@ -38,9 +38,9 @@ */ void GcodeSuite::M75() { startOrResumeJob(); - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); + #if ENABLED(DWIN_LCD_PROUI) DWIN_Print_Started(false); + if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); #endif } @@ -50,6 +50,7 @@ void GcodeSuite::M75() { void GcodeSuite::M76() { print_job_timer.pause(); TERN_(HOST_PAUSE_M76, hostui.pause()); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); } /** @@ -57,7 +58,7 @@ void GcodeSuite::M76() { */ void GcodeSuite::M77() { print_job_timer.stop(); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished()); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); } #if ENABLED(PRINTCOUNTER) diff --git a/Marlin/src/gcode/temp/M123.cpp b/Marlin/src/gcode/temp/M123.cpp new file mode 100644 index 000000000000..389656ef342b --- /dev/null +++ b/Marlin/src/gcode/temp/M123.cpp @@ -0,0 +1,48 @@ +/** + * 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 . + * + */ + +#include "../../inc/MarlinConfig.h" + +#if HAS_FANCHECK + +#include "../gcode.h" +#include "../../feature/fancheck.h" + +/** + * M123: Report fan states -or- set interval for auto-report + * + * S : Set auto-report interval + */ +void GcodeSuite::M123() { + + #if ENABLED(AUTO_REPORT_FANS) + if (parser.seenval('S')) { + fan_check.auto_reporter.set_interval(parser.value_byte()); + return; + } + #endif + + fan_check.print_fan_states(); + +} + +#endif // HAS_FANCHECK diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index f823aefbed97..c1e400511c91 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -30,8 +30,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif /** @@ -73,14 +73,21 @@ void GcodeSuite::M303() { default: SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); return; } - const celsius_t temp = parser.celsiusval('S', default_temp); - const int c = parser.intval('C', 5); + const bool seenC = parser.seenval('C'); + const int c = seenC ? parser.value_int() : 5; + const bool seenS = parser.seenval('S'); + const celsius_t temp = seenS ? parser.value_celsius() : default_temp; const bool u = parser.boolval('U'); + #if ENABLED(DWIN_LCD_PROUI) + if (seenC) HMI_data.PidCycles = c; + if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; } + #endif + #if DISABLED(BUSY_WHILE_HEATING) KEEPALIVE_STATE(NOT_BUSY); #endif diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 7b0c9928685c..33d9e462209d 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -31,8 +31,8 @@ #define MKS_MINI_12864 #endif -// MKS_MINI_12864_V3 is simply identical to FYSETC_MINI_12864_2_1 -#if ENABLED(MKS_MINI_12864_V3) +// MKS_MINI_12864_V3 and BTT_MINI_12864_V1 are identical to FYSETC_MINI_12864_2_1 +#if EITHER(MKS_MINI_12864_V3, BTT_MINI_12864_V1) #define FYSETC_MINI_12864_2_1 #endif @@ -78,8 +78,8 @@ // This helps to implement HAS_ADC_BUTTONS menus #define REVERSE_MENU_DIRECTION - #define ENCODER_PULSES_PER_STEP 1 - #define ENCODER_STEPS_PER_MENU_ITEM 1 + #define STD_ENCODER_PULSES_PER_STEP 1 + #define STD_ENCODER_STEPS_PER_MENU_ITEM 1 #define ENCODER_FEEDRATE_DEADZONE 2 #elif ENABLED(ZONESTAR_12864LCD) @@ -97,7 +97,7 @@ #elif ENABLED(RADDS_DISPLAY) #define IS_ULTIPANEL 1 - #define ENCODER_PULSES_PER_STEP 2 + #define STD_ENCODER_PULSES_PER_STEP 2 #elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864) @@ -158,44 +158,19 @@ #define IS_RRD_SC 1 #define U8GLIB_SH1106 - #define LED_CONTROL_MENU - #define NEOPIXEL_LED - #undef NEOPIXEL_TYPE - #define NEOPIXEL_TYPE NEO_RGB - #if NEOPIXEL_PIXELS < 3 - #undef NEOPIXELS_PIXELS - #define NEOPIXEL_PIXELS 3 - #endif #ifndef NEOPIXEL_BRIGHTNESS #define NEOPIXEL_BRIGHTNESS 127 #endif - #if ENABLED(PSU_CONTROL) - #define LED_BACKLIGHT_TIMEOUT 10000 - #endif - #elif ANY(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) #define FYSETC_MINI_12864 #define DOGLCD #define IS_ULTIPANEL 1 #define LED_COLORS_REDUCE_GREEN - #if ENABLED(PSU_CONTROL) && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) - #define LED_BACKLIGHT_TIMEOUT 10000 - #endif // Require LED backlighting enabled - #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) - #define RGB_LED - #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LED_CONTROL_MENU - #define NEOPIXEL_LED - #undef NEOPIXEL_TYPE - #define NEOPIXEL_TYPE NEO_RGB - #if NEOPIXEL_PIXELS < 3 - #undef NEOPIXELS_PIXELS - #define NEOPIXEL_PIXELS 3 - #endif + #if ENABLED(FYSETC_MINI_12864_2_1) #ifndef NEOPIXEL_BRIGHTNESS #define NEOPIXEL_BRIGHTNESS 127 #endif @@ -207,8 +182,11 @@ #define IS_ULTIPANEL 1 #define U8GLIB_SSD1309 #define LCD_RESET_PIN LCD_PINS_D6 // This controller need a reset pin - #define ENCODER_PULSES_PER_STEP 2 - #define ENCODER_STEPS_PER_MENU_ITEM 2 + #define STD_ENCODER_PULSES_PER_STEP 4 + #define STD_ENCODER_STEPS_PER_MENU_ITEM 1 + #ifndef PCA9632 + #define PCA9632 + #endif #elif ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) @@ -234,7 +212,7 @@ #define LCD_HEIGHT 10 // Character lines #define LCD_CONTRAST_MIN 127 #define LCD_CONTRAST_MAX 255 - #define DEFAULT_LCD_CONTRAST 250 + #define LCD_CONTRAST_DEFAULT 250 #define CONVERT_TO_EXT_ASCII // Use extended 128-255 symbols from ASCII table. // At this time present conversion only for cyrillic - bg, ru and uk languages. // First 7 ASCII symbols in panel font must be replaced with Marlin's special symbols. @@ -302,8 +280,8 @@ #define PCA9632_BUZZER #define PCA9632_BUZZER_DATA { 0x09, 0x02 } - #define ENCODER_PULSES_PER_STEP 1 // Overlord uses buttons - #define ENCODER_STEPS_PER_MENU_ITEM 1 + #define STD_ENCODER_PULSES_PER_STEP 1 // Overlord uses buttons + #define STD_ENCODER_STEPS_PER_MENU_ITEM 1 #endif // 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106 @@ -495,25 +473,33 @@ #endif // Aliases for LCD features -#if EITHER(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED) +#if EITHER(DWIN_CREALITY_LCD, DWIN_LCD_PROUI) #define HAS_DWIN_E3V2_BASIC 1 #endif #if EITHER(HAS_DWIN_E3V2_BASIC, DWIN_CREALITY_LCD_JYERSUI) #define HAS_DWIN_E3V2 1 #endif +#if ENABLED(DWIN_LCD_PROUI) + #define DO_LIST_BIN_FILES 1 +#endif // E3V2 extras #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI #define SERIAL_CATCHALL 0 #ifndef LCD_SERIAL_PORT - #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO) + #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_MINI_E3_V3_0, BTT_SKR_E3_TURBO) #define LCD_SERIAL_PORT 1 + #elif MB(CREALITY_V24S1_301) + #define LCD_SERIAL_PORT 2 // Creality Ender3S1 board #else #define LCD_SERIAL_PORT 3 // Creality 4.x board #endif #endif #define HAS_LCD_BRIGHTNESS 1 #define LCD_BRIGHTNESS_MAX 250 + #if ENABLED(DWIN_LCD_PROUI) + #define LCD_BRIGHTNESS_DEFAULT 127 + #endif #endif #if IS_ULTRA_LCD @@ -530,16 +516,24 @@ #endif #endif -#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) +#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) #define HAS_DISPLAY 1 #endif +#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI + #define HAS_LCDPRINT 1 +#endif + #if ANY(HAS_DISPLAY, HAS_DWIN_E3V2, GLOBAL_STATUS_MESSAGE) #define HAS_STATUS_MESSAGE 1 #endif #if IS_ULTIPANEL && DISABLED(NO_LCD_MENUS) - #define HAS_LCD_MENU 1 + #define HAS_MARLINUI_MENU 1 +#endif + +#if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2) + #define HAS_MANUAL_MOVE_MENU 1 #endif #if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI, DWIN_CREALITY_LCD_JYERSUI) @@ -693,6 +687,15 @@ #define HAS_Y_AXIS 1 #if LINEAR_AXES >= XYZ #define HAS_Z_AXIS 1 + #if LINEAR_AXES >= 4 + #define HAS_I_AXIS 1 + #if LINEAR_AXES >= 5 + #define HAS_J_AXIS 1 + #if LINEAR_AXES >= 6 + #define HAS_K_AXIS 1 + #endif + #endif + #endif #endif #endif @@ -822,7 +825,7 @@ /** * Set a flag for any type of bed probe, including the paper-test */ -#if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE) +#if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE, MAGLEV4) #define HAS_BED_PROBE 1 #endif @@ -1079,7 +1082,7 @@ #define CORE_AXIS_2 C_AXIS #endif #define CORESIGN(n) (ANY(COREYX, COREZX, COREZY) ? (-(n)) : (n)) -#elif ENABLED(MARKFORGED_XY) +#elif EITHER(MARKFORGED_XY, MARKFORGED_YX) // Markforged kinematics #define CORE_AXIS_1 A_AXIS #define CORE_AXIS_2 B_AXIS @@ -1215,13 +1218,13 @@ #if HAS_Z_AXIS && !defined(INVERT_Z_DIR) #define INVERT_Z_DIR false #endif -#if LINEAR_AXES >= 4 && !defined(INVERT_I_DIR) +#if HAS_I_AXIS && !defined(INVERT_I_DIR) #define INVERT_I_DIR false #endif -#if LINEAR_AXES >= 5 && !defined(INVERT_J_DIR) +#if HAS_J_AXIS && !defined(INVERT_J_DIR) #define INVERT_J_DIR false #endif -#if LINEAR_AXES >= 6 && !defined(INVERT_K_DIR) +#if HAS_K_AXIS && !defined(INVERT_K_DIR) #define INVERT_K_DIR false #endif #if HAS_EXTRUDERS && !defined(INVERT_E_DIR) @@ -1411,7 +1414,7 @@ #endif #endif -#if ANY(USE_XMIN_PLUG, USE_YMIN_PLUG, USE_ZMIN_PLUG, USE_XMAX_PLUG, USE_YMAX_PLUG, USE_ZMAX_PLUG) +#if X_HOME_DIR || (HAS_Y_AXIS && Y_HOME_DIR) || (HAS_Z_AXIS && Z_HOME_DIR) || (HAS_I_AXIS && I_HOME_DIR) || (HAS_J_AXIS && J_HOME_DIR) || (HAS_K_AXIS && K_HOME_DIR) #define HAS_ENDSTOPS 1 #define COORDINATE_OKAY(N,L,H) WITHIN(N,L,H) #else diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 49067a560676..d63395a7199f 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -23,7 +23,7 @@ /** * Conditionals_adv.h - * Defines that depend on advanced configuration. + * Conditionals set before pins.h and which depend on Configuration_adv.h. */ #ifndef AXIS_RELATIVE_MODES @@ -118,9 +118,9 @@ // Temperature sensor IDs #define HID_REDUNDANT -6 -#define HID_COOLER -5 -#define HID_PROBE -4 -#define HID_BOARD -3 +#define HID_BOARD -5 +#define HID_COOLER -4 +#define HID_PROBE -3 #define HID_CHAMBER -2 #define HID_BED -1 #define HID_E0 0 @@ -159,6 +159,9 @@ #ifndef MAX31865_SENSOR_WIRES_0 #define MAX31865_SENSOR_WIRES_0 2 #endif + #ifndef MAX31865_WIRE_OHMS_0 + #define MAX31865_WIRE_OHMS_0 0.0f + #endif #elif TEMP_SENSOR_0 == -3 #define TEMP_SENSOR_0_IS_MAX31855 1 #define TEMP_SENSOR_0_MAX_TC_TMIN -270 @@ -193,6 +196,9 @@ #ifndef MAX31865_SENSOR_WIRES_1 #define MAX31865_SENSOR_WIRES_1 2 #endif + #ifndef MAX31865_WIRE_OHMS_1 + #define MAX31865_WIRE_OHMS_1 0.0f + #endif #elif TEMP_SENSOR_1 == -3 #define TEMP_SENSOR_1_IS_MAX31855 1 #define TEMP_SENSOR_1_MAX_TC_TMIN -270 @@ -612,6 +618,8 @@ #if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED) #define HAS_COLOR_LEDS 1 +#else + #undef LED_POWEROFF_TIMEOUT #endif #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) #define HAS_LEDS_OFF_FLAG 1 @@ -622,7 +630,8 @@ #endif #if ENABLED(Z_STEPPER_AUTO_ALIGN) - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #ifdef Z_STEPPER_ALIGN_STEPPER_XY + #define HAS_Z_STEPPER_ALIGN_STEPPER_XY 1 #undef Z_STEPPER_ALIGN_AMP #endif #ifndef Z_STEPPER_ALIGN_AMP @@ -671,11 +680,6 @@ #define CUTTER_UNIT_IS(V) (_CUTTER_POWER(CUTTER_POWER_UNIT) == _CUTTER_POWER(V)) #endif -// Add features that need hardware PWM here -#if ANY(FAST_PWM_FAN, SPINDLE_LASER_USE_PWM) - #define NEEDS_HARDWARE_PWM 1 -#endif - #if !defined(__AVR__) || !defined(USBCON) // Define constants and variables for buffering serial data. // Use only 0 or powers of 2 greater than 1 @@ -737,9 +741,6 @@ #endif #if EITHER(FYSETC_MINI_12864_2_1, FYSETC_242_OLED_12864) - #define LED_CONTROL_MENU - #define LED_USER_PRESET_STARTUP - #define LED_COLOR_PRESETS #ifndef LED_USER_PRESET_GREEN #define LED_USER_PRESET_GREEN 128 #endif @@ -980,8 +981,13 @@ #endif #endif +// Flags for Case Light having a brightness property +#if ENABLED(CASE_LIGHT_ENABLE) && (NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)) + #define CASELIGHT_USES_BRIGHTNESS 1 +#endif + // Flag whether least_squares_fit.cpp is used -#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) +#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, HAS_Z_STEPPER_ALIGN_STEPPER_XY) #define NEED_LSF 1 #endif @@ -998,3 +1004,9 @@ #if EITHER(MEATPACK_ON_SERIAL_PORT_1, MEATPACK_ON_SERIAL_PORT_2) #define HAS_MEATPACK 1 #endif + +// AVR are (usually) too limited in resources to store the configuration into the binary +#if ENABLED(CONFIGURATION_EMBEDDING) && !defined(FORCE_CONFIG_EMBED) && (defined(__AVR__) || DISABLED(SDSUPPORT) || EITHER(SDCARD_READONLY, DISABLE_M503)) + #undef CONFIGURATION_EMBEDDING + #define CANNOT_EMBED_CONFIGURATION defined(__AVR__) +#endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 8008461547ce..9942f14eee87 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -23,7 +23,7 @@ /** * Conditionals_post.h - * Defines that depend on configuration but are not editable. + * Internal defines that depend on Configurations and Pins but are not user-editable. */ #ifdef GITHUB_ACTIONS @@ -78,13 +78,13 @@ /** * Axis lengths and center */ -#ifndef AXIS4_NAME +#if HAS_I_AXIS && !defined(AXIS4_NAME) #define AXIS4_NAME 'A' #endif -#ifndef AXIS5_NAME +#if HAS_J_AXIS && !defined(AXIS5_NAME) #define AXIS5_NAME 'B' #endif -#ifndef AXIS6_NAME +#if HAS_K_AXIS && !defined(AXIS6_NAME) #define AXIS6_NAME 'C' #endif @@ -97,13 +97,13 @@ #else #undef CONTROLLER_FAN_USE_Z_ONLY #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define I_MAX_LENGTH (I_MAX_POS - (I_MIN_POS)) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define J_MAX_LENGTH (J_MAX_POS - (J_MIN_POS)) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define K_MAX_LENGTH (K_MAX_POS - (K_MIN_POS)) #endif @@ -114,13 +114,13 @@ #if HAS_Y_AXIS && !defined(Y_BED_SIZE) #define Y_BED_SIZE Y_MAX_LENGTH #endif -#if LINEAR_AXES >= 4 && !defined(I_BED_SIZE) +#if HAS_I_AXIS && !defined(I_BED_SIZE) #define I_BED_SIZE I_MAX_LENGTH #endif -#if LINEAR_AXES >= 5 && !defined(J_BED_SIZE) +#if HAS_J_AXIS && !defined(J_BED_SIZE) #define J_BED_SIZE J_MAX_LENGTH #endif -#if LINEAR_AXES >= 6 && !defined(K_BED_SIZE) +#if HAS_K_AXIS && !defined(K_BED_SIZE) #define K_BED_SIZE K_MAX_LENGTH #endif @@ -134,13 +134,13 @@ #if HAS_Y_AXIS #define _Y_HALF_BED ((Y_BED_SIZE) / 2) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define _I_HALF_IMAX ((I_BED_SIZE) / 2) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define _J_HALF_JMAX ((J_BED_SIZE) / 2) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define _K_HALF_KMAX ((K_BED_SIZE) / 2) #endif @@ -149,13 +149,13 @@ #define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED) #define XY_CENTER { X_CENTER, Y_CENTER } #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define I_CENTER TERN(BED_CENTER_AT_0_0, 0, _I_HALF_BED) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define J_CENTER TERN(BED_CENTER_AT_0_0, 0, _J_HALF_BED) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define K_CENTER TERN(BED_CENTER_AT_0_0, 0, _K_HALF_BED) #endif @@ -166,15 +166,15 @@ #define Y_MIN_BED (Y_CENTER - _Y_HALF_BED) #define Y_MAX_BED (Y_MIN_BED + Y_BED_SIZE) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define I_MINIM (I_CENTER - _I_HALF_BED_SIZE) #define I_MAXIM (I_MINIM + I_BED_SIZE) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define J_MINIM (J_CENTER - _J_HALF_BED_SIZE) #define J_MAXIM (J_MINIM + J_BED_SIZE) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define K_MINIM (K_CENTER - _K_HALF_BED_SIZE) #define K_MAXIM (K_MINIM + K_BED_SIZE) #endif @@ -193,7 +193,7 @@ // Calibration codes only for non-core axes #if EITHER(BACKLASH_GCODE, CALIBRATION_GCODE) - #if EITHER(IS_CORE, MARKFORGED_XY) + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) #define CAN_CALIBRATE(A,B) (_AXIS(A) == B) #else #define CAN_CALIBRATE(A,B) true @@ -253,21 +253,21 @@ #define Z_HOME_POS TERN(Z_HOME_TO_MIN, Z_MIN_POS, Z_MAX_POS) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #ifdef MANUAL_I_HOME_POS #define I_HOME_POS MANUAL_I_HOME_POS #else #define I_HOME_POS TERN(I_HOME_TO_MIN, I_MIN_POS, I_MAX_POS) #endif #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #ifdef MANUAL_J_HOME_POS #define J_HOME_POS MANUAL_J_HOME_POS #else #define J_HOME_POS TERN(J_HOME_TO_MIN, J_MIN_POS, J_MAX_POS) #endif #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #ifdef MANUAL_K_HOME_POS #define K_HOME_POS MANUAL_K_HOME_POS #else @@ -373,11 +373,11 @@ #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) #define _LCD_CONTRAST_MIN 120 #define _LCD_CONTRAST_INIT 195 -#elif ENABLED(MKS_MINI_12864_V3) +#elif EITHER(MKS_MINI_12864_V3, BTT_MINI_12864_V1) #define _LCD_CONTRAST_MIN 255 #define _LCD_CONTRAST_INIT 255 - #define _LCD_CONTRAST_MAX 255 #elif ENABLED(FYSETC_MINI_12864) + #define _LCD_CONTRAST_MIN 180 #define _LCD_CONTRAST_INIT 220 #elif ENABLED(ULTI_CONTROLLER) #define _LCD_CONTRAST_INIT 127 @@ -389,18 +389,12 @@ #elif ENABLED(ZONESTAR_12864OLED) #define _LCD_CONTRAST_MIN 64 #define _LCD_CONTRAST_INIT 128 - #define _LCD_CONTRAST_MAX 255 #elif IS_TFTGLCD_PANEL - #define _LCD_CONTRAST_MIN 0 #define _LCD_CONTRAST_INIT 250 - #define _LCD_CONTRAST_MAX 255 #endif #ifdef _LCD_CONTRAST_INIT #define HAS_LCD_CONTRAST 1 -#endif - -#if HAS_LCD_CONTRAST #ifndef LCD_CONTRAST_MIN #ifdef _LCD_CONTRAST_MIN #define LCD_CONTRAST_MIN _LCD_CONTRAST_MIN @@ -420,8 +414,8 @@ #define LCD_CONTRAST_MAX 63 // ST7567 6-bits contrast #endif #endif - #ifndef DEFAULT_LCD_CONTRAST - #define DEFAULT_LCD_CONTRAST LCD_CONTRAST_INIT + #ifndef LCD_CONTRAST_DEFAULT + #define LCD_CONTRAST_DEFAULT LCD_CONTRAST_INIT #endif #endif @@ -443,7 +437,7 @@ // Set SD_DETECT_STATE based on hardware if not overridden #if PIN_EXISTS(SD_DETECT) && !defined(SD_DETECT_STATE) - #if BOTH(HAS_LCD_MENU, ELB_FULL_GRAPHIC_CONTROLLER) && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)) + #if BOTH(HAS_MARLINUI_MENU, ELB_FULL_GRAPHIC_CONTROLLER) && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)) #define SD_DETECT_STATE HIGH #else #define SD_DETECT_STATE LOW @@ -465,8 +459,8 @@ #endif -#if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI) || !PIN_EXISTS(SD_DETECT) - #define NO_LCD_REINIT 1 // Suppress LCD re-initialization +#if PIN_EXISTS(SD_DETECT) && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2) + #define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion #endif /** @@ -507,7 +501,13 @@ #ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 #endif - #if REDUNDANT_TEMP_MATCH(SOURCE, COOLER) + #if REDUNDANT_TEMP_MATCH(SOURCE, BOARD) + #if !PIN_EXISTS(TEMP_BOARD) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to BOARD requires TEMP_BOARD_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_BOARD_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, COOLER) #if !PIN_EXISTS(TEMP_COOLER) #error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN." #else @@ -745,7 +745,7 @@ #define LIB_INTERNAL_MAX31865 1 #endif -#endif //HAS_MAX_TC +#endif // HAS_MAX_TC /** * X_DUAL_ENDSTOPS endstop reassignment @@ -1620,7 +1620,7 @@ #endif #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #if PIN_EXISTS(I_ENABLE) || AXIS_IS_L64XX(I) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) #define HAS_I_ENABLE 1 #endif @@ -1640,7 +1640,7 @@ #undef DISABLE_INACTIVE_I #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #if PIN_EXISTS(J_ENABLE) || AXIS_IS_L64XX(J) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) #define HAS_J_ENABLE 1 #endif @@ -1660,7 +1660,7 @@ #undef DISABLE_INACTIVE_J #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #if PIN_EXISTS(K_ENABLE) || AXIS_IS_L64XX(K) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) #define HAS_K_ENABLE 1 #endif @@ -1861,231 +1861,332 @@ #undef Z3_STALL_SENSITIVITY #undef Z4_STALL_SENSITIVITY #endif - #if defined(X_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X) - #define X_SENSORLESS 1 - #endif - #if defined(X2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2) - #define X2_SENSORLESS 1 - #endif - #if defined(Y_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y) - #define Y_SENSORLESS 1 - #endif - #if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2) - #define Y2_SENSORLESS 1 - #endif - #if defined(Z_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z) - #define Z_SENSORLESS 1 - #endif - #if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2) - #define Z2_SENSORLESS 1 - #endif - #if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3) - #define Z3_SENSORLESS 1 - #endif - #if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4) - #define Z4_SENSORLESS 1 - #endif - #if defined(I_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(I) - #define I_SENSORLESS 1 - #endif - #if defined(J_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(J) - #define J_SENSORLESS 1 - #endif - #if defined(K_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(K) - #define K_SENSORLESS 1 - #endif - #if AXIS_HAS_STEALTHCHOP(X) - #define X_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(X2) - #define X2_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(Y) - #define Y_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(Y2) - #define Y2_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(Z) - #define Z_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(Z2) - #define Z2_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(Z3) - #define Z3_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(Z4) - #define Z4_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(I) - #define I_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(J) - #define J_HAS_STEALTHCHOP 1 - #endif - #if AXIS_HAS_STEALTHCHOP(K) - #define K_HAS_STEALTHCHOP 1 - #endif - #if E_STEPPERS > 0 && AXIS_HAS_STEALTHCHOP(E0) - #define E0_HAS_STEALTHCHOP 1 - #endif - #if E_STEPPERS > 1 && AXIS_HAS_STEALTHCHOP(E1) - #define E1_HAS_STEALTHCHOP 1 - #endif - #if E_STEPPERS > 2 && AXIS_HAS_STEALTHCHOP(E2) - #define E2_HAS_STEALTHCHOP 1 - #endif - #if E_STEPPERS > 3 && AXIS_HAS_STEALTHCHOP(E3) - #define E3_HAS_STEALTHCHOP 1 - #endif - #if E_STEPPERS > 4 && AXIS_HAS_STEALTHCHOP(E4) - #define E4_HAS_STEALTHCHOP 1 - #endif - #if E_STEPPERS > 5 && AXIS_HAS_STEALTHCHOP(E5) - #define E5_HAS_STEALTHCHOP 1 - #endif - #if E_STEPPERS > 6 && AXIS_HAS_STEALTHCHOP(E6) - #define E6_HAS_STEALTHCHOP 1 + #if AXIS_IS_TMC(X) + #if defined(X_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X) + #define X_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(X) + #define X_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) + #define X_SPI_SENSORLESS X_SENSORLESS + #endif + #ifndef X_INTERPOLATE + #define X_INTERPOLATE INTERPOLATE + #endif + #ifndef X_HOLD_MULTIPLIER + #define X_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif #endif - #if E_STEPPERS > 7 && AXIS_HAS_STEALTHCHOP(E7) - #define E7_HAS_STEALTHCHOP 1 + + #if AXIS_IS_TMC(X2) + #if defined(X2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2) + #define X2_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(X2) + #define X2_HAS_STEALTHCHOP 1 + #endif + #ifndef X2_INTERPOLATE + #define X2_INTERPOLATE X_INTERPOLATE + #endif + #ifndef X2_HOLD_MULTIPLIER + #define X2_HOLD_MULTIPLIER X_HOLD_MULTIPLIER + #endif + #ifndef X2_SLAVE_ADDRESS + #define X2_SLAVE_ADDRESS 0 + #endif #endif - #if ENABLED(SPI_ENDSTOPS) - #define X_SPI_SENSORLESS X_SENSORLESS - #if HAS_Y_AXIS + #if AXIS_IS_TMC(Y) + #if defined(Y_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y) + #define Y_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(Y) + #define Y_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) #define Y_SPI_SENSORLESS Y_SENSORLESS #endif - #if HAS_Z_AXIS - #define Z_SPI_SENSORLESS Z_SENSORLESS + #ifndef Y_INTERPOLATE + #define Y_INTERPOLATE INTERPOLATE #endif - #if LINEAR_AXES >= 4 - #define I_SPI_SENSORLESS I_SENSORLESS + #ifndef Y_HOLD_MULTIPLIER + #define Y_HOLD_MULTIPLIER HOLD_MULTIPLIER #endif - #if LINEAR_AXES >= 5 - #define J_SPI_SENSORLESS J_SENSORLESS + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 0 #endif - #if LINEAR_AXES >= 6 - #define K_SPI_SENSORLESS K_SENSORLESS + #if ENABLED(Y_DUAL_STEPPER_DRIVERS) + #if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2) + #define Y2_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(Y2) + #define Y2_HAS_STEALTHCHOP 1 + #endif + #ifndef Y2_INTERPOLATE + #define Y2_INTERPOLATE Y_INTERPOLATE + #endif + #ifndef Y2_HOLD_MULTIPLIER + #define Y2_HOLD_MULTIPLIER Y_HOLD_MULTIPLIER + #endif + #ifndef Y2_SLAVE_ADDRESS + #define Y2_SLAVE_ADDRESS 0 + #endif #endif #endif - #ifndef X_INTERPOLATE - #define X_INTERPOLATE INTERPOLATE - #endif - #ifndef X2_INTERPOLATE - #define X2_INTERPOLATE INTERPOLATE - #endif - #ifndef Y_INTERPOLATE - #define Y_INTERPOLATE INTERPOLATE - #endif - #ifndef Y2_INTERPOLATE - #define Y2_INTERPOLATE INTERPOLATE - #endif - #ifndef Z_INTERPOLATE - #define Z_INTERPOLATE INTERPOLATE - #endif - #ifndef Z2_INTERPOLATE - #define Z2_INTERPOLATE INTERPOLATE - #endif - #ifndef Z3_INTERPOLATE - #define Z3_INTERPOLATE INTERPOLATE - #endif - #ifndef Z4_INTERPOLATE - #define Z4_INTERPOLATE INTERPOLATE - #endif - #if LINEAR_AXES >= 4 && !defined(I_INTERPOLATE) - #define I_INTERPOLATE INTERPOLATE - #endif - #if LINEAR_AXES >= 5 && !defined(J_INTERPOLATE) - #define J_INTERPOLATE INTERPOLATE - #endif - #if LINEAR_AXES >= 6 && !defined(K_INTERPOLATE) - #define K_INTERPOLATE INTERPOLATE - #endif - #ifndef E0_INTERPOLATE - #define E0_INTERPOLATE INTERPOLATE - #endif - #ifndef E1_INTERPOLATE - #define E1_INTERPOLATE INTERPOLATE - #endif - #ifndef E2_INTERPOLATE - #define E2_INTERPOLATE INTERPOLATE - #endif - #ifndef E3_INTERPOLATE - #define E3_INTERPOLATE INTERPOLATE - #endif - #ifndef E4_INTERPOLATE - #define E4_INTERPOLATE INTERPOLATE - #endif - #ifndef E5_INTERPOLATE - #define E5_INTERPOLATE INTERPOLATE - #endif - #ifndef E6_INTERPOLATE - #define E6_INTERPOLATE INTERPOLATE - #endif - #ifndef E7_INTERPOLATE - #define E7_INTERPOLATE INTERPOLATE - #endif - #ifndef X_SLAVE_ADDRESS - #define X_SLAVE_ADDRESS 0 - #endif - #ifndef Y_SLAVE_ADDRESS - #define Y_SLAVE_ADDRESS 0 - #endif - #ifndef Z_SLAVE_ADDRESS - #define Z_SLAVE_ADDRESS 0 - #endif - #ifndef I_SLAVE_ADDRESS - #define I_SLAVE_ADDRESS 0 - #endif - #ifndef J_SLAVE_ADDRESS - #define J_SLAVE_ADDRESS 0 - #endif - #ifndef K_SLAVE_ADDRESS - #define K_SLAVE_ADDRESS 0 - #endif - #ifndef X2_SLAVE_ADDRESS - #define X2_SLAVE_ADDRESS 0 - #endif - #ifndef Y2_SLAVE_ADDRESS - #define Y2_SLAVE_ADDRESS 0 + + #if AXIS_IS_TMC(Z) + #if defined(Z_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z) + #define Z_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(Z) + #define Z_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) + #define Z_SPI_SENSORLESS Z_SENSORLESS + #endif + #ifndef Z_INTERPOLATE + #define Z_INTERPOLATE INTERPOLATE + #endif + #ifndef Z_HOLD_MULTIPLIER + #define Z_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 0 + #endif + #if NUM_Z_STEPPER_DRIVERS >= 2 + #if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2) + #define Z2_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(Z2) + #define Z2_HAS_STEALTHCHOP 1 + #endif + #ifndef Z2_INTERPOLATE + #define Z2_INTERPOLATE Z_INTERPOLATE + #endif + #ifndef Z2_HOLD_MULTIPLIER + #define Z2_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER + #endif + #ifndef Z2_SLAVE_ADDRESS + #define Z2_SLAVE_ADDRESS 0 + #endif + #endif + #if NUM_Z_STEPPER_DRIVERS >= 3 + #if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3) + #define Z3_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(Z3) + #define Z3_HAS_STEALTHCHOP 1 + #endif + #ifndef Z3_INTERPOLATE + #define Z3_INTERPOLATE Z_INTERPOLATE + #endif + #ifndef Z3_HOLD_MULTIPLIER + #define Z3_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER + #endif + #ifndef Z3_SLAVE_ADDRESS + #define Z3_SLAVE_ADDRESS 0 + #endif + #endif + #if NUM_Z_STEPPER_DRIVERS >= 4 + #if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4) + #define Z4_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(Z4) + #define Z4_HAS_STEALTHCHOP 1 + #endif + #ifndef Z4_INTERPOLATE + #define Z4_INTERPOLATE Z_INTERPOLATE + #endif + #ifndef Z4_HOLD_MULTIPLIER + #define Z4_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER + #endif + #ifndef Z4_SLAVE_ADDRESS + #define Z4_SLAVE_ADDRESS 0 + #endif + #endif #endif - #ifndef Z2_SLAVE_ADDRESS - #define Z2_SLAVE_ADDRESS 0 + + #if AXIS_IS_TMC(I) + #if defined(I_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(I) + #define I_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(I) + #define I_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) + #define I_SPI_SENSORLESS I_SENSORLESS + #endif + #ifndef I_INTERPOLATE + #define I_INTERPOLATE INTERPOLATE + #endif + #ifndef I_HOLD_MULTIPLIER + #define I_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef I_SLAVE_ADDRESS + #define I_SLAVE_ADDRESS 0 + #endif #endif - #ifndef Z3_SLAVE_ADDRESS - #define Z3_SLAVE_ADDRESS 0 + + #if AXIS_IS_TMC(J) + #if defined(J_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(J) + #define J_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(J) + #define J_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) + #define J_SPI_SENSORLESS J_SENSORLESS + #endif + #ifndef J_INTERPOLATE + #define J_INTERPOLATE INTERPOLATE + #endif + #ifndef J_HOLD_MULTIPLIER + #define J_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef J_SLAVE_ADDRESS + #define J_SLAVE_ADDRESS 0 + #endif #endif - #ifndef Z4_SLAVE_ADDRESS - #define Z4_SLAVE_ADDRESS 0 + + #if AXIS_IS_TMC(K) + #if defined(K_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(K) + #define K_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(K) + #define K_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) + #define K_SPI_SENSORLESS K_SENSORLESS + #endif + #ifndef K_INTERPOLATE + #define K_INTERPOLATE INTERPOLATE + #endif + #ifndef K_HOLD_MULTIPLIER + #define K_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef K_SLAVE_ADDRESS + #define K_SLAVE_ADDRESS 0 + #endif #endif - #ifndef E0_SLAVE_ADDRESS - #define E0_SLAVE_ADDRESS 0 + + #if AXIS_IS_TMC(E0) + #if AXIS_HAS_STEALTHCHOP(E0) + #define E0_HAS_STEALTHCHOP 1 + #endif + #ifndef E0_INTERPOLATE + #define E0_INTERPOLATE INTERPOLATE + #endif + #ifndef E0_HOLD_MULTIPLIER + #define E0_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0 + #endif #endif - #ifndef E1_SLAVE_ADDRESS - #define E1_SLAVE_ADDRESS 0 + #if AXIS_IS_TMC(E1) + #if AXIS_HAS_STEALTHCHOP(E1) + #define E1_HAS_STEALTHCHOP 1 + #endif + #ifndef E1_INTERPOLATE + #define E1_INTERPOLATE E0_INTERPOLATE + #endif + #ifndef E1_HOLD_MULTIPLIER + #define E1_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER + #endif + #ifndef E1_SLAVE_ADDRESS + #define E1_SLAVE_ADDRESS 0 + #endif #endif - #ifndef E2_SLAVE_ADDRESS - #define E2_SLAVE_ADDRESS 0 + #if AXIS_IS_TMC(E2) + #if AXIS_HAS_STEALTHCHOP(E2) + #define E2_HAS_STEALTHCHOP 1 + #endif + #ifndef E2_INTERPOLATE + #define E2_INTERPOLATE E0_INTERPOLATE + #endif + #ifndef E2_HOLD_MULTIPLIER + #define E2_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER + #endif + #ifndef E2_SLAVE_ADDRESS + #define E2_SLAVE_ADDRESS 0 + #endif #endif - #ifndef E3_SLAVE_ADDRESS - #define E3_SLAVE_ADDRESS 0 + #if AXIS_IS_TMC(E3) + #if AXIS_HAS_STEALTHCHOP(E3) + #define E3_HAS_STEALTHCHOP 1 + #endif + #ifndef E3_INTERPOLATE + #define E3_INTERPOLATE E0_INTERPOLATE + #endif + #ifndef E3_HOLD_MULTIPLIER + #define E3_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER + #endif + #ifndef E3_SLAVE_ADDRESS + #define E3_SLAVE_ADDRESS 0 + #endif #endif - #ifndef E4_SLAVE_ADDRESS - #define E4_SLAVE_ADDRESS 0 + #if AXIS_IS_TMC(E4) + #if AXIS_HAS_STEALTHCHOP(E4) + #define E4_HAS_STEALTHCHOP 1 + #endif + #ifndef E4_INTERPOLATE + #define E4_INTERPOLATE E0_INTERPOLATE + #endif + #ifndef E4_HOLD_MULTIPLIER + #define E4_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER + #endif + #ifndef E4_SLAVE_ADDRESS + #define E4_SLAVE_ADDRESS 0 + #endif #endif - #ifndef E5_SLAVE_ADDRESS - #define E5_SLAVE_ADDRESS 0 + #if AXIS_IS_TMC(E5) + #if AXIS_HAS_STEALTHCHOP(E5) + #define E5_HAS_STEALTHCHOP 1 + #endif + #ifndef E5_INTERPOLATE + #define E5_INTERPOLATE E0_INTERPOLATE + #endif + #ifndef E5_HOLD_MULTIPLIER + #define E5_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER + #endif + #ifndef E5_SLAVE_ADDRESS + #define E5_SLAVE_ADDRESS 0 + #endif #endif - #ifndef E6_SLAVE_ADDRESS - #define E6_SLAVE_ADDRESS 0 + #if AXIS_IS_TMC(E6) + #if AXIS_HAS_STEALTHCHOP(E6) + #define E6_HAS_STEALTHCHOP 1 + #endif + #ifndef E6_INTERPOLATE + #define E6_INTERPOLATE E0_INTERPOLATE + #endif + #ifndef E6_HOLD_MULTIPLIER + #define E6_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER + #endif + #ifndef E6_SLAVE_ADDRESS + #define E6_SLAVE_ADDRESS 0 + #endif #endif - #ifndef E7_SLAVE_ADDRESS - #define E7_SLAVE_ADDRESS 0 + #if AXIS_IS_TMC(E7) + #if AXIS_HAS_STEALTHCHOP(E7) + #define E7_HAS_STEALTHCHOP 1 + #endif + #ifndef E7_INTERPOLATE + #define E7_INTERPOLATE E0_INTERPOLATE + #endif + #ifndef E7_HOLD_MULTIPLIER + #define E7_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER + #endif + #ifndef E7_SLAVE_ADDRESS + #define E7_SLAVE_ADDRESS 0 + #endif #endif -#endif +#endif // HAS_TRINAMIC_CONFIG #if ANY_AXIS_HAS(HW_SERIAL) #define HAS_TMC_HW_SERIAL 1 @@ -2113,6 +2214,7 @@ #define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N)) #define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \ || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \ + || TMC_UART_IS(I, N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \ || TMC_UART_IS(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \ || TMC_UART_IS(E0, N) || TMC_UART_IS(E1, N) || TMC_UART_IS(E2, N) || TMC_UART_IS(E3, N) || TMC_UART_IS(E4, N) ) @@ -2294,28 +2396,28 @@ // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // #define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(TEMP_SENSOR_##P##_IS_MAX_TC, TEMP_SENSOR_##P##_IS_DUMMY)) -#if HAS_ADC_TEST(0) +#if HOTENDS > 0 && HAS_ADC_TEST(0) #define HAS_TEMP_ADC_0 1 #endif -#if HAS_ADC_TEST(1) +#if HOTENDS > 1 && HAS_ADC_TEST(1) #define HAS_TEMP_ADC_1 1 #endif -#if HAS_ADC_TEST(2) +#if HOTENDS > 2 && HAS_ADC_TEST(2) #define HAS_TEMP_ADC_2 1 #endif -#if HAS_ADC_TEST(3) +#if HOTENDS > 3 && HAS_ADC_TEST(3) #define HAS_TEMP_ADC_3 1 #endif -#if HAS_ADC_TEST(4) +#if HOTENDS > 4 && HAS_ADC_TEST(4) #define HAS_TEMP_ADC_4 1 #endif -#if HAS_ADC_TEST(5) +#if HOTENDS > 5 && HAS_ADC_TEST(5) #define HAS_TEMP_ADC_5 1 #endif -#if HAS_ADC_TEST(6) +#if HOTENDS > 6 && HAS_ADC_TEST(6) #define HAS_TEMP_ADC_6 1 #endif -#if HAS_ADC_TEST(7) +#if HOTENDS > 7 && HAS_ADC_TEST(7) #define HAS_TEMP_ADC_7 1 #endif #if HAS_ADC_TEST(BED) @@ -2344,12 +2446,12 @@ #if HAS_TEMP(BED) #define HAS_TEMP_BED 1 #endif -#if HAS_TEMP(PROBE) - #define HAS_TEMP_PROBE 1 -#endif #if HAS_TEMP(CHAMBER) #define HAS_TEMP_CHAMBER 1 #endif +#if HAS_TEMP(PROBE) + #define HAS_TEMP_PROBE 1 +#endif #if HAS_TEMP(COOLER) #define HAS_TEMP_COOLER 1 #endif @@ -2448,13 +2550,13 @@ #endif // Thermal protection -#if BOTH(HAS_HEATED_BED, THERMAL_PROTECTION_BED) - #define HAS_THERMALLY_PROTECTED_BED 1 +#if !HAS_HEATED_BED + #undef THERMAL_PROTECTION_BED #endif #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 #define WATCH_HOTENDS 1 #endif -#if HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0 +#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 #define WATCH_BED 1 #endif #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0 @@ -2463,10 +2565,13 @@ #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) && WATCH_COOLER_TEMP_PERIOD > 0 #define WATCH_COOLER 1 #endif +#if NONE(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_COOLER) + #undef THERMAL_PROTECTION_VARIANCE_MONITOR +#endif #if (ENABLED(THERMAL_PROTECTION_HOTENDS) || !EXTRUDERS) \ && (ENABLED(THERMAL_PROTECTION_BED) || !HAS_HEATED_BED) \ && (ENABLED(THERMAL_PROTECTION_CHAMBER) || !HAS_HEATED_CHAMBER) \ - && (ENABLED(THERMAL_PROTECTION_COOLER) || !HAS_COOLER) + && (ENABLED(THERMAL_PROTECTION_COOLER) || !HAS_COOLER) #define THERMALLY_SAFE 1 #endif @@ -2510,10 +2615,42 @@ #define AUTO_CHAMBER_IS_E 1 #endif +// Fans check +#if HAS_HOTEND && PIN_EXISTS(E0_FAN_TACHO) + #define HAS_E0_FAN_TACHO 1 +#endif +#if HOTENDS > 1 && PIN_EXISTS(E1_FAN_TACHO) + #define HAS_E1_FAN_TACHO 1 +#endif +#if HOTENDS > 2 && PIN_EXISTS(E2_FAN_TACHO) + #define HAS_E2_FAN_TACHO 1 +#endif +#if HOTENDS > 3 && PIN_EXISTS(E3_FAN_TACHO) + #define HAS_E3_FAN_TACHO 1 +#endif +#if HOTENDS > 4 && PIN_EXISTS(E4_FAN_TACHO) + #define HAS_E4_FAN_TACHO 1 +#endif +#if HOTENDS > 5 && PIN_EXISTS(E5_FAN_TACHO) + #define HAS_E5_FAN_TACHO 1 +#endif +#if HOTENDS > 6 && PIN_EXISTS(E6_FAN_TACHO) + #define HAS_E6_FAN_TACHO 1 +#endif +#if HOTENDS > 7 && PIN_EXISTS(E7_FAN_TACHO) + #define HAS_E7_FAN_TACHO 1 +#endif +#if ANY(HAS_E0_FAN_TACHO, HAS_E1_FAN_TACHO, HAS_E2_FAN_TACHO, HAS_E3_FAN_TACHO, HAS_E4_FAN_TACHO, HAS_E5_FAN_TACHO, HAS_E6_FAN_TACHO, HAS_E7_FAN_TACHO) + #define HAS_FANCHECK 1 + #if HAS_AUTO_FAN && EXTRUDER_AUTO_FAN_SPEED != 255 && DISABLED(FOURWIRES_FANS) + #define HAS_PWMFANCHECK 1 + #endif +#endif + #if !HAS_TEMP_SENSOR #undef AUTO_REPORT_TEMPERATURES #endif -#if ANY(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS, AUTO_REPORT_POSITION) +#if ANY(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS, AUTO_REPORT_POSITION, AUTO_REPORT_FANS) #define HAS_AUTO_REPORTING 1 #endif @@ -2635,13 +2772,6 @@ #error "FAN_OFF_PWM must be less than or equal to FAN_MIN_PWM." #endif -/** - * FAST PWM FAN Settings - */ -#if ENABLED(FAST_PWM_FAN) && !defined(FAST_PWM_FAN_FREQUENCY) - #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) // Fan frequency default -#endif - /** * Controller Fan Settings */ @@ -2922,7 +3052,7 @@ #define HAS_TEMPERATURE 1 #endif -#if HAS_TEMPERATURE && EITHER(HAS_LCD_MENU, HAS_DWIN_E3V2) +#if HAS_TEMPERATURE && EITHER(HAS_MARLINUI_MENU, HAS_DWIN_E3V2) #ifdef PREHEAT_6_LABEL #define PREHEAT_COUNT 6 #elif defined(PREHEAT_5_LABEL) @@ -3047,7 +3177,7 @@ * Advanced Pause - Filament Change */ #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) + #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) #define M600_PURGE_MORE_RESUMABLE 1 #endif #ifndef FILAMENT_CHANGE_SLOW_LOAD_LENGTH @@ -3277,7 +3407,7 @@ #endif #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU // LCD timeout to status screen default is 15s #ifndef LCD_TIMEOUT_TO_STATUS #define LCD_TIMEOUT_TO_STATUS 15000 diff --git a/Marlin/src/inc/MarlinConfig.h b/Marlin/src/inc/MarlinConfig.h index 8fdb4b9baeae..505a0682ebaa 100644 --- a/Marlin/src/inc/MarlinConfig.h +++ b/Marlin/src/inc/MarlinConfig.h @@ -29,6 +29,7 @@ #ifndef __MARLIN_DEPS__ #include "../HAL/HAL.h" + extern MarlinHAL hal; #endif #include "../pins/pins.h" diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index fbdda2c12758..a94846275e44 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -601,12 +601,22 @@ #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) - #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." -#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) - #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." +#elif defined(LCD_SCREEN_ROT_90) + #error "LCD_SCREEN_ROT_90 is now LCD_SCREEN_ROTATE with a value of 90." +#elif defined(LCD_SCREEN_ROT_180) + #error "LCD_SCREEN_ROT_180 is now LCD_SCREEN_ROTATE with a value of 180." +#elif defined(LCD_SCREEN_ROT_270) + #error "LCD_SCREEN_ROT_270 is now LCD_SCREEN_ROTATE with a value of 270." +#elif defined(DEFAULT_LCD_BRIGHTNESS) + #error "DEFAULT_LCD_BRIGHTNESS is now LCD_BRIGHTNESS_DEFAULT." +#elif defined(NOZZLE_PARK_X_ONLY) + #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 1." +#elif defined(NOZZLE_PARK_Y_ONLY) + #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 2." +#elif defined(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS is now just Z_STEPPER_ALIGN_STEPPER_XY." +#elif defined(DWIN_CREALITY_LCD_ENHANCED) + #error "DWIN_CREALITY_LCD_ENHANCED is now DWIN_LCD_PROUI." #endif constexpr float arm[] = AXIS_RELATIVE_MODES; @@ -791,6 +801,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Enable only one of ENDSTOPPULLUP_Y_MAX or ENDSTOPPULLDOWN_Y_MAX." #elif BOTH(ENDSTOPPULLUP_ZMAX, ENDSTOPPULLDOWN_ZMAX) #error "Enable only one of ENDSTOPPULLUP_Z_MAX or ENDSTOPPULLDOWN_Z_MAX." +#elif BOTH(ENDSTOPPULLUP_IMAX, ENDSTOPPULLDOWN_IMAX) + #error "Enable only one of ENDSTOPPULLUP_I_MAX or ENDSTOPPULLDOWN_I_MAX." +#elif BOTH(ENDSTOPPULLUP_JMAX, ENDSTOPPULLDOWN_JMAX) + #error "Enable only one of ENDSTOPPULLUP_J_MAX or ENDSTOPPULLDOWN_J_MAX." +#elif BOTH(ENDSTOPPULLUP_KMAX, ENDSTOPPULLDOWN_KMAX) + #error "Enable only one of ENDSTOPPULLUP_K_MAX or ENDSTOPPULLDOWN_K_MAX." #elif BOTH(ENDSTOPPULLUP_XMIN, ENDSTOPPULLDOWN_XMIN) #error "Enable only one of ENDSTOPPULLUP_X_MIN or ENDSTOPPULLDOWN_X_MIN." #elif BOTH(ENDSTOPPULLUP_YMIN, ENDSTOPPULLDOWN_YMIN) @@ -824,7 +840,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "LCD_PROGRESS_BAR requires SDSUPPORT or LCD_SET_PROGRESS_MANUALLY." #elif NONE(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) #error "LCD_PROGRESS_BAR only applies to HD44780 character LCD and TFTGLCD_PANEL_(SPI|I2C)." - #elif HAS_MARLINUI_U8GLIB + #elif HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI #error "LCD_PROGRESS_BAR does not apply to graphical displays." #elif ENABLED(FILAMENT_LCD_DISPLAY) #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both." @@ -832,14 +848,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." #endif #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) - #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." + #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." #endif #if ENABLED(USE_M73_REMAINING_TIME) && DISABLED(LCD_SET_PROGRESS_MANUALLY) #error "USE_M73_REMAINING_TIME requires LCD_SET_PROGRESS_MANUALLY" #endif -#if !HAS_LCD_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) +#if !HAS_MARLINUI_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) #error "SD_REPRINT_LAST_SELECTED_FILE currently requires a Marlin-native LCD menu." #endif @@ -848,6 +864,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE) #error "SHOW_CUSTOM_BOOTSCREEN requires Graphical LCD or TOUCH_UI_FTDI_EVE." +#elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN) + #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN." #elif ENABLED(CUSTOM_STATUS_SCREEN_IMAGE) && !HAS_MARLINUI_U8GLIB #error "CUSTOM_STATUS_SCREEN_IMAGE requires a 128x64 DOGM B/W Graphical LCD." #endif @@ -862,7 +880,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * SD Card Settings */ -#if ALL(SDSUPPORT, ELB_FULL_GRAPHIC_CONTROLLER, HAS_LCD_MENU) && PIN_EXISTS(SD_DETECT) && SD_DETECT_STATE != HIGH && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)) +#if ALL(SDSUPPORT, ELB_FULL_GRAPHIC_CONTROLLER, HAS_MARLINUI_MENU) && PIN_EXISTS(SD_DETECT) && SD_DETECT_STATE != HIGH && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)) #error "SD_DETECT_STATE must be set HIGH for SD on the ELB_FULL_GRAPHIC_CONTROLLER." #endif @@ -914,7 +932,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(BABYSTEPPING) #if ENABLED(SCARA) #error "BABYSTEPPING is not implemented for SCARA yet." - #elif BOTH(MARKFORGED_XY, BABYSTEP_XY) + #elif ENABLED(BABYSTEP_XY) && EITHER(MARKFORGED_XY, MARKFORGED_YX) #error "BABYSTEPPING only implemented for Z axis on MarkForged." #elif BOTH(DELTA, BABYSTEP_XY) #error "BABYSTEPPING only implemented for Z axis on deltabots." @@ -1069,8 +1087,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "PRUSA_MMU2S requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." #elif ENABLED(MMU_EXTRUDER_SENSOR) && DISABLED(FILAMENT_RUNOUT_SENSOR) #error "MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." - #elif ENABLED(MMU_EXTRUDER_SENSOR) && !HAS_LCD_MENU - #error "MMU_EXTRUDER_SENSOR requires an LCD supporting MarlinUI to be enabled." + #elif ENABLED(MMU_EXTRUDER_SENSOR) && !HAS_MARLINUI_MENU + #error "MMU_EXTRUDER_SENSOR requires an LCD supporting MarlinUI." + #elif ENABLED(MMU2_MENUS) && !HAS_MARLINUI_MENU + #error "MMU2_MENUS requires an LCD supporting MarlinUI." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / HAS_EXTENDABLE_MMU(S)."); #endif @@ -1210,14 +1230,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "For MIXING_EXTRUDER set MIXING_STEPPERS > 1 instead of EXTRUDERS > 1." #elif MIXING_STEPPERS < 2 #error "You must set MIXING_STEPPERS >= 2 for a mixing extruder." - #elif ENABLED(FILAMENT_SENSOR) - #error "MIXING_EXTRUDER is incompatible with FILAMENT_SENSOR. Comment out this line to use it anyway." + #elif ENABLED(FILAMENT_WIDTH_SENSOR) + #error "MIXING_EXTRUDER is incompatible with FILAMENT_WIDTH_SENSOR. Comment out this line to use it anyway." #elif ENABLED(SWITCHING_EXTRUDER) #error "Please select either MIXING_EXTRUDER or SWITCHING_EXTRUDER, not both." #elif ENABLED(SINGLENOZZLE) #error "MIXING_EXTRUDER is incompatible with SINGLENOZZLE." #elif ENABLED(DISABLE_INACTIVE_EXTRUDER) #error "MIXING_EXTRUDER is incompatible with DISABLE_INACTIVE_EXTRUDER." + #elif HAS_FILAMENT_RUNOUT_DISTANCE + #error "MIXING_EXTRUDER is incompatible with FILAMENT_RUNOUT_DISTANCE_MM." #endif #endif @@ -1414,10 +1436,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Allow only extra axis codes that do not conflict with G-code parameter names */ -#if LINEAR_AXES >= 4 - #if AXIS4_NAME != 'A' && AXIS4_NAME != 'B' && AXIS4_NAME != 'C' && AXIS4_NAME != 'U' && AXIS4_NAME != 'V' && AXIS4_NAME != 'W' - #error "AXIS4_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." - #elif !defined(I_MIN_POS) || !defined(I_MAX_POS) +#if HAS_I_AXIS + #if !defined(I_MIN_POS) || !defined(I_MAX_POS) #error "I_MIN_POS and I_MAX_POS are required with LINEAR_AXES >= 4." #elif !defined(I_HOME_DIR) #error "I_HOME_DIR is required with LINEAR_AXES >= 4." @@ -1425,11 +1445,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "I_ENABLE_ON is required for your I driver with LINEAR_AXES >= 4." #endif #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #if AXIS5_NAME == AXIS4_NAME #error "AXIS5_NAME must be unique." - #elif AXIS5_NAME != 'A' && AXIS5_NAME != 'B' && AXIS5_NAME != 'C' && AXIS5_NAME != 'U' && AXIS5_NAME != 'V' && AXIS5_NAME != 'W' - #error "AXIS5_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." #elif !defined(J_MIN_POS) || !defined(J_MAX_POS) #error "J_MIN_POS and J_MAX_POS are required with LINEAR_AXES >= 5." #elif !defined(J_HOME_DIR) @@ -1438,11 +1456,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "J_ENABLE_ON is required for your J driver with LINEAR_AXES >= 5." #endif #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #if AXIS6_NAME == AXIS5_NAME || AXIS6_NAME == AXIS4_NAME #error "AXIS6_NAME must be unique." - #elif AXIS6_NAME != 'A' && AXIS6_NAME != 'B' && AXIS6_NAME != 'C' && AXIS6_NAME != 'U' && AXIS6_NAME != 'V' && AXIS6_NAME != 'W' - #error "AXIS6_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." #elif !defined(K_MIN_POS) || !defined(K_MAX_POS) #error "K_MIN_POS and K_MAX_POS are required with LINEAR_AXES >= 6." #elif !defined(K_HOME_DIR) @@ -1459,8 +1475,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Allow only one kinematic type to be defined */ -#if MANY(DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, FOAMCUTTER_XYUV) - #error "Please enable only one of DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, or FOAMCUTTER_XYUV." +#if MANY(DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, MARKFORGED_YX, FOAMCUTTER_XYUV) + #error "Please enable only one of DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, MARKFORGED_YX, or FOAMCUTTER_XYUV." #endif /** @@ -1471,9 +1487,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You probably want to use Max Endstops for DELTA!" #elif ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(AUTO_BED_LEVELING_BILINEAR) && !UBL_SEGMENTED #error "ENABLE_LEVELING_FADE_HEIGHT on DELTA requires AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL." - #elif ENABLED(DELTA_AUTO_CALIBRATION) && !(HAS_BED_PROBE || HAS_LCD_MENU) + #elif ENABLED(DELTA_AUTO_CALIBRATION) && !(HAS_BED_PROBE || HAS_MARLINUI_MENU) #error "DELTA_AUTO_CALIBRATION requires a probe or LCD Controller." - #elif ENABLED(DELTA_CALIBRATION_MENU) && !HAS_LCD_MENU + #elif ENABLED(DELTA_CALIBRATION_MENU) && !HAS_MARLINUI_MENU #error "DELTA_CALIBRATION_MENU requires an LCD Controller." #elif ABL_USES_GRID #if ((GRID_MAX_POINTS_X) & 1) == 0 || ((GRID_MAX_POINTS_Y) & 1) == 0 @@ -1507,8 +1523,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if 1 < 0 \ + (DISABLED(BLTOUCH) && HAS_Z_SERVO_PROBE) \ - + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING) - #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or Z Servo." + + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4) + #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, or Z Servo." #endif #if HAS_BED_PROBE @@ -1562,10 +1578,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #else #define _IS_5V_TOLERANT(P) 1 // Assume 5V tolerance #endif - #if USES_Z_MIN_PROBE_PIN && !_IS_5V_TOLERANT(Z_MIN_PROBE_PIN) - #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PROBE_PIN." + #if USES_Z_MIN_PROBE_PIN + #if !_IS_5V_TOLERANT(Z_MIN_PROBE_PIN) + #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PROBE_PIN." + #endif #elif !_IS_5V_TOLERANT(Z_MIN_PIN) - #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PIN." + #if !MB(CHITU3D_V6) + #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PIN." + #endif #endif #undef _IS_5V_TOLERANT #undef _5V @@ -1577,6 +1597,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif + #if ENABLED(BLTOUCH_HS_MODE) && BLTOUCH_HS_MODE == 0 + #error "BLTOUCH_HS_MODE must now be defined as true or false, indicating the default state." + #endif #if BLTOUCH_DELAY < 200 #error "BLTOUCH_DELAY less than 200 is unsafe and is not supported." #endif @@ -1607,6 +1630,19 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif + /** + * MagLev V4 probe requirements + */ + #if ENABLED(MAGLEV4) + #if !PIN_EXISTS(MAGLEV_TRIGGER) + #error "MAGLEV4 requires MAGLEV_TRIGGER_PIN to be defined." + #elif DISABLED(Z_SAFE_HOMING) + #error "MAGLEV4 requires Z_SAFE_HOMING." + #elif MAGLEV_TRIGGER_DELAY != 15 + #error "MAGLEV_TRIGGER_DELAY should not be changed. Comment out this line to continue." + #endif + #endif + /** * Require pin options and pins to be defined */ @@ -1635,7 +1671,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(NOZZLE_AS_PROBE) static_assert(sanity_nozzle_to_probe_offset.x == 0 && sanity_nozzle_to_probe_offset.y == 0, "NOZZLE_AS_PROBE requires the XY offsets in NOZZLE_TO_PROBE_OFFSET to both be 0."); - #else + #elif !IS_KINEMATIC static_assert(PROBING_MARGIN >= 0, "PROBING_MARGIN must be >= 0."); static_assert(PROBING_MARGIN_BACK >= 0, "PROBING_MARGIN_BACK must be >= 0."); static_assert(PROBING_MARGIN_FRONT >= 0, "PROBING_MARGIN_FRONT must be >= 0."); @@ -1694,11 +1730,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Require some kind of probe for bed leveling and probe testing */ #if HAS_ABL_NOT_UBL && !PROBE_SELECTED - #error "Auto Bed Leveling requires one of these: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or a Z Servo." + #error "Auto Bed Leveling requires either PROBE_MANUALLY, SENSORLESS_PROBING, or a real probe." #endif #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) - #error "Z_MIN_PROBE_REPEATABILITY_TEST requires a probe: FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, BLTOUCH, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or Z Servo." + #error "Z_MIN_PROBE_REPEATABILITY_TEST requires a real probe." #endif #endif @@ -1796,7 +1832,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * LCD_BED_LEVELING requirements */ #if ENABLED(LCD_BED_LEVELING) - #if NONE(HAS_LCD_MENU, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if NONE(HAS_MARLINUI_MENU, DWIN_CREALITY_LCD, DWIN_LCD_PROUI) #error "LCD_BED_LEVELING is not supported by the selected LCD controller." #elif !(ENABLED(MESH_BED_LEVELING) || HAS_ABL_NOT_UBL) #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or AUTO_BED_LEVELING." @@ -1958,8 +1994,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(DUAL_X_CARRIAGE) #if EXTRUDERS < 2 #error "DUAL_X_CARRIAGE requires 2 (or more) extruders." - #elif ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) - #error "DUAL_X_CARRIAGE cannot be used with COREXY, COREYX, COREXZ, COREZX, or MARKFORGED_XY." + #elif ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX) + #error "DUAL_X_CARRIAGE cannot be used with COREXY, COREYX, COREXZ, COREZX, MARKFORGED_YX, or MARKFORGED_XY." #elif !GOOD_AXIS_PINS(X2) #error "DUAL_X_CARRIAGE requires X2 stepper pins to be defined." #elif !HAS_X_MAX @@ -1990,8 +2026,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if HAS_FAN0 && CONTROLLER_FAN_PIN == FAN_PIN - #error "You cannot set CONTROLLER_FAN_PIN equal to FAN_PIN." +#if HAS_FAN0 + #if CONTROLLER_FAN_PIN == FAN_PIN + #error "You cannot set CONTROLLER_FAN_PIN equal to FAN_PIN." + #elif ENABLED(FAN_SOFT_PWM_REQUIRED) && DISABLED(FAN_SOFT_PWM) + #error "FAN_SOFT_PWM is required for your board. Enable it to continue." + #endif #endif #if ENABLED(USE_CONTROLLER_FAN) @@ -2143,9 +2183,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Test Sensor & Heater pin combos. * Pins and Sensor IDs must be set for each heater */ -#if !ANY_PIN(TEMP_0, TEMP_0_CS) +#if HAS_EXTRUDERS && !ANY_PIN(TEMP_0, TEMP_0_CS) #error "TEMP_0_PIN or TEMP_0_CS_PIN not defined for this board." -#elif !HAS_HEATER_0 && EXTRUDERS +#elif HAS_EXTRUDERS && !HAS_HEATER_0 #error "HEATER_0_PIN not defined for this board." #elif TEMP_SENSOR_0_IS_MAX_TC && !PIN_EXISTS(TEMP_0_CS) #error "TEMP_SENSOR_0 MAX thermocouple requires TEMP_0_CS_PIN." @@ -2266,12 +2306,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "CONTROLLER_FAN_MIN_BOARD_TEMP requires TEMP_SENSOR_BOARD." #endif +#if TEMP_SENSOR_BOARD && !PIN_EXISTS(TEMP_BOARD) + #error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN." +#endif + #if ENABLED(LASER_COOLANT_FLOW_METER) && !(PIN_EXISTS(FLOWMETER) && ENABLED(LASER_FEATURE)) #error "LASER_COOLANT_FLOW_METER requires FLOWMETER_PIN and LASER_FEATURE." #endif -#if ENABLED(CHAMBER_FAN) && !(defined(CHAMBER_FAN_MODE) && WITHIN(CHAMBER_FAN_MODE, 0, 2)) - #error "CHAMBER_FAN_MODE must be between 0 and 2." +#if ENABLED(CHAMBER_FAN) && !(defined(CHAMBER_FAN_MODE) && WITHIN(CHAMBER_FAN_MODE, 0, 3)) + #error "CHAMBER_FAN_MODE must be between 0 and 3." #endif #if ENABLED(CHAMBER_VENT) @@ -2302,17 +2346,31 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif /** - * LED Control Menu + * FYSETC LCD Requirements */ -#if ENABLED(LED_CONTROL_MENU) && !HAS_COLOR_LEDS - #error "LED_CONTROL_MENU requires BLINKM, RGB_LED, RGBW_LED, PCA9533, PCA9632, or NEOPIXEL_LED." +#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864_2_1) + #ifndef NEO_RGB + #define NEO_RGB 123 + #define FAUX_RGB 1 + #endif + #if defined(NEOPIXEL_TYPE) && NEOPIXEL_TYPE != NEO_RGB + #error "Your FYSETC Mini Panel requires NEOPIXEL_TYPE to be NEO_RGB." + #elif defined(NEOPIXEL_PIXELS) && NEOPIXEL_PIXELS < 3 + #error "Your FYSETC Mini Panel requires NEOPIXEL_PIXELS >= 3." + #endif + #if FAUX_RGB + #undef NEO_RGB + #undef FAUX_RGB + #endif +#elif EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && !DISABLED(RGB_LED) + #error "Your FYSETC Mini Panel requires RGB_LED." #endif /** - * LED Backlight Timeout + * LED Control Menu requirements */ -#if defined(LED_BACKLIGHT_TIMEOUT) && !(ENABLED(PSU_CONTROL) && ANY(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_242_OLED_12864)) - #error "LED_BACKLIGHT_TIMEOUT requires a FYSETC Mini Panel and a Power Switch." +#if ENABLED(LED_CONTROL_MENU) && !HAS_COLOR_LEDS + #error "LED_CONTROL_MENU requires BLINKM, RGB_LED, RGBW_LED, PCA9533, PCA9632, or NEOPIXEL_LED." #endif /** @@ -2390,13 +2448,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if _AXIS_PLUG_UNUSED_TEST(Z) #error "You must enable USE_ZMIN_PLUG or USE_ZMAX_PLUG." #endif - #if LINEAR_AXES >= 4 && _AXIS_PLUG_UNUSED_TEST(I) + #if HAS_I_AXIS && _AXIS_PLUG_UNUSED_TEST(I) #error "You must enable USE_IMIN_PLUG or USE_IMAX_PLUG." #endif - #if LINEAR_AXES >= 5 && _AXIS_PLUG_UNUSED_TEST(J) + #if HAS_J_AXIS && _AXIS_PLUG_UNUSED_TEST(J) #error "You must enable USE_JMIN_PLUG or USE_JMAX_PLUG." #endif - #if LINEAR_AXES >= 6 && _AXIS_PLUG_UNUSED_TEST(K) + #if HAS_K_AXIS && _AXIS_PLUG_UNUSED_TEST(K) #error "You must enable USE_KMIN_PLUG or USE_KMAX_PLUG." #endif @@ -2410,17 +2468,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Enable USE_YMIN_PLUG when homing Y to MIN." #elif Y_HOME_TO_MAX && DISABLED(USE_YMAX_PLUG) #error "Enable USE_YMAX_PLUG when homing Y to MAX." - #elif LINEAR_AXES >= 4 && I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) + #elif HAS_I_AXIS && I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) #error "Enable USE_IMIN_PLUG when homing I to MIN." - #elif LINEAR_AXES >= 4 && I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) + #elif HAS_I_AXIS && I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) #error "Enable USE_IMAX_PLUG when homing I to MAX." - #elif LINEAR_AXES >= 5 && J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) + #elif HAS_J_AXIS && J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) #error "Enable USE_JMIN_PLUG when homing J to MIN." - #elif LINEAR_AXES >= 5 && J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) + #elif HAS_J_AXIS && J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) #error "Enable USE_JMAX_PLUG when homing J to MAX." - #elif LINEAR_AXES >= 6 && K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) + #elif HAS_K_AXIS && K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) #error "Enable USE_KMIN_PLUG when homing K to MIN." - #elif LINEAR_AXES >= 6 && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) + #elif HAS_K_AXIS && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) #error "Enable USE_KMAX_PLUG when homing K to MAX." #endif #endif @@ -2583,6 +2641,31 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif +/** + * Fan check + */ +#if HAS_FANCHECK + #if BOTH(E0_FAN_TACHO_PULLUP, E0_FAN_TACHO_PULLDOWN) + #error "Enable only one of E0_FAN_TACHO_PULLUP or E0_FAN_TACHO_PULLDOWN." + #elif BOTH(E1_FAN_TACHO_PULLUP, E1_FAN_TACHO_PULLDOWN) + #error "Enable only one of E1_FAN_TACHO_PULLUP or E1_FAN_TACHO_PULLDOWN." + #elif BOTH(E2_FAN_TACHO_PULLUP, E2_FAN_TACHO_PULLDOWN) + #error "Enable only one of E2_FAN_TACHO_PULLUP or E2_FAN_TACHO_PULLDOWN." + #elif BOTH(E3_FAN_TACHO_PULLUP, E3_FAN_TACHO_PULLDOWN) + #error "Enable only one of E3_FAN_TACHO_PULLUP or E3_FAN_TACHO_PULLDOWN." + #elif BOTH(E4_FAN_TACHO_PULLUP, E4_FAN_TACHO_PULLDOWN) + #error "Enable only one of E4_FAN_TACHO_PULLUP or E4_FAN_TACHO_PULLDOWN." + #elif BOTH(E5_FAN_TACHO_PULLUP, E5_FAN_TACHO_PULLDOWN) + #error "Enable only one of E5_FAN_TACHO_PULLUP or E5_FAN_TACHO_PULLDOWN." + #elif BOTH(E6_FAN_TACHO_PULLUP, E6_FAN_TACHO_PULLDOWN) + #error "Enable only one of E6_FAN_TACHO_PULLUP or E6_FAN_TACHO_PULLDOWN." + #elif BOTH(E7_FAN_TACHO_PULLUP, E7_FAN_TACHO_PULLDOWN) + #error "Enable only one of E7_FAN_TACHO_PULLUP or E7_FAN_TACHO_PULLDOWN." + #endif +#elif ENABLED(AUTO_REPORT_FANS) + #error "AUTO_REPORT_FANS requires one or more fans with a tachometer pin." +#endif + /** * Make sure only one EEPROM type is enabled */ @@ -2630,14 +2713,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS + (ENABLED(U8GLIB_SSD1306) && DISABLED(IS_U8GLIB_SSD1306)) \ + (ENABLED(MINIPANEL) && NONE(MKS_MINI_12864, ENDER2_STOCKDISPLAY)) \ + (ENABLED(MKS_MINI_12864) && NONE(MKS_LCD12864A, MKS_LCD12864B)) \ + + (ENABLED(FYSETC_MINI_12864_2_1) && NONE(MKS_MINI_12864_V3, BTT_MINI_12864_V1)) \ + + COUNT_ENABLED(MKS_MINI_12864_V3, BTT_MINI_12864_V1) \ + (ENABLED(EXTENSIBLE_UI) && DISABLED(IS_EXTUI)) \ + (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \ + (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \ + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \ + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) \ + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \ - + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \ - + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \ + + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \ + + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_GENERIC_12864_1_1) \ + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \ + COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \ + COUNT_ENABLED(MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, ANET_ET4_TFT28, ANET_ET5_TFT35, BIQU_BX_TFT70, BTT_TFT35_SPI_V1_0) \ @@ -2709,8 +2794,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Please enable only one of TFT_INTERFACE_SPI or TFT_INTERFACE_SPI." #endif -#if MANY(LCD_SCREEN_ROT_0, LCD_SCREEN_ROT_90, LCD_SCREEN_ROT_180, LCD_SCREEN_ROT_270) - #error "Please enable only one LCD_SCREEN_ROT_* option: 0, 90, 180, or 270." +#if defined(LCD_SCREEN_ROTATE) && LCD_SCREEN_ROTATE != 0 && LCD_SCREEN_ROTATE != 90 && LCD_SCREEN_ROTATE != 180 && LCD_SCREEN_ROTATE != 270 + #error "LCD_SCREEN_ROTATE must be 0, 90, 180, or 270." #endif #if MANY(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320, TFT_RES_1024x600) @@ -2733,6 +2818,20 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Please select only one of CHIRON_TFT_STANDARD or CHIRON_TFT_NEW." #endif +#if ENABLED(ANYCUBIC_LCD_CHIRON) + #if !defined(BEEPER_PIN) + #error "ANYCUBIC_LCD_CHIRON requires BEEPER_PIN" + #elif DISABLED(SDSUPPORT) + #error "ANYCUBIC_LCD_CHIRON requires SDSUPPORT" + #elif TEMP_SENSOR_BED == 0 + #error "ANYCUBIC_LCD_CHIRON requires heatbed (TEMP_SENSOR_BED)" + #elif NONE(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING) + #error "ANYCUBIC_LCD_CHIRON requires one of: AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL or MESH_BED_LEVELING" + #elif DISABLED(BABYSTEPPING) + #error "ANYCUBIC_LCD_CHIRON requires BABYSTEPPING" + #endif +#endif + #if EITHER(MKS_TS35_V2_0, BTT_TFT35_SPI_V1_0) && SD_CONNECTION_IS(LCD) #error "SDCARD_CONNECTION cannot be set to LCD for the enabled TFT. No available SD card reader." #endif @@ -2752,17 +2851,25 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY) #error "DWIN_CREALITY_LCD does not support LCD_BED_LEVELING with PROBE_MANUALLY." #endif -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #if DISABLED(SDSUPPORT) - #error "DWIN_CREALITY_LCD_ENHANCED requires SDSUPPORT to be enabled." + #error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled." #elif ENABLED(PID_EDIT_MENU) - #error "DWIN_CREALITY_LCD_ENHANCED does not support PID_EDIT_MENU." + #error "DWIN_LCD_PROUI does not support PID_EDIT_MENU." #elif ENABLED(PID_AUTOTUNE_MENU) - #error "DWIN_CREALITY_LCD_ENHANCED does not support PID_AUTOTUNE_MENU." + #error "DWIN_LCD_PROUI does not support PID_AUTOTUNE_MENU." #elif ENABLED(LEVEL_BED_CORNERS) - #error "DWIN_CREALITY_LCD_ENHANCED does not support LEVEL_BED_CORNERS." + #error "DWIN_LCD_PROUI does not support LEVEL_BED_CORNERS." #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY) - #error "DWIN_CREALITY_LCD_ENHANCED does not support LCD_BED_LEVELING with PROBE_MANUALLY." + #error "DWIN_LCD_PROUI does not support LCD_BED_LEVELING with PROBE_MANUALLY." + #endif +#endif + +#if LCD_BACKLIGHT_TIMEOUT + #if !HAS_ENCODER_ACTION + #error "LCD_BACKLIGHT_TIMEOUT requires an LCD with encoder or keypad." + #elif !PIN_EXISTS(LCD_BACKLIGHT) + #error "LCD_BACKLIGHT_TIMEOUT requires LCD_BACKLIGHT_PIN." #endif #endif @@ -2814,15 +2921,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -/** - * FYSETC Mini 12864 RGB backlighting required - */ -#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && DISABLED(RGB_LED) - #error "RGB_LED is required for FYSETC_MINI_12864 1.2 and 2.0." -#elif EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) && DISABLED(LED_USER_PRESET_STARTUP) - #error "LED_USER_PRESET_STARTUP is required for FYSETC_MINI_12864 2.x displays." -#endif - /** * Check existing CS pins against enabled TMC SPI drivers. */ @@ -2904,11 +3002,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TMC2208 or TMC2209 on E6 requires E6_HARDWARE_SERIAL or E6_SERIAL_(RX|TX)_PIN." #elif INVALID_TMC_UART(E7) #error "TMC2208 or TMC2209 on E7 requires E7_HARDWARE_SERIAL or E7_SERIAL_(RX|TX)_PIN." -#elif LINEAR_AXES >= 4 && INVALID_TMC_UART(I) +#elif HAS_I_AXIS && INVALID_TMC_UART(I) #error "TMC2208 or TMC2209 on I requires I_HARDWARE_SERIAL or I_SERIAL_(RX|TX)_PIN." -#elif LINEAR_AXES >= 5 && INVALID_TMC_UART(J) +#elif HAS_J_AXIS && INVALID_TMC_UART(J) #error "TMC2208 or TMC2209 on J requires J_HARDWARE_SERIAL or J_SERIAL_(RX|TX)_PIN." -#elif LINEAR_AXES >= 6 && INVALID_TMC_UART(K) +#elif HAS_K_AXIS && INVALID_TMC_UART(K) #error "TMC2208 or TMC2209 on K requires K_HARDWARE_SERIAL or K_SERIAL_(RX|TX)_PIN." #endif #undef INVALID_TMC_UART @@ -2994,11 +3092,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS INVALID_TMC_MS(E6) #elif !TMC_MICROSTEP_IS_VALID(E7) INVALID_TMC_MS(E7) -#elif LINEAR_AXES >= 4 && !TMC_MICROSTEP_IS_VALID(I) +#elif HAS_I_AXIS && !TMC_MICROSTEP_IS_VALID(I) INVALID_TMC_MS(I) -#elif LINEAR_AXES >= 5 && !TMC_MICROSTEP_IS_VALID(J) +#elif HAS_J_AXIS && !TMC_MICROSTEP_IS_VALID(J) INVALID_TMC_MS(J) -#elif LINEAR_AXES >= 6 && !TMC_MICROSTEP_IS_VALID(K) +#elif HAS_K_AXIS && !TMC_MICROSTEP_IS_VALID(K) INVALID_TMC_MS(K) #endif #undef INVALID_TMC_MS @@ -3020,13 +3118,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #define X_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(X,TMC2209) #define Y_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Y,TMC2209) #define Z_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Z,TMC2209) - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS #define I_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(I,TMC2209) #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS #define J_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(J,TMC2209) #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS #define K_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(K,TMC2209) #endif @@ -3043,17 +3141,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMIN (or ENDSTOPPULLUPS) when homing to Z_MIN." #elif Z_SENSORLESS && Z_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_ZMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMAX (or ENDSTOPPULLUPS) when homing to Z_MAX." - #elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_IMIN) + #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_IMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMIN (or ENDSTOPPULLUPS) when homing to I_MIN." - #elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_IMAX) + #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_IMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMAX (or ENDSTOPPULLUPS) when homing to I_MAX." - #elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_JMIN) + #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_JMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMIN (or ENDSTOPPULLUPS) when homing to J_MIN." - #elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_JMAX) + #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_JMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMAX (or ENDSTOPPULLUPS) when homing to J_MAX." - #elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_KMIN) + #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_KMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMIN (or ENDSTOPPULLUPS) when homing to K_MIN." - #elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_KMAX) + #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_KMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMAX (or ENDSTOPPULLUPS) when homing to K_MAX." #endif #endif @@ -3099,37 +3197,37 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #else #error "SENSORLESS_HOMING requires Z_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to Z_MAX." #endif - #elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MIN && I_MIN_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING + #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MIN) && I_MIN_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING #if I_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires I_MIN_ENDSTOP_INVERTING = true when homing to I_MIN." #else #error "SENSORLESS_HOMING requires I_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to I_MIN." #endif - #elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MAX && I_MAX_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING + #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MAX) && I_MAX_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING #if I_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires I_MAX_ENDSTOP_INVERTING = true when homing to I_MAX." #else #error "SENSORLESS_HOMING requires I_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to I_MAX." #endif - #elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MIN && J_MIN_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING + #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MIN) && J_MIN_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING #if J_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires J_MIN_ENDSTOP_INVERTING = true when homing to J_MIN." #else #error "SENSORLESS_HOMING requires J_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to J_MIN." #endif - #elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MAX && J_MAX_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING + #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MAX) && J_MAX_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING #if J_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires J_MAX_ENDSTOP_INVERTING = true when homing to J_MAX." #else #error "SENSORLESS_HOMING requires J_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to J_MAX." #endif - #elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MIN && K_MIN_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING + #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MIN) && K_MIN_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING #if K_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires K_MIN_ENDSTOP_INVERTING = true when homing to K_MIN." #else #error "SENSORLESS_HOMING requires K_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to K_MIN." #endif - #elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MAX && K_MAX_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING + #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MAX) && K_MAX_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING #if K_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires K_MAX_ENDSTOP_INVERTING = true when homing to K_MAX." #else @@ -3174,8 +3272,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "CoreXZ requires both X and Z to use sensorless homing if either one does." #elif CORE_IS_YZ && Y_SENSORLESS != Z_SENSORLESS && !HOMING_Z_WITH_PROBE #error "CoreYZ requires both Y and Z to use sensorless homing if either one does." -#elif ENABLED(MARKFORGED_XY) && X_SENSORLESS != Y_SENSORLESS - #error "MARKFORGED_XY requires both X and Y to use sensorless homing if either one does." +#elif EITHER(MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS != Y_SENSORLESS + #error "MARKFORGED requires both X and Y to use sensorless homing if either one does." #endif // Other TMC feature requirements @@ -3253,8 +3351,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * L64XX requirement */ -#if HAS_L64XX && LINEAR_AXES >= 4 - #error "L64XX requires LINEAR_AXES 3. Homing with L64XX is not yet implemented for LINEAR_AXES > 3." +#if HAS_L64XX && HAS_I_AXIS + #error "L64XX requires LINEAR_AXES <= 3. Homing with L64XX is not yet implemented for LINEAR_AXES > 3." #endif /** @@ -3342,8 +3440,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel." #endif -#if ENABLED(LED_CONTROL_MENU) && !IS_ULTIPANEL - #error "LED_CONTROL_MENU requires an LCD controller." +#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) + #error "LED_CONTROL_MENU requires an LCD controller that implements the menu." #endif #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) && DISABLED(NEOPIXEL_LED) @@ -3364,11 +3462,13 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #endif #endif +#if BOTH(X_AXIS_TWIST_COMPENSATION, NOZZLE_AS_PROBE) + #error "X_AXIS_TWIST_COMPENSATION is incompatible with NOZZLE_AS_PROBE." +#endif + #if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(BACKUP_POWER_SUPPLY) && !PIN_EXISTS(POWER_LOSS) #error "BACKUP_POWER_SUPPLY requires a POWER_LOSS_PIN." - #elif BOTH(POWER_LOSS_RECOVER_ZHOME, Z_SAFE_HOMING) - #error "POWER_LOSS_RECOVER_ZHOME cannot be used with Z_SAFE_HOMING." #elif BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN) #error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time." #elif ENABLED(POWER_LOSS_RECOVER_ZHOME) && Z_HOME_TO_MAX @@ -3383,17 +3483,17 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "Z_STEPPER_AUTO_ALIGN requires NUM_Z_STEPPER_DRIVERS greater than 1." #elif !HAS_BED_PROBE #error "Z_STEPPER_AUTO_ALIGN requires a Z-bed probe." - #elif ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #elif HAS_Z_STEPPER_ALIGN_STEPPER_XY static_assert(WITHIN(Z_STEPPER_ALIGN_AMP, 0.5, 2.0), "Z_STEPPER_ALIGN_AMP must be between 0.5 and 2.0."); #if NUM_Z_STEPPER_DRIVERS < 3 - #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS requires NUM_Z_STEPPER_DRIVERS to be 3 or 4." + #error "Z_STEPPER_ALIGN_STEPPER_XY requires NUM_Z_STEPPER_DRIVERS to be 3 or 4." #endif #endif #endif #if ENABLED(MECHANICAL_GANTRY_CALIBRATION) #if NONE(HAS_MOTOR_CURRENT_DAC, HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC, HAS_TRINAMIC_CONFIG, HAS_MOTOR_CURRENT_PWM) - #error "It is highly recommended to have adjustable current drivers to prevent damage. Disable this line to continue anyway." + #error "Adjustable current drivers are highly recommended to prevent damage. Comment out this line to continue anyway." #elif !defined(GANTRY_CALIBRATION_CURRENT) #error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_CURRENT to be set." #elif !defined(GANTRY_CALIBRATION_EXTRA_HEIGHT) @@ -3435,7 +3535,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "BACKLASH_COMPENSATION requires BACKLASH_DISTANCE_MM." #elif !defined(BACKLASH_CORRECTION) #error "BACKLASH_COMPENSATION requires BACKLASH_CORRECTION." - #elif ENABLED(MARKFORGED_XY) + #elif EITHER(MARKFORGED_XY, MARKFORGED_YX) constexpr float backlash_arr[] = BACKLASH_DISTANCE_MM; static_assert(!backlash_arr[CORE_AXIS_1] && !backlash_arr[CORE_AXIS_2], "BACKLASH_COMPENSATION can only apply to " STRINGIFY(NORMAL_AXIS) " on a MarkForged system."); @@ -3510,6 +3610,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "PSU_CONTROL requires PS_ON_PIN." #elif POWER_OFF_DELAY < 0 #error "POWER_OFF_DELAY must be a positive value." + #elif ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) && !(defined(AUTO_POWER_E_TEMP) || defined(AUTO_POWER_CHAMBER_TEMP) || defined(AUTO_POWER_COOLER_TEMP)) + #error "POWER_OFF_WAIT_FOR_COOLDOWN requires AUTO_POWER_E_TEMP, AUTO_POWER_CHAMBER_TEMP, and/or AUTO_POWER_COOLER_TEMP." #endif #endif @@ -3628,7 +3730,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "COOLANT_FLOOD requires COOLANT_FLOOD_PIN to be defined." #endif -#if NONE(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) +#if NONE(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, IS_DWIN_MARLINUI) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) #error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD." #endif @@ -3652,8 +3754,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); /** * Touch Screen Calibration */ -#if ENABLED(TFT_TOUCH_DEVICE_XPT2046) && DISABLED(TOUCH_SCREEN_CALIBRATION) \ - && (!defined(TOUCH_CALIBRATION_X) || !defined(TOUCH_CALIBRATION_Y) || !defined(TOUCH_OFFSET_X) || !defined(TOUCH_OFFSET_Y)) +#if !MB(LINUX_RAMPS) && ENABLED(TFT_TOUCH_DEVICE_XPT2046) && DISABLED(TOUCH_SCREEN_CALIBRATION) \ + && !(defined(TOUCH_CALIBRATION_X) && defined(TOUCH_CALIBRATION_Y) && defined(TOUCH_OFFSET_X) && defined(TOUCH_OFFSET_Y)) #error "TOUCH_CALIBRATION_[XY] and TOUCH_OFFSET_[XY] are required for resistive touch screens with TOUCH_SCREEN_CALIBRATION disabled." #endif @@ -3668,7 +3770,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); * Sanity Check for Password Feature */ #if ENABLED(PASSWORD_FEATURE) - #if NONE(HAS_LCD_MENU, PASSWORD_UNLOCK_GCODE, PASSWORD_CHANGE_GCODE) + #if NONE(HAS_MARLINUI_MENU, PASSWORD_UNLOCK_GCODE, PASSWORD_CHANGE_GCODE) #error "Without PASSWORD_UNLOCK_GCODE, PASSWORD_CHANGE_GCODE, or a supported LCD there's no way to unlock the printer or set a password." #elif DISABLED(EEPROM_SETTINGS) #warning "PASSWORD_FEATURE settings will be lost on power-off without EEPROM_SETTINGS." @@ -3724,22 +3826,15 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #if _BAD_DRIVER(Z) #error "Z_DRIVER_TYPE is not recognized." #endif -#if LINEAR_AXES >= 4 - #if _BAD_DRIVER(I) - #error "I_DRIVER_TYPE is not recognized." - #endif +#if _BAD_DRIVER(I) + #error "I_DRIVER_TYPE is not recognized." #endif -#if LINEAR_AXES >= 5 - #if _BAD_DRIVER(J) - #error "J_DRIVER_TYPE is not recognized." - #endif +#if _BAD_DRIVER(J) + #error "J_DRIVER_TYPE is not recognized." #endif -#if LINEAR_AXES >= 6 - #if _BAD_DRIVER(K) - #error "K_DRIVER_TYPE is not recognized." - #endif +#if _BAD_DRIVER(K) + #error "K_DRIVER_TYPE is not recognized." #endif - #if _BAD_DRIVER(X2) #error "X2_DRIVER_TYPE is not recognized." #endif @@ -3814,3 +3909,10 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #undef _TEST_PWM #undef _LINEAR_AXES_STR #undef _LOGICAL_AXES_STR + +// JTAG support in the HAL +#if ENABLED(DISABLE_DEBUG) && !defined(JTAGSWD_DISABLE) + #error "DISABLE_DEBUG is not supported for the selected MCU/Board." +#elif ENABLED(DISABLE_JTAG) && !defined(JTAG_DISABLE) + #error "DISABLE_JTAG is not supported for the selected MCU/Board." +#endif diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index badb7231e0bd..31f031561a6f 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-11-12" + #define STRING_DISTRIBUTION_DATE "2022-03-21" #endif /** diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 1976c0958160..9d7b14d763ac 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -59,470 +59,484 @@ #warning "Your Configuration provides no method to acquire user feedback!" #endif -#if AUTO_ASSIGNED_X2_STEPPER - #warning "Auto-assigned X2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." +#if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_BOARD + #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." +#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_BOARD + #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." #endif -#if AUTO_ASSIGNED_X2_MS1 - #warning "Auto-assigned X2_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_X2_MS2 - #warning "Auto-assigned X2_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_X2_MS3 - #warning "Auto-assigned X2_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_X2_CS - #warning "Auto-assigned X2_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_X2_DIAG - #if X2_USE_ENDSTOP == _XMIN_ - #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_ - #warning "Auto-assigned X2_DIAG_PIN to Y_DIAG_PIN." - #elif X2_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned X2_DIAG_PIN to Z_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E0_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E1_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E2_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E3_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E4_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E5_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E6_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E7_DIAG_PIN." + +#ifndef NO_AUTO_ASSIGN_WARNING + + #if AUTO_ASSIGNED_X2_STEPPER + #warning "Note: Auto-assigned X2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_Y2_STEPPER - #warning "Auto-assigned Y2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_Y2_MS1 - #warning "Auto-assigned Y2_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_Y2_MS2 - #warning "Auto-assigned Y2_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_Y2_MS3 - #warning "Auto-assigned Y2_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_Y2_CS - #warning "Auto-assigned Y2_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_Y2_DIAG - #if Y2_USE_ENDSTOP == _XMIN_ - #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_ - #warning "Auto-assigned Y2_DIAG_PIN to Y_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to Z_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E0_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E1_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E2_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E3_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E4_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E5_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E6_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_MS1 + #warning "Note: Auto-assigned X2_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_Z2_STEPPER - #warning "Auto-assigned Z2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_Z2_MS1 - #warning "Auto-assigned Z2_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_Z2_MS2 - #warning "Auto-assigned Z2_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_Z2_MS3 - #warning "Auto-assigned Z2_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_Z2_CS - #warning "Auto-assigned Z2_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_Z2_DIAG - #if Z2_USE_ENDSTOP == _XMIN_ - #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_ - #warning "Auto-assigned Z2_DIAG_PIN to Y_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to Z_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E0_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E1_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E2_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E3_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E4_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E5_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E6_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_MS2 + #warning "Note: Auto-assigned X2_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_Z3_STEPPER - #warning "Auto-assigned Z3 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_Z3_CS - #warning "Auto-assigned Z3_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_Z3_MS1 - #warning "Auto-assigned Z3_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_Z3_MS2 - #warning "Auto-assigned Z3_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_Z3_MS3 - #warning "Auto-assigned Z3_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_Z3_DIAG - #if Z3_USE_ENDSTOP == _XMIN_ - #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_ - #warning "Auto-assigned Z3_DIAG_PIN to Y_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to Z_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E0_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E1_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E2_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E3_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E4_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E5_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E6_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_MS3 + #warning "Note: Auto-assigned X2_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_Z4_STEPPER - #warning "Auto-assigned Z4 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_Z4_CS - #warning "Auto-assigned Z4_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_Z4_MS1 - #warning "Auto-assigned Z4_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_Z4_MS2 - #warning "Auto-assigned Z4_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_Z4_MS3 - #warning "Auto-assigned Z4_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_Z4_DIAG - #if Z4_USE_ENDSTOP == _XMIN_ - #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_ - #warning "Auto-assigned Z4_DIAG_PIN to Y_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to Z_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E0_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E1_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E2_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E3_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E4_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E5_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E6_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_CS + #warning "Note: Auto-assigned X2_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_I_STEPPER - #warning "Auto-assigned I STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_I_CS - #warning "Auto-assigned I_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_I_MS1 - #warning "Auto-assigned I_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_I_MS2 - #warning "Auto-assigned I_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_I_MS3 - #warning "Auto-assigned I_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_I_DIAG - #if I_USE_ENDSTOP == _XMIN_ - #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_ - #warning "Auto-assigned I_DIAG_PIN to Y_DIAG_PIN." - #elif I_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned I_DIAG_PIN to Z_DIAG_PIN." - #elif I_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E0_DIAG_PIN." - #elif I_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E1_DIAG_PIN." - #elif I_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E2_DIAG_PIN." - #elif I_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E3_DIAG_PIN." - #elif I_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E4_DIAG_PIN." - #elif I_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E5_DIAG_PIN." - #elif I_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E6_DIAG_PIN." - #elif I_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_DIAG + #if X2_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned X2_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned X2_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned X2_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif #endif -#endif -#if AUTO_ASSIGNED_J_STEPPER - #warning "Auto-assigned J STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_J_CS - #warning "Auto-assigned J_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_J_MS1 - #warning "Auto-assigned J_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_J_MS2 - #warning "Auto-assigned J_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_J_MS3 - #warning "Auto-assigned J_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_J_DIAG - #if J_USE_ENDSTOP == _XMIN_ - #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_ - #warning "Auto-assigned J_DIAG_PIN to Y_DIAG_PIN." - #elif J_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned J_DIAG_PIN to Z_DIAG_PIN." - #elif J_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E0_DIAG_PIN." - #elif J_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E1_DIAG_PIN." - #elif J_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E2_DIAG_PIN." - #elif J_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E3_DIAG_PIN." - #elif J_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E4_DIAG_PIN." - #elif J_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E5_DIAG_PIN." - #elif J_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E6_DIAG_PIN." - #elif J_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_Y2_STEPPER + #warning "Note: Auto-assigned Y2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_K_STEPPER - #warning "Auto-assigned K STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_K_CS - #warning "Auto-assigned K_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_K_MS1 - #warning "Auto-assigned K_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_K_MS2 - #warning "Auto-assigned K_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_K_MS3 - #warning "Auto-assigned K_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_K_DIAG - #if K_USE_ENDSTOP == _XMIN_ - #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_ - #warning "Auto-assigned K_DIAG_PIN to Y_DIAG_PIN." - #elif K_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned K_DIAG_PIN to Z_DIAG_PIN." - #elif K_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E0_DIAG_PIN." - #elif K_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E1_DIAG_PIN." - #elif K_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E2_DIAG_PIN." - #elif K_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E3_DIAG_PIN." - #elif K_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E4_DIAG_PIN." - #elif K_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E5_DIAG_PIN." - #elif K_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E6_DIAG_PIN." - #elif K_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_Y2_MS1 + #warning "Note: Auto-assigned Y2_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_MS2 + #warning "Note: Auto-assigned Y2_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_MS3 + #warning "Note: Auto-assigned Y2_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_CS + #warning "Note: Auto-assigned Y2_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_DIAG + #if Y2_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_Z2_STEPPER + #warning "Note: Auto-assigned Z2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_MS1 + #warning "Note: Auto-assigned Z2_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_MS2 + #warning "Note: Auto-assigned Z2_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_MS3 + #warning "Note: Auto-assigned Z2_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_CS + #warning "Note: Auto-assigned Z2_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_DIAG + #if Z2_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_Z3_STEPPER + #warning "Note: Auto-assigned Z3 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_CS + #warning "Note: Auto-assigned Z3_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_MS1 + #warning "Note: Auto-assigned Z3_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_MS2 + #warning "Note: Auto-assigned Z3_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_MS3 + #warning "Note: Auto-assigned Z3_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_DIAG + #if Z3_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_Z4_STEPPER + #warning "Note: Auto-assigned Z4 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_CS + #warning "Note: Auto-assigned Z4_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_MS1 + #warning "Note: Auto-assigned Z4_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_MS2 + #warning "Note: Auto-assigned Z4_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_MS3 + #warning "Note: Auto-assigned Z4_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_DIAG + #if Z4_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_I_STEPPER + #warning "Note: Auto-assigned I STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_CS + #warning "Note: Auto-assigned I_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_MS1 + #warning "Note: Auto-assigned I_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_MS2 + #warning "Note: Auto-assigned I_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_MS3 + #warning "Note: Auto-assigned I_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_DIAG + #if I_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned I_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned I_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned I_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned I_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned I_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned I_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned I_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned I_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned I_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_J_STEPPER + #warning "Note: Auto-assigned J STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_CS + #warning "Note: Auto-assigned J_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_MS1 + #warning "Note: Auto-assigned J_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_MS2 + #warning "Note: Auto-assigned J_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_MS3 + #warning "Note: Auto-assigned J_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_DIAG + #if J_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned J_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned J_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned J_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned J_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned J_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned J_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned J_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned J_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned J_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_K_STEPPER + #warning "Note: Auto-assigned K STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_CS + #warning "Note: Auto-assigned K_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_MS1 + #warning "Note: Auto-assigned K_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_MS2 + #warning "Note: Auto-assigned K_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_MS3 + #warning "Note: Auto-assigned K_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_DIAG + #if K_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned K_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned K_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned K_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned K_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned K_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned K_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned K_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned K_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned K_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + + #if ENABLED(CHAMBER_FAN) && !defined(CHAMBER_FAN_INDEX) + #warning "Note: Auto-assigned CHAMBER_FAN_INDEX to the first free FAN pin. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif + +#endif // !NO_AUTO_ASSIGN_WARNING #if IS_LEGACY_TFT #warning "Don't forget to update your TFT settings in Configuration.h." @@ -530,7 +544,11 @@ // Ender 3 Pro (but, apparently all Creality 4.2.2 boards) #if ENABLED(EMIT_CREALITY_422_WARNING) || MB(CREALITY_V4) - #warning "Creality 4.2.2 boards may have A4988 or TMC2208_STANDALONE drivers. Check your board and make sure to select the correct DRIVER_TYPE!" + #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225)." +#endif + +#if PRINTCOUNTER_SYNC + #warning "To prevent step loss, motion will pause for PRINTCOUNTER auto-save." #endif #if HOMING_Z_WITH_PROBE && IS_CARTESIAN && DISABLED(Z_SAFE_HOMING) @@ -540,8 +558,49 @@ // // 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)" +#if !USE_SENSORLESS + #if ENABLED(USES_DIAG_JUMPERS) && DISABLED(DIAG_JUMPERS_REMOVED) + #warning "Motherboard DIAG jumpers must be removed when SENSORLESS_HOMING is disabled. (Define DIAG_JUMPERS_REMOVED to suppress this warning.)" + #elif ENABLED(USES_DIAG_PINS) && DISABLED(DIAG_PINS_REMOVED) + #warning "Driver DIAG pins must be physically removed unless SENSORLESS_HOMING is enabled. (See https://bit.ly/2ZPRlt0) (Define DIAG_PINS_REMOVED to suppress this warning.)" + #endif +#endif + +#if CANNOT_EMBED_CONFIGURATION + #warning "Disabled CONFIGURATION_EMBEDDING because the target usually has less flash storage. Define FORCE_CONFIG_EMBED to override." +#endif + +#if HAS_LCD_CONTRAST && LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX + #warning "Contrast cannot be changed when LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX." +#endif + +/** + * FYSETC backlighting + */ +#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864_2_1) && !ALL(NEOPIXEL_LED, LED_CONTROL_MENU, LED_USER_PRESET_STARTUP, LED_COLOR_PRESETS) + #warning "Your FYSETC Mini Panel works best with NEOPIXEL_LED, LED_CONTROL_MENU, LED_USER_PRESET_STARTUP, and LED_COLOR_PRESETS." +#endif + +#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && DISABLED(RGB_LED) + #warning "Your FYSETC Mini Panel works best with RGB_LED." +#elif EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) && DISABLED(LED_USER_PRESET_STARTUP) + #warning "Your FYSETC Mini Panel works best with LED_USER_PRESET_STARTUP." +#endif + +#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864) && BOTH(PSU_CONTROL, HAS_COLOR_LEDS) && !LED_POWEROFF_TIMEOUT + #warning "Your FYSETC display with PSU_CONTROL works best with LED_POWEROFF_TIMEOUT." +#endif + +/** + * Maple environent + */ +#ifdef __STM32F1__ + #warning "Maple build environments are deprecated. Please use a non-Maple build environment. Report issues to the Marlin Firmware project." +#endif + +/** + * Průša MK3/S/+ fan pin reassignment + */ +#if MB(BTT_BTT002_V1_0, EINSY_RAMBO) && DISABLED(NO_MK3_FAN_PINS_WARNING) + #warning "Define MK3_FAN_PINS to swap hotend and part cooling fan pins. (Define NO_MK3_FAN_PINS_WARNING to suppress this warning.)" #endif diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index b450c9c10f5a..db4bd4e19e8c 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -284,7 +284,7 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS #endif // LCD_PROGRESS_BAR - #if BOTH(SDSUPPORT, HAS_LCD_MENU) + #if BOTH(SDSUPPORT, HAS_MARLINUI_MENU) // CHARSET_MENU const static PROGMEM byte refresh[8] = { @@ -334,7 +334,7 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS #endif { createChar_P(LCD_STR_UPLEVEL[0], uplevel); - #if BOTH(SDSUPPORT, HAS_LCD_MENU) + #if BOTH(SDSUPPORT, HAS_MARLINUI_MENU) // SD Card sub-menu special characters createChar_P(LCD_STR_REFRESH[0], refresh); createChar_P(LCD_STR_FOLDER[0], folder); @@ -1051,7 +1051,7 @@ void MarlinUI::draw_status_screen() { draw_status_message(blink); } -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../menu/menu.h" @@ -1117,10 +1117,14 @@ void MarlinUI::draw_status_screen() { // The Select Screen presents a prompt and two "buttons" void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { ui.draw_select_screen_prompt(pref, string, suff); - SETCURSOR(0, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd_put_wchar(yesno ? ' ' : ']'); - SETCURSOR_RJ(utf8_strlen_P(yes) + 2, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd_put_wchar(yesno ? ']' : ' '); + if (no) { + SETCURSOR(0, LCD_HEIGHT - 1); + lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd_put_wchar(yesno ? ' ' : ']'); + } + if (yes) { + SETCURSOR_RJ(utf8_strlen_P(yes) + 2, LCD_HEIGHT - 1); + lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd_put_wchar(yesno ? ']' : ' '); + } } #if ENABLED(SDSUPPORT) @@ -1584,6 +1588,6 @@ void MarlinUI::draw_status_screen() { #endif // AUTO_BED_LEVELING_UBL -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU #endif // HAS_MARLINUI_HD44780 diff --git a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp index 106ce7613892..d0cf5795d235 100644 --- a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp @@ -45,7 +45,7 @@ #include -int lcd_glyph_height(void) { return 1; } +int lcd_glyph_height() { return 1; } typedef struct _TFTGLCD_charmap_t { wchar_t uchar; // the unicode char @@ -1119,7 +1119,7 @@ int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { return 0; } - int test_TFTGLCD_charmap_all(void) { + int test_TFTGLCD_charmap_all() { int flg_error = 0; if (test_TFTGLCD_charmap(g_TFTGLCD_charmap_device, COUNT(g_TFTGLCD_charmap_device), "g_TFTGLCD_charmap_device", 0) < 0) { flg_error = 1; diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 420bd7cd66ae..0745397f4f99 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -265,7 +265,7 @@ void TFTGLCD::setContrast(uint16_t contrast) { extern volatile int8_t encoderDiff; // Read buttons and encoder states -uint8_t MarlinUI::read_slow_buttons(void) { +uint8_t MarlinUI::read_slow_buttons() { if (!PanelDetected) return 0; #if ENABLED(TFTGLCD_PANEL_SPI) uint8_t b = 0; @@ -922,7 +922,7 @@ void MarlinUI::draw_status_screen() { lcd.print_screen(); } -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../menu/menu.h" @@ -1003,11 +1003,15 @@ void MarlinUI::draw_status_screen() { void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff) { if (!PanelDetected) return; ui.draw_select_screen_prompt(pref, string, suff); - lcd.setCursor(0, MIDDLE_Y); lcd.write(COLOR_EDIT); - lcd.write(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd.write(yesno ? ' ' : ']'); - lcd.setCursor(LCD_WIDTH - utf8_strlen_P(yes) - 3, MIDDLE_Y); - lcd.write(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd.write(yesno ? ']' : ' '); + if (no) { + lcd.setCursor(0, MIDDLE_Y); + lcd.write(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd.write(yesno ? ' ' : ']'); + } + if (yes) { + lcd.setCursor(LCD_WIDTH - utf8_strlen_P(yes) - 3, MIDDLE_Y); + lcd.write(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd.write(yesno ? ']' : ' '); + } lcd.print_line(); } @@ -1084,6 +1088,6 @@ void MarlinUI::draw_status_screen() { #endif // AUTO_BED_LEVELING_UBL -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU #endif // IS_TFTGLCD_PANEL diff --git a/Marlin/src/lcd/buttons.h b/Marlin/src/lcd/buttons.h index 6d028e9bc65a..429fb971ec83 100644 --- a/Marlin/src/lcd/buttons.h +++ b/Marlin/src/lcd/buttons.h @@ -45,36 +45,6 @@ #define ENCODER_PHASE_3 1 #endif -#if IS_RRW_KEYPAD - #define BTN_OFFSET 0 // Bit offset into buttons for shift register values - - #define BLEN_KEYPAD_F3 0 - #define BLEN_KEYPAD_F2 1 - #define BLEN_KEYPAD_F1 2 - #define BLEN_KEYPAD_DOWN 3 - #define BLEN_KEYPAD_RIGHT 4 - #define BLEN_KEYPAD_MIDDLE 5 - #define BLEN_KEYPAD_UP 6 - #define BLEN_KEYPAD_LEFT 7 - - #define EN_KEYPAD_F1 _BV(BTN_OFFSET + BLEN_KEYPAD_F1) - #define EN_KEYPAD_F2 _BV(BTN_OFFSET + BLEN_KEYPAD_F2) - #define EN_KEYPAD_F3 _BV(BTN_OFFSET + BLEN_KEYPAD_F3) - #define EN_KEYPAD_DOWN _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN) - #define EN_KEYPAD_RIGHT _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT) - #define EN_KEYPAD_MIDDLE _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE) - #define EN_KEYPAD_UP _BV(BTN_OFFSET + BLEN_KEYPAD_UP) - #define EN_KEYPAD_LEFT _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT) - - #define RRK(B) (keypad_buttons & (B)) - - #ifdef EN_C - #define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE)) - #else - #define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE) - #endif -#endif - #if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2) // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes) #define BLEN_A 0 @@ -141,7 +111,39 @@ #define B_ST _BV(BL_ST) #ifndef BUTTON_CLICK - #define BUTTON_CLICK() (buttons & (B_MI|B_ST)) + #if EN_C + #define BUTTON_CLICK() (buttons & (B_MI|B_ST)) + #endif + #endif +#endif + +#if IS_RRW_KEYPAD + #define BTN_OFFSET 0 // Bit offset into buttons for shift register values + + #define BLEN_KEYPAD_F3 0 + #define BLEN_KEYPAD_F2 1 + #define BLEN_KEYPAD_F1 2 + #define BLEN_KEYPAD_DOWN 3 + #define BLEN_KEYPAD_RIGHT 4 + #define BLEN_KEYPAD_MIDDLE 5 + #define BLEN_KEYPAD_UP 6 + #define BLEN_KEYPAD_LEFT 7 + + #define EN_KEYPAD_F1 _BV(BTN_OFFSET + BLEN_KEYPAD_F1) + #define EN_KEYPAD_F2 _BV(BTN_OFFSET + BLEN_KEYPAD_F2) + #define EN_KEYPAD_F3 _BV(BTN_OFFSET + BLEN_KEYPAD_F3) + #define EN_KEYPAD_DOWN _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN) + #define EN_KEYPAD_RIGHT _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT) + #define EN_KEYPAD_MIDDLE _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE) + #define EN_KEYPAD_UP _BV(BTN_OFFSET + BLEN_KEYPAD_UP) + #define EN_KEYPAD_LEFT _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT) + + #define RRK(B) (keypad_buttons & (B)) + + #ifdef EN_C + #define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE)) + #else + #define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE) #endif #endif diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index a30dd4ca17f3..e5c6524a9ec4 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -57,6 +57,11 @@ #define U8G_COM_HAL_SW_SPI_FN u8g_com_std_sw_spi_fn #define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn + #elif defined(ESP32) + + uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + #define U8G_COM_HAL_HW_SPI_FN u8g_eps_hw_spi_fn + #elif defined(__AVR__) uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 59c74148adef..fc862e54398b 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -282,9 +282,9 @@ void MarlinUI::init_lcd() { #if PIN_EXISTS(LCD_RESET) // Perform a clean hardware reset with needed delays OUT_WRITE(LCD_RESET_PIN, LOW); - _delay_ms(5); + hal.delay_ms(5); WRITE(LCD_RESET_PIN, HIGH); - _delay_ms(5); + hal.delay_ms(5); u8g.begin(); #endif @@ -294,9 +294,13 @@ void MarlinUI::init_lcd() { TERN_(HAS_LCD_CONTRAST, refresh_contrast()); - TERN_(LCD_SCREEN_ROT_90, u8g.setRot90()); - TERN_(LCD_SCREEN_ROT_180, u8g.setRot180()); - TERN_(LCD_SCREEN_ROT_270, u8g.setRot270()); + #if LCD_SCREEN_ROTATE == 90 + u8g.setRot90(); + #elif LCD_SCREEN_ROTATE == 180 + u8g.setRot180(); + #elif LCD_SCREEN_ROTATE == 270 + u8g.setRot270(); + #endif update_language_font(); } @@ -349,7 +353,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../menu/menu.h" @@ -515,8 +519,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { ui.draw_select_screen_prompt(pref, string, suff); - draw_boxed_string(1, LCD_HEIGHT - 1, no, !yesno); - draw_boxed_string(LCD_WIDTH - (utf8_strlen_P(yes) * (USE_WIDE_GLYPH ? 2 : 1) + 1), LCD_HEIGHT - 1, yes, yesno); + if (no) draw_boxed_string(1, LCD_HEIGHT - 1, no, !yesno); + if (yes) draw_boxed_string(LCD_WIDTH - (utf8_strlen_P(yes) * (USE_WIDE_GLYPH ? 2 : 1) + 1), LCD_HEIGHT - 1, yes, yesno); } #if ENABLED(SDSUPPORT) @@ -740,6 +744,6 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #endif // BABYSTEP_ZPROBE_GFX_OVERLAY || MESH_EDIT_GFX_OVERLAY -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU #endif // HAS_MARLINUI_U8GLIB diff --git a/Marlin/src/lcd/dogm/status/bed.h b/Marlin/src/lcd/dogm/status/bed.h index 175a50e34188..27f5617ef703 100644 --- a/Marlin/src/lcd/dogm/status/bed.h +++ b/Marlin/src/lcd/dogm/status/bed.h @@ -42,6 +42,18 @@ B00000011,B11111111,B11111111 }; + #if HAS_LEVELING + const unsigned char status_bed_leveled_bmp[] PROGMEM = { + B11111111,B11111111,B11001110, + B01000000,B00100000,B00100100, + B00100000,B00010000,B00010000, + B00011111,B11111111,B11111000, + B00001000,B00000100,B00000100, + B00100100,B00000010,B00000010, + B01110011,B11111111,B11111111 + }; + #endif + const unsigned char status_bed_on_bmp[] PROGMEM = { B00000010,B00100010,B00000000, B00000100,B01000100,B00000000, @@ -57,6 +69,23 @@ B00000011,B11111111,B11111111 }; + #if HAS_LEVELING + const unsigned char status_bed_leveled_on_bmp[] PROGMEM = { + B00000010,B00100010,B00000000, + B00000100,B01000100,B00000000, + B00000100,B01000100,B00000000, + B00000010,B00100010,B00000000, + B00000001,B00010001,B00000000, + B11111111,B11111111,B11001110, + B01000000,B10101000,B10100100, + B00100001,B00010001,B00010000, + B00011111,B11111111,B11111000, + B00001000,B00000100,B00000100, + B00100100,B00000010,B00000010, + B01110011,B11111111,B11111111 + }; + #endif + #else #define STATUS_BED_WIDTH 21 diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 52554e5df8bd..c9a44e0c64d0 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -49,6 +49,10 @@ #include "../../module/planner.h" #endif +#if HAS_LEVELING + #include "../../module/planner.h" +#endif + #if HAS_CUTTER #include "../../feature/spindle_laser.h" #endif @@ -57,7 +61,7 @@ #include "../../feature/cooler.h" #endif -#if ENABLED(I2C_AMMETER) +#if DO_DRAW_AMMETER #include "../../feature/ammeter.h" #endif @@ -602,7 +606,13 @@ void MarlinUI::draw_status_screen() { #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS) #if ANIM_BED - #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp) + #if BOTH(HAS_LEVELING, STATUS_ALT_BED_BITMAP) + #define BED_BITMAP(S) ((S) \ + ? (planner.leveling_active ? status_bed_leveled_on_bmp : status_bed_on_bmp) \ + : (planner.leveling_active ? status_bed_leveled_bmp : status_bed_bmp)) + #else + #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp) + #endif #else #define BED_BITMAP(S) status_bed_bmp #endif @@ -664,7 +674,7 @@ void MarlinUI::draw_status_screen() { #if CUTTER_UNIT_IS(PERCENT) lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #elif CUTTER_UNIT_IS(RPM) - lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr51rj(float(cutter.unitPower) / 1000)); + lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr61rj(float(cutter.unitPower) / 1000)); lcd_put_wchar('K'); #else lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index 2e6d697488ca..492a79a31108 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -672,14 +672,7 @@ void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool // If position is unknown, flash the labels. const unsigned char alt_label = position_trusted ? 0 : (ui.get_blink() ? ' ' : 0); - if (TERN1(LCD_SHOW_E_TOTAL, !printingIsActive())) { - write_byte(alt_label ? alt_label : 'X'); - write_str(dtostrf(pos.x, -4, 0, str), 4); - - write_byte(alt_label ? alt_label : 'Y'); - write_str(dtostrf(pos.y, -4, 0, str), 4); - } - else { + if (TERN0(LCD_SHOW_E_TOTAL, printingIsActive())) { #if ENABLED(LCD_SHOW_E_TOTAL) char tmp[15]; const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm @@ -687,6 +680,13 @@ void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool write_str(tmp); #endif } + else { + write_byte(alt_label ? alt_label : 'X'); + write_str(dtostrf(pos.x, -4, 0, str), 4); + + write_byte(alt_label ? alt_label : 'Y'); + write_str(dtostrf(pos.y, -4, 0, str), 4); + } write_byte(alt_label ? alt_label : 'Z'); write_str(dtostrf(pos.z, -5, 1, str), 5); diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index d89b22a7aa74..f6780bba6c26 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -21,7 +21,7 @@ */ #include "../../../inc/MarlinConfigPre.h" -#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI #include "dwin_api.h" #include "dwin_set.h" diff --git a/Marlin/src/lcd/e3v2/common/dwin_set.h b/Marlin/src/lcd/e3v2/common/dwin_set.h index 4fedd7a5843b..7f4438695478 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_set.h +++ b/Marlin/src/lcd/e3v2/common/dwin_set.h @@ -25,7 +25,16 @@ #define Language_English 1 #define Language_Chinese 2 -#define ICON 7 // Icon set file 7.ICO +//#define USE_STOCK_DWIN_SET // Use the Creality stock DWIN_SET instead of Marlin's unified DWIN_SET by The-EG & thinkyhead +#ifdef USE_STOCK_DWIN_SET + #define ICON 9 // 9.ICO +#else + #define ICON 7 // 7.ICO +#endif + +#ifndef CORP_WEBSITE + #define CORP_WEBSITE WEBSITE_URL +#endif #define ICON_LOGO 0 #define ICON_Print_0 1 diff --git a/Marlin/src/lcd/e3v2/common/encoder.h b/Marlin/src/lcd/e3v2/common/encoder.h index e5d9645ed43b..3ab8c3bf422b 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.h +++ b/Marlin/src/lcd/e3v2/common/encoder.h @@ -45,12 +45,32 @@ typedef enum { ENCODER_DIFF_ENTER = 3 // click } EncoderState; +#define ENCODER_WAIT_MS 20 + // Encoder initialization void Encoder_Configuration(); // Analyze encoder value and return state EncoderState Encoder_ReceiveAnalyze(); +inline EncoderState get_encoder_state() { + static millis_t Encoder_ms = 0; + const millis_t ms = millis(); + if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; + const EncoderState state = Encoder_ReceiveAnalyze(); + if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; + return state; +} + +template +inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { + if (encoder_diffState == ENCODER_DIFF_CW) + valref += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + valref -= EncoderRate.encoderMoveValue; + return encoder_diffState == ENCODER_DIFF_ENTER; +} + /*********************** Encoder LED ***********************/ #if PIN_EXISTS(LCD_LED) diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index adf8f3771f3d..05ac38d226ce 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -91,9 +91,6 @@ #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL -#endif #define PAUSE_HEAT @@ -474,15 +471,6 @@ void Draw_Back_First(const bool is_sel=true) { if (is_sel) Draw_Menu_Cursor(0); } -template -inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { - if (encoder_diffState == ENCODER_DIFF_CW) - valref += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - valref -= EncoderRate.encoderMoveValue; - return encoder_diffState == ENCODER_DIFF_ENTER; -} - // // Draw Menus // @@ -1299,15 +1287,6 @@ void Goto_MainMenu() { TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); } -inline EncoderState get_encoder_state() { - static millis_t Encoder_ms = 0; - const millis_t ms = millis(); - if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; - const EncoderState state = Encoder_ReceiveAnalyze(); - if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; - return state; -} - void HMI_Plan_Move(const feedRate_t fr_mm_s) { if (!planner.is_full()) { planner.synchronize(); @@ -1754,7 +1733,7 @@ void update_variable() { if (_new_hotend_target) Draw_Stat_Int(25 + 4 * STAT_CHR_W + 6, 384, _hotendtarget); - static int16_t _flow = planner.flow_percentage[0]; + static int16_t _flow = 0; if (_flow != planner.flow_percentage[0]) { _flow = planner.flow_percentage[0]; Draw_Stat_Int(116 + 2 * STAT_CHR_W, 417, _flow); @@ -1768,7 +1747,7 @@ void update_variable() { Draw_Stat_Int(25 + 4 * STAT_CHR_W + 6, 417, _bedtarget); #endif - static int16_t _feedrate = 100; + static int16_t _feedrate = 0; if (_feedrate != feedrate_percentage) { _feedrate = feedrate_percentage; Draw_Stat_Int(116 + 2 * STAT_CHR_W, 384, _feedrate); @@ -1834,6 +1813,9 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) void HMI_SDCardInit() { card.cdroot(); } +// Initialize or re-initialize the LCD +void MarlinUI::init_lcd() { DWIN_Startup(); } + void MarlinUI::refresh() { /* Nothing to see here */ } #if HAS_LCD_BRIGHTNESS @@ -2269,6 +2251,8 @@ void HMI_SelectFile() { // thermalManager.fan_speed[i] = 255; #endif + _card_percent = 0; + _remain_time = 0; Goto_PrintProcess(); } } @@ -2760,7 +2744,10 @@ void HMI_Prepare() { #endif #if HAS_HOTEND || HAS_HEATED_BED - case PREPARE_CASE_COOL: thermalManager.cooldown(); break; + case PREPARE_CASE_COOL: + thermalManager.cooldown(); + ui.reset_status(); + break; #endif case PREPARE_CASE_LANG: @@ -4081,6 +4068,13 @@ void HMI_Init() { HMI_SetLanguage(); } +void DWIN_InitScreen() { + Encoder_Configuration(); + HMI_Init(); + HMI_SetLanguageCache(); + HMI_StartFrame(true); +} + void DWIN_Update() { EachMomentUpdate(); // Status update HMI_SDCardUpdate(); // SD card update @@ -4173,10 +4167,7 @@ void EachMomentUpdate() { } #if ENABLED(POWER_LOSS_RECOVERY) else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off - static bool recovery_flag = false; - recovery.dwin_flag = false; - recovery_flag = true; auto update_selection = [&](const bool sel) { HMI_flag.select_flag = sel; @@ -4196,6 +4187,7 @@ void EachMomentUpdate() { DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name); DWIN_UpdateLCD(); + bool recovery_flag = true; while (recovery_flag) { EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { @@ -4289,7 +4281,7 @@ void DWIN_HandleScreen() { } } -void DWIN_CompletedHoming() { +void DWIN_HomingDone() { HMI_flag.home_flag = false; dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); if (checkkey == Last_Prepare) { @@ -4305,7 +4297,7 @@ void DWIN_CompletedHoming() { } } -void DWIN_CompletedLeveling() { +void DWIN_LevelingDone() { if (checkkey == Leveling) Goto_MainMenu(); } diff --git a/Marlin/src/lcd/e3v2/creality/dwin.h b/Marlin/src/lcd/e3v2/creality/dwin.h index 3122a6fcbae1..487f309ed996 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.h +++ b/Marlin/src/lcd/e3v2/creality/dwin.h @@ -236,13 +236,14 @@ void HMI_MaxJerk(); // Maximum jerk speed submenu void HMI_Step(); // Transmission ratio void HMI_Init(); +void DWIN_InitScreen(); void DWIN_Update(); void EachMomentUpdate(); void DWIN_HandleScreen(); void DWIN_StatusChanged(const char * const cstr=nullptr); void DWIN_StatusChanged(FSTR_P const fstr); -inline void DWIN_StartHoming() { HMI_flag.home_flag = true; } +inline void DWIN_HomingStart() { HMI_flag.home_flag = true; } -void DWIN_CompletedHoming(); -void DWIN_CompletedLeveling(); +void DWIN_HomingDone(); +void DWIN_LevelingDone(); diff --git a/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp index fee22932d2e5..3d60e32a7908 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp @@ -49,6 +49,7 @@ void DWIN_Startup() { #if DISABLED(SHOW_BOOTSCREEN) DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here #endif + DWIN_JPG_ShowAndCache(3); DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/enhanced/meshviewer.h b/Marlin/src/lcd/e3v2/enhanced/meshviewer.h deleted file mode 100644 index 0ba6ae2d7d15..000000000000 --- a/Marlin/src/lcd/e3v2/enhanced/meshviewer.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * DWIN Mesh Viewer - * Author: Miguel A. Risco-Castillo - * Version: 3.8.1 - * Date: 2021/11/06 - * - * This program 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 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 Lesser General Public License - * along with this program. If not, see . - * - */ -#pragma once - -class MeshViewerClass { -public: - void Draw(); -}; - -extern MeshViewerClass MeshViewer; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 4c838a2e2143..3e777d4aaaed 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -82,10 +82,6 @@ #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL - #endif - #define DWIN_FONT_MENU font8x16 #define DWIN_FONT_STAT font10x20 #define DWIN_FONT_HEAD font10x20 @@ -962,8 +958,8 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { static bool new_msg; static uint8_t msgscrl = 0; static char lastmsg[64]; - if (strcmp_P(lastmsg, statusmsg) != 0 || refresh) { - strcpy_P(lastmsg, statusmsg); + if (strcmp(lastmsg, statusmsg) != 0 || refresh) { + strcpy(lastmsg, statusmsg); msgscrl = 0; new_msg = true; } @@ -4135,7 +4131,7 @@ void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) { switch (popupid) { case Pause: Draw_Popup(F("Pause Print"), F(""), F(""), Popup); break; case Stop: Draw_Popup(F("Stop Print"), F(""), F(""), Popup); break; - case Resume: Draw_Popup(F("Resume Print?"), F("Looks Like the last"), F("print was interupted."), Popup); break; + case Resume: Draw_Popup(F("Resume Print?"), F("Looks Like the last"), F("print was interrupted."), Popup); break; case ConfFilChange: Draw_Popup(F("Confirm Filament Change"), F(""), F(""), Popup); break; case PurgeMore: Draw_Popup(F("Purge more filament?"), F("(Cancel to finish process)"), F(""), Popup); break; case SaveLevel: Draw_Popup(F("Leveling Complete"), F("Save to EEPROM?"), F(""), Popup); break; @@ -4699,10 +4695,7 @@ void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * option /* Main Functions */ void CrealityDWINClass::Update_Status(const char * const text) { - char header[4]; - LOOP_L_N(i, 3) header[i] = text[i]; - header[3] = '\0'; - if (strcmp_P(header, PSTR("")) == 0) { + if (strncmp_P(text, PSTR(""), 3) == 0) { LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i + 3]; filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0'; Draw_Print_Filename(true); @@ -4726,10 +4719,10 @@ void CrealityDWINClass::Start_Print(bool sd) { card.selectFileByName(fname); } #endif - strcpy_P(filename, card.longest_filename()); + strcpy(filename, card.longest_filename()); } else - strcpy_P(filename, "Host Print"); + strcpy_P(filename, PSTR("Host Print")); TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_Screen(); @@ -4924,18 +4917,10 @@ void CrealityDWINClass::Screen_Update() { } void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) { - if (success) { - if (ui.buzzer_enabled) { - BUZZ(100, 659); - BUZZ( 10, 0); - BUZZ(100, 698); - } - else Update_Status("Success"); - } - else if (ui.buzzer_enabled) - BUZZ(40, 440); + if (ui.buzzer_enabled) + DONE_BUZZ(success); else - Update_Status("Failed"); + Update_Status(success ? "Success" : "Failed"); } void CrealityDWINClass::Save_Settings(char *buff) { @@ -4980,7 +4965,7 @@ void CrealityDWINClass::Reset_Settings() { Redraw_Screen(); } -void MarlinUI::init() { +void MarlinUI::init_lcd() { delay(800); SERIAL_ECHOPGM("\nDWIN handshake "); if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error."); @@ -4993,6 +4978,8 @@ void MarlinUI::init() { DWIN_UpdateLCD(); delay(20); } + + DWIN_JPG_ShowAndCache(3); DWIN_JPG_CacheTo1(Language_English); CrealityDWIN.Redraw_Screen(); } diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp index ef390ac9dc04..a4cefe4ab99a 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp @@ -45,6 +45,7 @@ void DWIN_Startup() { const bool success = DWIN_Handshake(); if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error."); DWIN_Frame_SetDir(TERN(DWIN_MARLINUI_LANDSCAPE, 0, 1)); + DWIN_JPG_ShowAndCache(3); DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h index 3e80a0103ee8..dc6c79bd2d0e 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h @@ -64,6 +64,8 @@ #define ICON_UpArrow 14 #define ICON_DownArrow 15 #define ICON_BedLine 16 +#define ICON_BedLevelOff 17 +#define ICON_BedLevelOn 18 #include "../common/dwin_font.h" diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h index 30af387bdcba..64676dddfdaf 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h @@ -55,7 +55,7 @@ class DWIN_String { //static font_t *font() { return font_header; }; //static uint16_t font_height() { return font_header->FontAscent - font_header->FontDescent; } //static glyph_t *glyph(uint8_t character) { return glyphs[character] ?: glyphs[0x3F]; } /* Use '?' for unknown glyphs */ - //static inline glyph_t *glyph(uint8_t *character) { return glyph(*character); } + //static glyph_t *glyph(uint8_t *character) { return glyph(*character); } static void set(); //static void add(uint8_t character) { add_character(character); eol(); } @@ -65,10 +65,10 @@ class DWIN_String { static void set(uint8_t *string) { set(); add(string); } static void set(wchar_t character) { set(); add(character); } static void set(uint8_t *string, int8_t index, const char *itemString=nullptr) { set(); add(string, index, (uint8_t *)itemString); } - static inline void set(FSTR_P fstring) { set((uint8_t *)fstring); } - static inline void set(const char *string) { set((uint8_t *)string); } - static inline void set(const char *string, int8_t index, const char *itemString=nullptr) { set((uint8_t *)string, index, itemString); } - static inline void add(const char *string) { add((uint8_t *)string); } + static void set(FSTR_P fstring) { set((uint8_t *)fstring); } + static void set(const char *string) { set((uint8_t *)string); } + static void set(const char *string, int8_t index, const char *itemString=nullptr) { set((uint8_t *)string, index, itemString); } + static void add(const char *string) { add((uint8_t *)string); } static void trim(const uint8_t character=0x20); static void rtrim(const uint8_t character=0x20); @@ -76,9 +76,9 @@ class DWIN_String { static void truncate(uint8_t maxlen) { if (len > maxlen) { len = maxlen; eol(); } } - static inline uint8_t length() { return len; } - static inline uint16_t width() { return span; } - static inline uint8_t *string() { return data; } + static uint8_t length() { return len; } + static uint16_t width() { return span; } + static uint8_t *string() { return data; } static uint16_t center(uint16_t width) { return span > width ? 0 : (width - span) / 2; } }; diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index 126700185b04..f49d06d39642 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -79,12 +79,7 @@ void MarlinUI::set_font(const uint8_t font_nr) { bool MarlinUI::detected() { return true; } // Initialize or re-initialize the LCD -void MarlinUI::init_lcd() { - DWIN_Startup(); - - // Load the assets JPG (currently just the status screen 'icon') - DWIN_JPG_CacheTo1(DWIN_MarlinUI_Assets); -} +void MarlinUI::init_lcd() { DWIN_Startup(); } // This LCD should clear where it will draw anew void MarlinUI::clear_lcd() { @@ -258,7 +253,7 @@ void MarlinUI::draw_status_message(const bool blink) { void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../../menu/menu.h" @@ -442,8 +437,8 @@ void MarlinUI::draw_status_message(const bool blink) { dwin_font.solid = false; dwin_font.fg = Color_White; ui.draw_select_screen_prompt(pref, string, suff); - draw_boxed_string(false, no, !yesno); - draw_boxed_string(true, yes, yesno); + if (no) draw_boxed_string(false, no, !yesno); + if (yes) draw_boxed_string(true, yes, yesno); } #if ENABLED(SDSUPPORT) @@ -586,6 +581,6 @@ void MarlinUI::draw_status_message(const bool blink) { #endif // BABYSTEP_ZPROBE_GFX_OVERLAY || MESH_EDIT_GFX_OVERLAY -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU #endif // IS_DWIN_MARLINUI diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 306e9044f703..c2948048c119 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -37,6 +37,7 @@ #include "../../../module/motion.h" #include "../../../module/temperature.h" #include "../../../module/printcounter.h" +#include "../../../module/planner.h" #if ENABLED(SDSUPPORT) #include "../../../libs/duration_t.h" @@ -46,8 +47,13 @@ #include "../../../MarlinCore.h" // for printingIsActive #endif -#define STATUS_HEATERS_X 15 -#define STATUS_HEATERS_Y 56 +#if ENABLED(DWIN_MARLINUI_PORTRAIT) + #define STATUS_HEATERS_X 15 + #define STATUS_HEATERS_Y 56 +#else + #define STATUS_HEATERS_X 154 + #define STATUS_HEATERS_Y 10 +#endif #define STATUS_HEATERS_XSPACE 64 #define STATUS_FAN_WIDTH 48 #define STATUS_FAN_HEIGHT 48 @@ -61,35 +67,63 @@ // Homed and known, display constantly. // FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink, const uint16_t x, const uint16_t y) { - uint8_t vallen = utf8_strlen(value); - if (!ui.did_first_redraw) { - dwin_string.set(); - dwin_string.add('X' + axis); - DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (vallen * 14 - 14) / 2, y + 2, S(dwin_string.string())); - } + #if ENABLED(DWIN_MARLINUI_PORTRAIT) - dwin_string.set(); - if (blink) - dwin_string.add(value); - else { - if (!TEST(axis_homed, axis)) + uint8_t vallen = utf8_strlen(value); + if (!ui.did_first_redraw) { + dwin_string.set(); + dwin_string.add('X' + axis); + DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (vallen * 14 - 14) / 2, y + 2, S(dwin_string.string())); + } + + dwin_string.set(); + if (blink) + dwin_string.add(value); + else if (!TEST(axis_homed, axis)) while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); + else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !TEST(axis_trusted, axis)) + dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); + else + dwin_string.add(value); + + // For E_TOTAL there may be some characters to cover up + if (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS) + dwin_string.add(" "); + + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); + + #else // !DWIN_MARLINUI_PORTRAIT + + if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { + dwin_string.set(); + dwin_string.add('X' + axis); + DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string())); + } + + dwin_string.set(); + if (blink) + dwin_string.add(value); else { - #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) - if (!TEST(axis_trusted, axis)) - dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); - else - #endif - dwin_string.add(value); + if (!TEST(axis_homed, axis)) + while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); + else { + #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) + if (!TEST(axis_trusted, axis)) + dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); + else + #endif + dwin_string.add(value); + } } - } - // For E_TOTAL there may be some characters to cover up - if (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS) - dwin_string.add(" "); + // For E_TOTAL there may be some characters to cover up + if (ENABLED(LCD_SHOW_E_TOTAL) && (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) && axis == X_AXIS) + dwin_string.add(" "); + + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string())); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); + #endif // !DWIN_MARLINUI_PORTRAIT } #if ENABLED(LCD_SHOW_E_TOTAL) @@ -97,20 +131,36 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_e_value(const_float_t value, const uint16_t x, const uint16_t y) { const uint8_t scale = value >= 100000.0f ? 10 : 1; // show cm after 99,999mm - if (!ui.did_first_redraw) { - // Extra spaces so we don't have to clear the 'Y' label separately - dwin_string.set("E "); - DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string())); - } + #if ENABLED(DWIN_MARLINUI_PORTRAIT) - dwin_string.set(ui16tostr5rj(value / scale)); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); + if (!ui.did_first_redraw) { + // Extra spaces to erase previous value + dwin_string.set("E "); + DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string())); + } + + dwin_string.set(ui16tostr5rj(value / scale)); + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); + + // Extra spaces to erase previous value + DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, x + (5 * 14), y + 32, S(scale == 1 ? "mm " : "cm ")); + + #else // !DWIN_MARLINUI_PORTRAIT + + if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { + dwin_string.set("E "); + DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string())); + } + + dwin_string.set(ui16tostr5rj(value / scale)); + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string())); + + DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, x + (32 + 70), y + 4, S(scale == 1 ? "mm " : "cm ")); - // Extra spaces so we don't have to clear out the Y value separately - DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, x + (5 * 14), y + 32, S(scale == 1 ? "mm " : "cm ")); + #endif // !DWIN_MARLINUI_PORTRAIT } -#endif +#endif // LCD_SHOW_E_TOTAL // // Fan Icon and Percentage @@ -126,6 +176,7 @@ FORCE_INLINE void _draw_fan_status(const uint16_t x, const uint16_t y) { DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string())); } else { + DWIN_ICON_AnimationControl(0x0000); // disable all icon animations (this is the only one) DWIN_ICON_Show(ICON, ICON_Fan0, x + fanx, y); dwin_string.set(PSTR(" ")); DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string())); @@ -153,18 +204,35 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #if HAS_HEATED_BED static celsius_t old_bed_temp = 500, old_bed_target = 500; static bool old_bed_on = false; + #if HAS_LEVELING + static bool old_leveling_on = false; + #endif #endif #if HAS_HOTEND && HAS_HEATED_BED const bool isBed = heater < 0; - const float tc = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater)), - tt = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater)); - const uint8_t ta = isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater); - const bool c_draw = tc != (isBed ? old_bed_temp : old_temp[heater]), - t_draw = tt != (isBed ? old_bed_target : old_target[heater]), - i_draw = ta != (isBed ? old_bed_on : old_on[heater]); - if (isBed) { old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; } - else { old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; } + const float tc = isBed ? thermalManager.degBed() : thermalManager.degHotend(heater), + tt = isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater); + const bool ta = isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater); + + bool c_draw = tc != (isBed ? old_bed_temp : old_temp[heater]), + t_draw = tt != (isBed ? old_bed_target : old_target[heater]), + i_draw = ta != (isBed ? old_bed_on : old_on[heater]); + + if (isBed) { + #if HAS_LEVELING + if (!i_draw && planner.leveling_active != old_leveling_on) i_draw = true; + old_leveling_on = planner.leveling_active; + #endif + old_bed_temp = tc; + old_bed_target = tt; + old_bed_on = ta; + } + else { + old_temp[heater] = tc; + old_target[heater] = tt; + old_on[heater] = ta; + } #elif HAS_HOTEND constexpr bool isBed = false; const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); @@ -175,7 +243,11 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x constexpr bool isBed = true; const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); const uint8_t ta = thermalManager.isHeatingBed(); - const bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; + bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; + #if HAS_LEVELING + if (!idraw && planner.leveling_active != old_leveling_on) i_draw = true; + old_leveling_on = tl; + #endif old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; #endif @@ -185,8 +257,10 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y, S(dwin_string.string())); } - if (!ui.did_first_redraw || i_draw) - DWIN_ICON_Show(ICON, (isBed ? ICON_BedOff : ICON_HotendOff) + ta, x, y + STATUS_CHR_HEIGHT + 2); + if (!ui.did_first_redraw || i_draw){ + const uint8_t ico = isBed ? (TERN0(HAS_LEVELING, planner.leveling_active) ? ICON_BedLevelOff : ICON_BedOff) : ICON_HotendOff; + DWIN_ICON_Show(ICON, ico + ta, x, y + STATUS_CHR_HEIGHT + 2); + } if (!ui.did_first_redraw || c_draw) { dwin_string.set(i16tostr3rj(tc + 0.5)); @@ -220,14 +294,22 @@ void MarlinUI::draw_status_screen() { // Logo/Status Icon #define STATUS_LOGO_WIDTH 128 #define STATUS_LOGO_HEIGHT 40 - DWIN_ICON_Show(ICON, ICON_LOGO_Marlin, (LCD_PIXEL_WIDTH - (STATUS_LOGO_WIDTH)) / 2, ((STATUS_HEATERS_Y - 4) - (STATUS_LOGO_HEIGHT)) / 2); + DWIN_ICON_Show(ICON, ICON_LOGO_Marlin, + #if ENABLED(DWIN_MARLINUI_PORTRAIT) + (LCD_PIXEL_WIDTH - (STATUS_LOGO_WIDTH)) / 2, ((STATUS_HEATERS_Y - 4) - (STATUS_LOGO_HEIGHT)) / 2 + #else + 5, 42 + #endif + ); // Draw a frame around the x/y/z values - #if ENABLED(DWIN_MARLINUI_PORTRAIT) - DWIN_Draw_Rectangle(0, Select_Color, 0, 193, LCD_PIXEL_WIDTH, 260); - #else - //DWIN_Draw_Rectangle(0, Select_Color, LCD_PIXEL_WIDTH - 106, 50, LCD_PIXEL_WIDTH - 1, 230); - #endif + DWIN_Draw_Rectangle(0, Select_Color, + #if ENABLED(DWIN_MARLINUI_PORTRAIT) + 0, 193, LCD_PIXEL_WIDTH, 260 + #else + 0, 115, LCD_PIXEL_WIDTH - 1, 152 + #endif + ); } uint16_t hx = STATUS_HEATERS_X; @@ -244,33 +326,22 @@ void MarlinUI::draw_status_screen() { #endif #if HAS_FAN - // Fan display, pinned to the right side - #if ENABLED(DWIN_MARLINUI_PORTRAIT) - _draw_fan_status(LCD_PIXEL_WIDTH - STATUS_CHR_WIDTH * 4, STATUS_FAN_Y); - #else - _draw_fan_status(212, STATUS_FAN_Y); - #endif + _draw_fan_status(LCD_PIXEL_WIDTH - STATUS_CHR_WIDTH * 5, STATUS_FAN_Y); #endif // Axis values const xyz_pos_t lpos = current_position.asLogical(); const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive()); UNUSED(show_e_total); - #if ENABLED(DWIN_MARLINUI_PORTRAIT) - constexpr int16_t cpy = 195; - if (show_e_total) { - TERN_(LCD_SHOW_E_TOTAL, _draw_e_value(e_move_accumulator, 6, cpy)); - } - else { - _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink, 6, cpy); - TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink, 95, cpy)); - } - TERN_(HAS_Z_AXIS, _draw_axis_value(Z_AXIS, ftostr52sp(lpos.z), blink, 165, cpy)); - #else - constexpr int16_t cpx = LCD_PIXEL_WIDTH - 104; - _draw_axis_value(X_AXIS, ftostr52sp(lpos.x), blink, cpx, STATUS_HEATERS_Y); - TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ftostr52sp(lpos.y), blink, cpx, STATUS_HEATERS_Y + 59)); - TERN_(HAS_Z_AXIS, _draw_axis_value(Z_AXIS, ftostr52sp(lpos.z), blink, cpx, STATUS_HEATERS_Y + 118)); - #endif + + constexpr int16_t cpy = TERN(DWIN_MARLINUI_PORTRAIT, 195, 117); + if (show_e_total) { + TERN_(LCD_SHOW_E_TOTAL, _draw_e_value(e_move_accumulator, TERN(DWIN_MARLINUI_PORTRAIT, 6, 75), cpy)); + } + else { + _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink, TERN(DWIN_MARLINUI_PORTRAIT, 6, 75), cpy); + TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink, TERN(DWIN_MARLINUI_PORTRAIT, 95, 184), cpy)); + } + TERN_(HAS_Z_AXIS, _draw_axis_value(Z_AXIS, ftostr52sp(lpos.z), blink, TERN(DWIN_MARLINUI_PORTRAIT, 165, 300), cpy)); // Feedrate static uint16_t old_fp = 0; @@ -278,9 +349,9 @@ void MarlinUI::draw_status_screen() { old_fp = feedrate_percentage; _draw_feedrate_status(i16tostr3rj(feedrate_percentage), #if ENABLED(DWIN_MARLINUI_PORTRAIT) - 5, 290 + 5, 290 #else - 294, STATUS_HEATERS_Y + 14, 195 #endif ); } @@ -317,25 +388,23 @@ void MarlinUI::draw_status_screen() { time.toDigital(buffer); dwin_string.set(" "); dwin_string.add(buffer); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 280, 100, S(dwin_string.string())); + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 230, 170, S(dwin_string.string())); - #if ENABLED(LCD_SHOW_E_TOTAL) - if (show_e_total && TERN1(SHOW_REMAINING_TIME, !blink)) { // if SHOW_REMAINING_TIME is also - const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // show cm after 99,000mm - - DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 249, 135, S("E")); - dwin_string.set(ui16tostr5rj(e_move_accumulator * escale)); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 263, 135, S(dwin_string.string())); - DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 333, 135, S(escale==1 ? "mm" : "cm")); - } - #endif #if ENABLED(SHOW_REMAINING_TIME) - if (!show_e_total || blink) { - DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 249, 135, S(" R ")); + if (print_job_timer.isRunning()) { time = get_remaining_time(); - time.toDigital(buffer); - dwin_string.set(buffer); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 291, 135, S(dwin_string.string())); + DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(" R ")); + if (print_job_timer.isPaused() && blink) + dwin_string.set(" "); + else { + time.toDigital(buffer); + dwin_string.set(buffer); + } + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string())); + } + else if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { + dwin_string.set(" "); + DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string())); } #endif #endif @@ -343,9 +412,11 @@ void MarlinUI::draw_status_screen() { // // Progress Bar // - constexpr int16_t pb_margin = 5, pb_left = pb_margin, pb_height = 60, - pb_right = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_PORTRAIT, 0, 107) - pb_margin, - pb_bottom = TERN(DWIN_MARLINUI_PORTRAIT, 410, 230), + constexpr int16_t pb_margin = 5, + pb_left = pb_margin + TERN(DWIN_MARLINUI_PORTRAIT, 0, 90), + pb_height = TERN(DWIN_MARLINUI_PORTRAIT, 60, 20), + pb_right = LCD_PIXEL_WIDTH - pb_margin, + pb_bottom = TERN(DWIN_MARLINUI_PORTRAIT, 410, 220), pb_top = pb_bottom - pb_height, pb_width = pb_right - pb_left; @@ -385,6 +456,7 @@ void MarlinUI::draw_status_screen() { draw_status_message(blink); ui.did_first_redraw = true; + ui.old_is_printing = print_job_timer.isRunning(); } #endif // IS_DWIN_MARLINUI diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp similarity index 56% rename from Marlin/src/lcd/e3v2/enhanced/dwin.cpp rename to Marlin/src/lcd/e3v2/proui/dwin.cpp index d1a9ba7077fd..66e90740fdfb 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -21,17 +21,19 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.15.2 + * Date: 2022/03/01 */ -#include "../../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfig.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "dwin.h" +#include "menus.h" +#include "dwin_popup.h" #include "../../fontutils.h" #include "../../marlinui.h" @@ -62,6 +64,10 @@ #include "../../../feature/host_actions.h" #endif +#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY) + #define HAS_ONESTEP_LEVELING 1 +#endif + #if HAS_MESH || HAS_ONESTEP_LEVELING #include "../../../feature/bedlevel/bedlevel.h" #endif @@ -70,18 +76,48 @@ #include "../../../module/probe.h" #endif -#if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - #include "../../../feature/babystep.h" +#ifdef BLTOUCH_HS_MODE + #include "../../../feature/bltouch.h" +#endif + +#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) + #define HAS_ZOFFSET_ITEM 1 + #if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) + #define JUST_BABYSTEP 1 + #endif + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) + #include "../../../feature/babystep.h" + #endif #endif #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../feature/powerloss.h" #endif +#if HAS_GCODE_PREVIEW + #include "gcode_preview.h" +#endif + +#if HAS_ESDIAG + #include "endstop_diag.h" +#endif + #if HAS_MESH #include "meshviewer.h" #endif +#if ENABLED(PRINTCOUNTER) + #include "printstats.h" +#endif + +#if ENABLED(CASE_LIGHT_MENU) + #include "../../../feature/caselight.h" +#endif + +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" +#endif + #include #include #include @@ -92,10 +128,6 @@ #include "lockscreen.h" -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL -#endif - #define PAUSE_HEAT #define MENU_CHAR_LIMIT 24 @@ -148,7 +180,7 @@ enum SelectItem : uint8_t { PAGE_PRINT = 0, PAGE_PREPARE, PAGE_CONTROL, - PAGE_INFO_LEVELING, + PAGE_ADVANCE, PAGE_COUNT, PRINT_SETUP = 0, @@ -169,14 +201,13 @@ typedef struct { select_t select_page{0}, select_file{0}, select_print{0}; uint8_t index_file = MROWS; -bool dwin_abort_flag = false; // Flag to reset feedrate, return to Home bool hash_changed = true; // Flag to know if message status was changed -constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; -constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; +constexpr float max_feedrate_edit_values[] = DEFAULT_MAX_FEEDRATE; +constexpr float max_acceleration_edit_values[] = DEFAULT_MAX_ACCELERATION; #if HAS_CLASSIC_JERK - constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; + constexpr float max_jerk_edit_values[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; #endif static uint8_t _percent_done = 0; @@ -185,18 +216,6 @@ static uint32_t _remain_time = 0; // Additional Aux Host Support static bool sdprint = false; -#if ENABLED(PAUSE_HEAT) - #if HAS_HOTEND - celsius_t resume_hotend_temp = 0; - #endif - #if HAS_HEATED_BED - celsius_t resume_bed_temp = 0; - #endif - #if HAS_FAN - uint16_t resume_fan = 0; - #endif -#endif - #if HAS_ZOFFSET_ITEM float dwin_zoffset = 0, last_zoffset = 0; #endif @@ -207,7 +226,7 @@ static bool sdprint = false; // New menu system pointers MenuClass *PrepareMenu = nullptr; -MenuClass *LevBedMenu = nullptr; +MenuClass *TrammingMenu = nullptr; MenuClass *MoveMenu = nullptr; MenuClass *ControlMenu = nullptr; MenuClass *AdvancedSettings = nullptr; @@ -236,9 +255,18 @@ MenuClass *MaxJerkMenu = nullptr; MenuClass *StepsMenu = nullptr; MenuClass *HotendPIDMenu = nullptr; MenuClass *BedPIDMenu = nullptr; -#if EITHER(HAS_BED_PROBE, BABYSTEPPING) +#if ENABLED(CASELIGHT_USES_BRIGHTNESS) + MenuClass *CaseLightMenu = nullptr; +#endif +#if ENABLED(LED_CONTROL_MENU) + MenuClass *LedControlMenu = nullptr; +#endif +#if HAS_BED_PROBE MenuClass *ZOffsetWizMenu = nullptr; #endif +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + MenuClass *HomingMenu = nullptr; +#endif // Updatable menuitems pointers MenuItemClass *HotendTargetItem = nullptr; @@ -270,13 +298,23 @@ void HMI_ToggleLanguage() { #endif } +//----------------------------------------------------------------------------- +// Main Buttons +//----------------------------------------------------------------------------- + typedef struct { uint16_t x, y[2], w, h; } text_info_t; -void ICON_Button(const bool here, const int iconid, const frame_rect_t &ico, const text_info_t (&txt)[2]) { - const bool cn = HMI_IsChinese(); - DWIN_ICON_Show(true, false, false, ICON, iconid + here, ico.x, ico.y); - if (here) DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, ico.x, ico.y, ico.x + ico.w - 1, ico.y + ico.h - 1); - DWIN_Frame_AreaCopy(1, txt[cn].x, txt[cn].y[here], txt[cn].x + txt[cn].w - 1, txt[cn].y[here] + txt[cn].h - 1, ico.x + (ico.w - txt[cn].w) / 2, (ico.y + ico.h - 28) - txt[cn].h/2); +void ICON_Button(const bool selected, const int iconid, const frame_rect_t &ico, const text_info_t (&txt), FSTR_P caption) { + DWIN_ICON_Show(true, false, false, ICON, iconid + selected, ico.x, ico.y); + if (selected) DWINUI::Draw_Box(0, HMI_data.Highlight_Color, ico); + if (HMI_IsChinese()) { + DWIN_Frame_AreaCopy(1, txt.x, txt.y[selected], txt.x + txt.w - 1, txt.y[selected] + txt.h - 1, ico.x + (ico.w - txt.w) / 2, (ico.y + ico.h - 25) - txt.h/2); + } + else { + const uint16_t x = ico.x + (ico.w - strlen_P(FTOP(caption)) * DWINUI::fontWidth()) / 2, + y = (ico.y + ico.h - 20) - DWINUI::fontHeight() / 2; + DWINUI::Draw_String(x, y, caption); + } } // @@ -284,11 +322,8 @@ void ICON_Button(const bool here, const int iconid, const frame_rect_t &ico, con // void ICON_Print() { constexpr frame_rect_t ico = { 17, 110, 110, 100 }; - constexpr text_info_t txt[2] = { - { 1, { 417, 449 }, 30, 14 }, - { 1, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_PRINT, ICON_Print_0, ico, txt); + constexpr text_info_t txt = { 1, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_PRINT, ICON_Print_0, ico, txt, GET_TEXT_F(MSG_BUTTON_PRINT)); } // @@ -296,11 +331,8 @@ void ICON_Print() { // void ICON_Prepare() { constexpr frame_rect_t ico = { 145, 110, 110, 100 }; - constexpr text_info_t txt[2] = { - { 33, { 417, 449 }, 51, 14 }, - { 31, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_PREPARE, ICON_Prepare_0, ico, txt); + constexpr text_info_t txt = { 31, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_PREPARE, ICON_Prepare_0, ico, txt, GET_TEXT_F(MSG_PREPARE)); } // @@ -308,35 +340,17 @@ void ICON_Prepare() { // void ICON_Control() { constexpr frame_rect_t ico = { 17, 226, 110, 100 }; - constexpr text_info_t txt[2] = { - { 85, { 417, 449 }, 46, 14 }, - { 61, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_CONTROL, ICON_Control_0, ico, txt); -} - -// -// Main Menu: "Info" -// -void ICON_StartInfo() { - constexpr frame_rect_t ico = { 145, 226, 110, 100 }; - constexpr text_info_t txt[2] = { - { 133, { 417, 449 }, 23, 14 }, - { 91, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_INFO_LEVELING, ICON_Info_0, ico, txt); + constexpr text_info_t txt = { 61, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_CONTROL, ICON_Control_0, ico, txt, GET_TEXT_F(MSG_CONTROL)); } // -// Main Menu: "Level" +// Main Menu: "Advanced Settings" // -void ICON_Leveling() { +void ICON_AdvSettings() { constexpr frame_rect_t ico = { 145, 226, 110, 100 }; - constexpr text_info_t txt[2] = { - { 88, { 433, 464 }, 36, 14 }, - { 211, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_INFO_LEVELING, ICON_Leveling_0, ico, txt); + constexpr text_info_t txt = { 91, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_ADVANCE, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_ADVANCED)); } // @@ -344,11 +358,8 @@ void ICON_Leveling() { // void ICON_Tune() { constexpr frame_rect_t ico = { 8, 232, 80, 100 }; - constexpr text_info_t txt[2] = { - { 0, { 433, 464 }, 32, 14 }, - { 121, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_print.now == PRINT_SETUP, ICON_Setup_0, ico, txt); + constexpr text_info_t txt = { 121, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_print.now == PRINT_SETUP, ICON_Setup_0, ico, txt, GET_TEXT_F(MSG_TUNE)); } // @@ -356,11 +367,8 @@ void ICON_Tune() { // void ICON_Pause() { constexpr frame_rect_t ico = { 96, 232, 80, 100 }; - constexpr text_info_t txt[2] = { - { 157, { 417, 449 }, 39, 14 }, - { 181, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Pause_0, ico, txt); + constexpr text_info_t txt = { 181, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Pause_0, ico, txt, GET_TEXT_F(MSG_BUTTON_PAUSE)); } // @@ -368,11 +376,8 @@ void ICON_Pause() { // void ICON_Resume() { constexpr frame_rect_t ico = { 96, 232, 80, 100 }; - constexpr text_info_t txt[2] = { - { 33, { 433, 464 }, 53, 14 }, - { 1, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Continue_0, ico, txt); + constexpr text_info_t txt = { 1, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Continue_0, ico, txt, GET_TEXT_F(MSG_BUTTON_RESUME)); } // @@ -380,20 +385,13 @@ void ICON_Resume() { // void ICON_Stop() { constexpr frame_rect_t ico = { 184, 232, 80, 100 }; - constexpr text_info_t txt[2] = { - { 196, { 417, 449 }, 29, 14 }, - { 151, { 405, 447 }, 27, 12 } - }; - ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt); + constexpr text_info_t txt = { 151, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 12 }; + ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt, GET_TEXT_F(MSG_BUTTON_STOP)); } -void Draw_Menu_Cursor(const int8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Cursor_color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); -} - -void Erase_Menu_Cursor(const int8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); -} +//----------------------------------------------------------------------------- +// Drawing routines +//----------------------------------------------------------------------------- void Move_Highlight(const int8_t from, const int8_t newline) { Erase_Menu_Cursor(newline - from); @@ -402,7 +400,7 @@ void Move_Highlight(const int8_t from, const int8_t newline) { void Add_Menu_Line() { Move_Highlight(1, MROWS); - DWIN_Draw_Line(HMI_data.SplitLine_Color, 16, MBASE(MROWS + 1) - 20, 256, MBASE(MROWS + 1) - 19); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(MROWS + 1), 240); } void Scroll_Menu(const uint8_t dir) { @@ -421,98 +419,31 @@ void Erase_Menu_Text(const uint8_t line) { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); } -void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false) { - if (label) DWINUI::Draw_String(LBLX, MBASE(line) - 1, (char*)label); - if (icon) DWINUI::Draw_Icon(icon, 26, MBASE(line) - 3); - if (more) DWINUI::Draw_Icon(ICON_More, 226, MBASE(line) - 3); - DWIN_Draw_Line(HMI_data.SplitLine_Color, 16, MBASE(line) + 33, 256, MBASE(line) + 33); -} - -void Draw_Chkb_Line(const uint8_t line, const bool checked) { - DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 16, MBASE(line) - 1, checked); -} - -void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const uint16_t value=0) { - DWINUI::Draw_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); -} - -// The "Back" label is always on the first line -void Draw_Back_Label() { - if (HMI_IsChinese()) - DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); - else - DWIN_Frame_AreaCopy(1, 223, 179, 254, 189, LBLX, MBASE(0)); -} - // Draw "Back" line at the top void Draw_Back_First(const bool is_sel=true) { Draw_Menu_Line(0, ICON_Back); - Draw_Back_Label(); + if (HMI_IsChinese()) + DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); + else + DWINUI::Draw_String(LBLX, MBASE(0), GET_TEXT_F(MSG_BACK)); if (is_sel) Draw_Menu_Cursor(0); } -inline EncoderState get_encoder_state() { - static millis_t Encoder_ms = 0; - const millis_t ms = millis(); - if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; - const EncoderState state = Encoder_ReceiveAnalyze(); - if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; - return state; -} - -template -inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { - if (encoder_diffState == ENCODER_DIFF_CW) - valref += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - valref -= EncoderRate.encoderMoveValue; - return encoder_diffState == ENCODER_DIFF_ENTER; -} - -// -// Draw Popup Windows -// - -inline void Draw_Popup_Bkgd_60() { - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330); - DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330); -} - -inline void Draw_Popup_Bkgd_105() { - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 105, 258, 374); - DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 105, 258, 374); -} - -void Clear_Popup_Area() { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); -} - -void DWIN_Draw_Popup1(const uint8_t icon) { - DWINUI::ClearMenuArea(); - Draw_Popup_Bkgd_60(); - if (icon) DWINUI::Draw_Icon(icon, 101, 105); -} -void DWIN_Draw_Popup2(FSTR_P const fmsg2, uint8_t button) { - if (fmsg2) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 240, fmsg2); - if (button) DWINUI::Draw_Icon(button, 86, 280); -} - -void DWIN_Draw_Popup(const uint8_t icon, const char * const cmsg1, FSTR_P const fmsg2, uint8_t button) { - DWIN_Draw_Popup1(icon); - if (cmsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, cmsg1); - DWIN_Draw_Popup2(fmsg2, button); -} - -void DWIN_Draw_Popup(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2, uint8_t button) { - DWIN_Draw_Popup1(icon); - if (fmsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, fmsg1); - DWIN_Draw_Popup2(fmsg2, button); -} - -void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) { - HMI_SaveProcessID(WaitResponse); - DWIN_Draw_Popup(icon, fmsg1, fmsg2, ICON_Continue_E); // Button Continue - DWIN_UpdateLCD(); +//PopUps +void Popup_window_PauseOrStop() { + if (HMI_IsChinese()) { + DWINUI::ClearMenuArea(); + Draw_Popup_Bkgd(); + if (select_print.now == PRINT_PAUSE_RESUME) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); + else if (select_print.now == PRINT_STOP) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); + DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); + DWINUI::Draw_IconWB(ICON_Confirm_C, 26, 280); + DWINUI::Draw_IconWB(ICON_Cancel_C, 146, 280); + Draw_Select_Highlight(true); + DWIN_UpdateLCD(); + } + else + DWIN_Popup_ConfirmCancel(ICON_BLTouch, select_print.now == PRINT_PAUSE_RESUME ? GET_TEXT_F(MSG_PAUSE_PRINT) : GET_TEXT_F(MSG_STOP_PRINT)); } #if HAS_HOTEND @@ -521,107 +452,45 @@ void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fm if (HMI_IsChinese()) { HMI_SaveProcessID(WaitResponse); DWINUI::ClearMenuArea(); - Draw_Popup_Bkgd_60(); + Draw_Popup_Bkgd(); DWINUI::Draw_Icon(ICON_TempTooLow, 102, 105); DWIN_Frame_AreaCopy(1, 103, 371, 136, 386, 69, 240); DWIN_Frame_AreaCopy(1, 170, 371, 270, 386, 102, 240); - DWINUI::Draw_Icon(ICON_Confirm_C, 86, 280); + DWINUI::Draw_IconWB(ICON_Confirm_C, 86, 280); DWIN_UpdateLCD(); } else - DWIN_Popup_Confirm(ICON_TempTooLow, F("Nozzle is too cold"), F("Preheat the hotend")); + DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); } #endif -void Popup_Window_Resume() { - Clear_Popup_Area(); - Draw_Popup_Bkgd_105(); - if (HMI_IsChinese()) { - DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 135); - DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 192); - DWINUI::Draw_Icon(ICON_Cancel_C, 26, 307); - DWINUI::Draw_Icon(ICON_Continue_C, 146, 307); - } - else { - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 115, F("Continue Print")); - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 192, F("It looks like the last")); - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 212, F("file was interrupted.")); - DWINUI::Draw_Icon(ICON_Cancel_E, 26, 307); - DWINUI::Draw_Icon(ICON_Continue_E, 146, 307); - } -} - -void Draw_Select_Highlight(const bool sel) { - HMI_flag.select_flag = sel; - const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color, - c2 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color; - DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318); - DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319); - DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318); - DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319); -} - -void Popup_window_PauseOrStop() { - if (HMI_IsChinese()) { - DWINUI::ClearMenuArea(); - Draw_Popup_Bkgd_60(); - if (select_print.now == PRINT_PAUSE_RESUME) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); - else if (select_print.now == PRINT_STOP) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); - DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); - DWINUI::Draw_Icon(ICON_Confirm_C, 26, 280); - DWINUI::Draw_Icon(ICON_Cancel_C, 146, 280); - } - else { - DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), select_print.now == PRINT_PAUSE_RESUME ? GET_TEXT_F(MSG_PAUSE_PRINT) : GET_TEXT_F(MSG_STOP_PRINT)); - DWINUI::Draw_Icon(ICON_Confirm_E, 26, 280); - DWINUI::Draw_Icon(ICON_Cancel_E, 146, 280); - } - Draw_Select_Highlight(true); - DWIN_UpdateLCD(); -} - #if HAS_HOTEND || HAS_HEATED_BED void DWIN_Popup_Temperature(const bool toohigh) { - Clear_Popup_Area(); - Draw_Popup_Bkgd_105(); - if (toohigh) { - DWINUI::Draw_Icon(ICON_TempTooHigh, 102, 165); - if (HMI_IsChinese()) { + HMI_SaveProcessID(WaitResponse); + if (HMI_IsChinese()) { + DWINUI::ClearMenuArea(); + Draw_Popup_Bkgd(); + if (toohigh) { + DWINUI::Draw_Icon(ICON_TempTooHigh, 102, 165); DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285); DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } else { - DWINUI::Draw_String(HMI_data.PopupTxt_Color, 36, 300, F("Nozzle or Bed temperature")); - DWINUI::Draw_String(HMI_data.PopupTxt_Color, 92, 300, F("is too high")); - } - } - else { - DWINUI::Draw_Icon(ICON_TempTooLow, 102, 165); - if (HMI_IsChinese()) { + DWINUI::Draw_Icon(ICON_TempTooLow, 102, 165); DWIN_Frame_AreaCopy(1, 103, 371, 270, 386, 52, 285); DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } - else { - DWINUI::Draw_String(HMI_data.PopupTxt_Color, 36, 300, F("Nozzle or Bed temperature")); - DWINUI::Draw_String(HMI_data.PopupTxt_Color, 92, 300, F("is too low")); - } } + else DWIN_Show_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low"), BTN_Continue); } #endif // Draw status line -void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text, const bool center = true) { - DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - if (text) { - if (center) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text); - else DWINUI::Draw_String(color, 0, STATUS_Y + 2, text); - } - DWIN_UpdateLCD(); -} -void DWIN_DrawStatusLine(const char *text, const bool center = true) { - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, text, center); +void DWIN_DrawStatusLine(const char *text) { + DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); + if (text) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, text); } // Clear & reset status line @@ -642,17 +511,15 @@ void DWIN_CheckStatusMessage() { }; void DWIN_DrawStatusMessage() { - const uint8_t max_status_chars = DWIN_WIDTH / DWINUI::fontWidth(DWINUI::font); - #if ENABLED(STATUS_MESSAGE_SCROLLING) // Get the UTF8 character count of the string uint8_t slen = utf8_strlen(ui.status_message); // If the string fits the status line do not scroll it - if (slen <= max_status_chars) { + if (slen <= LCD_WIDTH) { if (hash_changed) { - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message); + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } } @@ -665,16 +532,16 @@ void DWIN_DrawStatusMessage() { const char *stat = MarlinUI::status_and_len(rlen); DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); DWINUI::MoveTo(0, STATUS_Y + 2); - DWINUI::Draw_String(stat, max_status_chars); + DWINUI::Draw_String(HMI_data.StatusTxt_Color, stat, LCD_WIDTH); // If the string doesn't completely fill the line... - if (rlen < max_status_chars) { - DWINUI::Draw_Char('.'); // Always at 1+ spaces left, draw a dot - uint8_t chars = max_status_chars - rlen; // Amount of space left in characters + if (rlen < LCD_WIDTH) { + DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); // Always at 1+ spaces left, draw a dot + uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters if (--chars) { // Draw a second dot if there's space - DWINUI::Draw_Char('.'); + DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); if (--chars) - DWINUI::Draw_String(ui.status_message, chars); // Print a second copy of the message + DWINUI::Draw_String(HMI_data.StatusTxt_Color, ui.status_message, chars); // Print a second copy of the message } } MarlinUI::advance_status_scroll(); @@ -683,8 +550,8 @@ void DWIN_DrawStatusMessage() { #else if (hash_changed) { - ui.status_message[max_status_chars] = 0; - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message); + ui.status_message[LCD_WIDTH] = 0; + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } @@ -693,19 +560,17 @@ void DWIN_DrawStatusMessage() { void Draw_Print_Labels() { if (HMI_IsChinese()) { - Title.FrameCopy(30, 1, 42, 14); // "Printing" DWIN_Frame_AreaCopy(1, 0, 72, 63, 86, 41, 173); // Printing Time DWIN_Frame_AreaCopy(1, 65, 72, 128, 86, 176, 173); // Remain } else { - Title.ShowCaption(GET_TEXT(MSG_PRINTING)); - DWINUI::Draw_String( 46, 173, F("Print Time")); - DWINUI::Draw_String(181, 173, F("Remain")); + DWINUI::Draw_String( 46, 173, GET_TEXT_F(MSG_INFO_PRINT_TIME)); + DWINUI::Draw_String(181, 173, GET_TEXT_F(MSG_REMAINING_TIME)); } } void Draw_Print_ProgressBar() { - DWINUI::Draw_Icon(ICON_Bar, 15, 93); + DWIN_ICON_Show(true, false, false, ICON, ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, HMI_data.Barfill_Color, 16 + _percent_done * 240 / 100, 93, 256, 113); DWINUI::Draw_Int(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 3, 117, 133, _percent_done); DWINUI::Draw_String(HMI_data.PercentTxt_Color, 142, 133, F("%")); @@ -725,36 +590,49 @@ void Draw_Print_ProgressRemain() { } void ICON_ResumeOrPause() { - if (printingIsPaused() || HMI_flag.pause_flag || HMI_flag.pause_action) - ICON_Resume(); - else - ICON_Pause(); + if (checkkey == PrintProcess) printingIsPaused() ? ICON_Resume() : ICON_Pause(); +} + +// Update filename on print +void DWIN_Print_Header(const char *text = nullptr) { + static char headertxt[31] = ""; // Print header text + if (text) { + const int8_t size = _MIN(30U, strlen_P(text)); + LOOP_L_N(i, size) headertxt[i] = text[i]; + headertxt[size] = '\0'; + } + if (checkkey == PrintProcess || checkkey == PrintDone) { + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 60, DWIN_WIDTH, 60+16); + DWINUI::Draw_CenteredString(60, headertxt); + } } void Draw_PrintProcess() { + if (HMI_IsChinese()) + Title.FrameCopy(30, 1, 42, 14); // "Printing" + else + Title.ShowCaption(GET_TEXT_F(MSG_PRINTING)); DWINUI::ClearMenuArea(); - Draw_Print_Labels(); - - ICON_Tune(); - ICON_ResumeOrPause(); - ICON_Stop(); - DWIN_Print_Header(sdprint ? card.longest_filename() : nullptr); - + Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); - Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); Draw_Print_ProgressRemain(); - - DWIN_UpdateLCD(); + ICON_Tune(); + ICON_ResumeOrPause(); + ICON_Stop(); } void Goto_PrintProcess() { - if (checkkey == PrintProcess) return; - checkkey = PrintProcess; - Draw_PrintProcess(); + if (checkkey == PrintProcess) + ICON_ResumeOrPause(); + else { + checkkey = PrintProcess; + Draw_PrintProcess(); + } + DWIN_UpdateLCD(); } void Draw_PrintDone() { @@ -762,42 +640,47 @@ void Draw_PrintDone() { _percent_done = 100; _remain_time = 0; + Title.ShowCaption(GET_TEXT_F(MSG_PRINT_DONE)); DWINUI::ClearMenuArea(); DWIN_Print_Header(nullptr); + Draw_Print_ProgressBar(); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); - Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); Draw_Print_ProgressRemain(); - // show print done confirm - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 240, DWIN_WIDTH - 1, STATUS_Y - 1); - DWINUI::Draw_Icon(HMI_IsChinese() ? ICON_Confirm_C : ICON_Confirm_E, 86, 283); + DWINUI::Draw_Button(BTN_Confirm, 86, 273); +} + +void Goto_PrintDone() { + wait_for_user = true; + if (checkkey != PrintDone) { + checkkey = PrintDone; + Draw_PrintDone(); + DWIN_UpdateLCD(); + } } void Draw_Main_Menu() { DWINUI::ClearMenuArea(); - if (HMI_IsChinese()) Title.FrameCopy(2, 2, 26, 13); // "Home" etc else Title.ShowCaption(MACHINE_NAME); - DWINUI::Draw_Icon(ICON_LOGO, 71, 52); // CREALITY logo - + DWIN_ResetStatusLine(); ICON_Print(); ICON_Prepare(); ICON_Control(); - TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); - DWIN_UpdateLCD(); + ICON_AdvSettings(); } void Goto_Main_Menu() { if (checkkey == MainMenu) return; checkkey = MainMenu; - ui.reset_status(true); Draw_Main_Menu(); + DWIN_UpdateLCD(); } // Draw X, Y, Z and blink if in an un-homed or un-trusted state @@ -813,11 +696,11 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, if (force || changed || draw_qmark || draw_empty) { if (blink && draw_qmark) - DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F("--?--")); + DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" - ? -")); else if (blink && draw_empty) - DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" ")); + DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" ")); else - DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 1, x, y, p); + DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 2, x, y, p); } } @@ -828,9 +711,9 @@ void _draw_xyz_position(const bool force) { if (force || blink != _blink) { _blink = blink; //SERIAL_ECHOPGM(" (blink)"); - _update_axis_value(X_AXIS, 35, 459, blink, true); - _update_axis_value(Y_AXIS, 120, 459, blink, true); - _update_axis_value(Z_AXIS, 205, 459, blink, true); + _update_axis_value(X_AXIS, 27, 459, blink, true); + _update_axis_value(Y_AXIS, 112, 459, blink, true); + _update_axis_value(Z_AXIS, 197, 459, blink, true); } //SERIAL_EOL(); } @@ -914,9 +797,21 @@ void update_variable() { static float _offset = 0; if (BABY_Z_VAR != _offset) { _offset = BABY_Z_VAR; - DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, _offset); + DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, _offset); } + #if HAS_MESH + static bool _leveling_active = false; + if (_leveling_active != planner.leveling_active) { + _leveling_active = planner.leveling_active; + DWIN_Draw_Box(1, HMI_data.Background_Color, 186, 416, 20, 20); + if (_leveling_active) + DWINUI::Draw_Icon(ICON_SetZOffset, 186, 416); + else + DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + } + #endif + _draw_xyz_position(false); } @@ -933,14 +828,15 @@ void update_variable() { #endif void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) { - char * const name = card.longest_filename(); - size_t pos = strlen(name); // index of ending nul + size_t pos = strlen(src); // index of ending nul // For files, remove the extension // which may be .gcode, .gco, or .g if (!card.flag.filenameIsDir) while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0) + if (!pos) pos = strlen(src); // pos = 0 ('.' not found) restore pos + size_t len = pos; // nul or '.' if (len > maxlen) { // Keep the name short pos = len = maxlen; // move nul down @@ -957,14 +853,6 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) void HMI_SDCardInit() { card.cdroot(); } -void MarlinUI::refresh() { /* Nothing to see here */ } - -#if HAS_LCD_BRIGHTNESS - void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } -#endif - -#define ICON_Folder ICON_More - #if ENABLED(SCROLL_LONG_FILENAMES) char shift_name[LONG_FILENAME_LENGTH + 1]; @@ -1014,7 +902,8 @@ void Draw_SDItem(const uint16_t item, int16_t row=-1) { // Draw the file/folder with name aligned left char str[strlen(name) + 1]; make_name_without_ext(str, name); - Draw_Menu_Line(row, card.flag.filenameIsDir ? ICON_Folder : ICON_File, str); + const uint8_t icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; + Draw_Menu_Line(row, icon, str); } #if ENABLED(SCROLL_LONG_FILENAMES) @@ -1057,7 +946,7 @@ void Redraw_SD_List() { } else { DWIN_Draw_Rectangle(1, HMI_data.AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); - DWINUI::Draw_CenteredString(font16x32, HMI_data.AlertTxt_Color, MBASE(3), F("No Media")); + DWINUI::Draw_CenteredString(font12x24, HMI_data.AlertTxt_Color, MBASE(3), GET_TEXT_F(MSG_MEDIA_NOT_INSERTED)); } } @@ -1083,21 +972,18 @@ void HMI_SDCardUpdate() { if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); //SERIAL_ECHOLNPGM("HMI_SDCardUpdate: ", DWIN_lcd_sd_status); - if (DWIN_lcd_sd_status) { + if (DWIN_lcd_sd_status) { // Media inserted if (checkkey == SelectFile) Redraw_SD_List(); } - else { + else { // Media removed // clean file icon if (checkkey == SelectFile) { Redraw_SD_List(); } else if (sdprint && card.isPrinting() && printingIsActive()) { - // TODO: Move card removed abort handling - // to CardReader::manage_media. - card.abortFilePrintSoon(); wait_for_heatup = wait_for_user = false; - dwin_abort_flag = true; // Reset feedrate, return to Home + HMI_flag.abort_flag = true; // Abort print } } DWIN_UpdateLCD(); @@ -1105,10 +991,10 @@ void HMI_SDCardUpdate() { } // -// The status area is always on-screen, except during -// full-screen modal dialogs. (TODO: Keep alive during dialogs) +// The Dashboard is always on-screen, except during +// full-screen modal dialogs. // -void Draw_Status_Area(const bool with_update) { +void DWIN_Draw_Dashboard() { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1); @@ -1140,10 +1026,10 @@ void Draw_Status_Area(const bool with_update) { #endif #if HAS_ZOFFSET_ITEM - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); #endif - DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, BABY_Z_VAR); + DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, BABY_Z_VAR); DWIN_Draw_Rectangle(1, HMI_data.SplitLine_Color, 0, 449, DWIN_WIDTH, 451); @@ -1152,47 +1038,35 @@ void Draw_Status_Area(const bool with_update) { DWINUI::Draw_Icon(ICON_MaxSpeedZ, 180, 456); _draw_xyz_position(true); - if (with_update) { - DWIN_UpdateLCD(); - delay(5); - } -} - -void HMI_StartFrame(const bool with_update) { - Goto_Main_Menu(); - DWIN_DrawStatusLine(nullptr); - Draw_Status_Area(with_update); } void Draw_Info_Menu() { DWINUI::ClearMenuArea(); Draw_Back_First(); - - DWINUI::Draw_CenteredString(122, F(MACHINE_SIZE)); - DWINUI::Draw_CenteredString(195, F(SHORT_BUILD_VERSION)); - - if (HMI_IsChinese()) { + if (HMI_IsChinese()) Title.FrameCopy(30, 17, 28, 13); // "Info" + else + Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); + if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102); // "Size" DWIN_Frame_AreaCopy(1, 1, 164, 56, 176, 108, 175); // "Firmware Version" DWIN_Frame_AreaCopy(1, 58, 164, 113, 176, 105, 248); // "Contact Details" + DWINUI::Draw_CenteredString(268, F(CORP_WEBSITE)); } else { - Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); - - DWIN_Frame_AreaCopy(1, 120, 150, 146, 161, 124, 102); // "Size" - DWIN_Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175); // "Firmware Version" - DWIN_Frame_AreaCopy(1, 1, 164, 96, 175, 89, 248); // "Contact details" + DWINUI::Draw_CenteredString(102, F("Size")); + DWINUI::Draw_CenteredString(175, F("Firmware version")); + DWINUI::Draw_CenteredString(248, F("Build Datetime")); + DWINUI::Draw_CenteredString(268, F(STRING_DISTRIBUTION_DATE)); } - DWINUI::Draw_CenteredString(268, F(CORP_WEBSITE)); + DWINUI::Draw_CenteredString(122, F(MACHINE_SIZE)); + DWINUI::Draw_CenteredString(195, F(SHORT_BUILD_VERSION)); LOOP_L_N(i, 3) { - DWINUI::Draw_Icon(ICON_PrintSize + i, 26, 99 + i * 73); + DWINUI::Draw_Icon(ICON_PrintSize + i, ICOX, 99 + i * 73); DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MBASE(2) + i * 73, 240); } - - DWIN_UpdateLCD(); } void Draw_Print_File_Menu() { @@ -1214,7 +1088,7 @@ void HMI_MainMenu() { case PAGE_PRINT: ICON_Print(); break; case PAGE_PREPARE: ICON_Print(); ICON_Prepare(); break; case PAGE_CONTROL: ICON_Prepare(); ICON_Control(); break; - case PAGE_INFO_LEVELING: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; + case PAGE_ADVANCE: ICON_Control(); ICON_AdvSettings(); break; } } } @@ -1223,8 +1097,8 @@ void HMI_MainMenu() { switch (select_page.now) { case PAGE_PRINT: ICON_Print(); ICON_Prepare(); break; case PAGE_PREPARE: ICON_Prepare(); ICON_Control(); break; - case PAGE_CONTROL: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; - case PAGE_INFO_LEVELING: TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; + case PAGE_CONTROL: ICON_Control(); ICON_AdvSettings(); break; + case PAGE_ADVANCE: ICON_AdvSettings(); break; } } } @@ -1232,21 +1106,13 @@ void HMI_MainMenu() { switch (select_page.now) { case PAGE_PRINT: checkkey = SelectFile; + card.mount(); + delay(300); Draw_Print_File_Menu(); break; - case PAGE_PREPARE: Draw_Prepare_Menu(); break; - case PAGE_CONTROL: Draw_Control_Menu(); break; - - case PAGE_INFO_LEVELING: - #if HAS_ONESTEP_LEVELING - queue.inject(F("G28Z\nG29")); // Force to get the current Z home position - #else - last_checkkey = MainMenu; - Goto_InfoMenu(); - #endif - break; + case PAGE_ADVANCE: Draw_AdvancedSettings_Menu(); break; } } DWIN_UpdateLCD(); @@ -1331,7 +1197,7 @@ void HMI_SelectFile() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (select_file.now == 0) { // Back select_page.set(PAGE_PRINT); - Goto_Main_Menu(); + return Goto_Main_Menu(); } else if (hasUpDir && select_file.now == 1) { // CD-Up SDCard_Up(); @@ -1355,16 +1221,10 @@ void HMI_SelectFile() { HMI_flag.heat_flag = true; HMI_flag.print_finish = false; - card.openAndPrintFile(card.filename); - - #if HAS_FAN - // All fans on for Ender 3 v2 ? - // The slicer should manage this for us. - //for (uint8_t i = 0; i < FAN_COUNT; i++) - // thermalManager.fan_speed[i] = 255; - #endif - - DWIN_Print_Started(true); + if (card.fileIsBinary()) + return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); + else + return Goto_ConfirmToPrint(); } } @@ -1372,6 +1232,16 @@ void HMI_SelectFile() { DWIN_UpdateLCD(); } +// Pause or Stop popup +void onClick_PauseOrStop() { + switch (select_print.now) { + case PRINT_PAUSE_RESUME: if (HMI_flag.select_flag) HMI_flag.pause_flag = true; break; // confirm pause + case PRINT_STOP: if (HMI_flag.select_flag) HMI_flag.abort_flag = true; break; // stop confirmed then abort print + default: break; + } + return Goto_PrintProcess(); +} + // Printing void HMI_Printing() { EncoderState encoder_diffState = get_encoder_state(); @@ -1399,106 +1269,23 @@ void HMI_Printing() { switch (select_print.now) { case PRINT_SETUP: Draw_Tune_Menu(); break; case PRINT_PAUSE_RESUME: - if (HMI_flag.pause_flag) { - ICON_Pause(); - #if DISABLED(ADVANCED_PAUSE_FEATURE) - char cmd[40]; - cmd[0] = '\0'; - #if BOTH(HAS_HEATED_BED, PAUSE_HEAT) - if (resume_bed_temp) sprintf_P(cmd, PSTR("M190 S%i\n"), resume_bed_temp); - #endif - #if BOTH(HAS_HOTEND, PAUSE_HEAT) - if (resume_hotend_temp) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), resume_hotend_temp); - #endif - #if HAS_FAN - if (resume_fan) thermalManager.fan_speed[0] = resume_fan; - #endif - strcat_P(cmd, M24_STR); - queue.inject(cmd); - #endif - } - else { - HMI_flag.select_flag = true; - checkkey = PauseOrStop; - Popup_window_PauseOrStop(); + if (printingIsPaused()) { // if printer is already in pause + ui.resume_print(); + break; } - break; - + else + return Goto_Popup(Popup_window_PauseOrStop, onClick_PauseOrStop); case PRINT_STOP: - HMI_flag.select_flag = true; - checkkey = PauseOrStop; - Popup_window_PauseOrStop(); - break; - + return Goto_Popup(Popup_window_PauseOrStop, onClick_PauseOrStop); default: break; } } DWIN_UpdateLCD(); } -// Print done -void HMI_PrintDone() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - dwin_abort_flag = true; // Reset feedrate, return to Home - Goto_Main_Menu(); // Return to Main menu after print done - } -} - -// Pause or Stop popup -void HMI_PauseOrStop() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - - if (encoder_diffState == ENCODER_DIFF_CW) - Draw_Select_Highlight(false); - else if (encoder_diffState == ENCODER_DIFF_CCW) - Draw_Select_Highlight(true); - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (select_print.now == PRINT_PAUSE_RESUME) { - if (HMI_flag.select_flag) { - HMI_flag.pause_action = true; - ICON_Resume(); - queue.inject(F("M25")); - } - else { - // cancel pause - } - Goto_PrintProcess(); - } - else if (select_print.now == PRINT_STOP) { - if (HMI_flag.select_flag) { - checkkey = MainMenu; - if (HMI_flag.home_flag) planner.synchronize(); // Wait for planner moves to finish! - wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user - card.abortFilePrintSoon(); // Let the main loop handle SD abort - dwin_abort_flag = true; // Reset feedrate, return to Home - #ifdef ACTION_ON_CANCEL - hostui.cancel(); - #endif - DWIN_Draw_Popup(ICON_BLTouch, F("Stopping...") , F("Please wait until done.")); - } - else - Goto_PrintProcess(); // cancel stop - } - } - DWIN_UpdateLCD(); -} - #include "../../../libs/buzzer.h" -void HMI_AudioFeedback(const bool success/*=true*/) { - #if HAS_BUZZER - if (success) { - BUZZ(100, 659); - BUZZ(10, 0); - BUZZ(100, 698); - } - else - BUZZ(40, 440); - #endif -} +void HMI_AudioFeedback(const bool success/*=true*/) { DONE_BUZZ(success); } void Draw_Main_Area() { switch (checkkey) { @@ -1506,11 +1293,10 @@ void Draw_Main_Area() { case SelectFile: Draw_Print_File_Menu(); break; case PrintProcess: Draw_PrintProcess(); break; case PrintDone: Draw_PrintDone(); break; - case Info: Draw_Info_Menu(); break; - case PauseOrStop: Popup_window_PauseOrStop(); break; - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case FilamentPurge: Draw_Popup_FilamentPurge(); break; + #if HAS_ESDIAG + case ESDiagProcess: Draw_EndStopDiag(); break; #endif + case Popup: popupDraw(); break; case Locked: lockScreen.draw(); break; case Menu: case SetInt: @@ -1524,38 +1310,43 @@ void Draw_Main_Area() { void HMI_ReturnScreen() { checkkey = last_checkkey; + wait_for_user = false; Draw_Main_Area(); - return; } -void HMI_Popup() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - wait_for_user = false; - HMI_ReturnScreen(); +void HMI_WaitForUser() { + get_encoder_state(); + if (!wait_for_user) { + switch (checkkey) { + case PrintDone: + select_page.reset(); + Goto_Main_Menu(); + break; + #if HAS_ONESTEP_LEVELING + case Leveling: + //TERN_(ProUI, ProEx.StopLeveling()); + HMI_ReturnScreen(); + break; + #endif + default: + HMI_ReturnScreen(); + break; + } } } void HMI_Init() { - HMI_SDCardInit(); - + DWINUI::Draw_Box(1, Color_Black, {5, 220, DWIN_WIDTH-5, DWINUI::fontHeight()}); + DWINUI::Draw_CenteredString(Color_White, 220, F("Professional Firmware ")); for (uint16_t t = 0; t <= 100; t += 2) { DWINUI::Draw_Icon(ICON_Bar, 15, 260); DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 15 + t * 242 / 100, 260, 257, 280); DWIN_UpdateLCD(); delay(20); } - HMI_SetLanguage(); } -void DWIN_Update() { - EachMomentUpdate(); // Status update - HMI_SDCardUpdate(); // SD card update - DWIN_HandleScreen(); // Rotary encoder update -} - void EachMomentUpdate() { static millis_t next_var_update_ms = 0, next_rts_update_ms = 0, next_status_update_ms = 0; @@ -1563,6 +1354,15 @@ void EachMomentUpdate() { if (ELAPSED(ms, next_var_update_ms)) { next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL; update_variable(); + switch (checkkey) { + #if HAS_ESDIAG + case ESDiagProcess: + ESDiag.Update(); + break; + #endif + default: + break; + } } if (ELAPSED(ms, next_status_update_ms)) { @@ -1573,52 +1373,45 @@ void EachMomentUpdate() { if (PENDING(ms, next_rts_update_ms)) return; next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL; - if (checkkey == PrintProcess) { + if (checkkey == PrintProcess) { // print process + + // Print pause + if (HMI_flag.pause_flag && !HMI_flag.home_flag) { + HMI_flag.pause_flag = false; + if (!HMI_flag.pause_action) { + HMI_flag.pause_action = true; + return ui.pause_print(); + } + } + // if print done - if (HMI_flag.print_finish) { + if (HMI_flag.print_finish && !HMI_flag.home_flag) { HMI_flag.print_finish = false; - TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); - planner.finish_and_disable(); - checkkey = PrintDone; - Draw_PrintDone(); - } - else if (HMI_flag.pause_flag != printingIsPaused()) { - // print status update - HMI_flag.pause_flag = printingIsPaused(); - ICON_ResumeOrPause(); + return DWIN_Print_Finished(); } - } - - // pause after homing - if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) { - HMI_flag.pause_action = false; - #if ENABLED(PAUSE_HEAT) - TERN_(HAS_HOTEND, resume_hotend_temp = sdprint ? thermalManager.degTargetHotend(0) : thermalManager.wholeDegHotend(0)); - TERN_(HAS_HEATED_BED, resume_bed_temp = sdprint ? thermalManager.degTargetBed() : thermalManager.wholeDegBed()); - TERN_(HAS_FAN, resume_fan = thermalManager.fan_speed[0]); - #endif - IF_DISABLED(ADVANCED_PAUSE_FEATURE, thermalManager.disable_all_heaters()); - IF_DISABLED(PARK_HEAD_ON_PAUSE, queue.inject(F("G1 F1200 X0 Y0"))); - } - if (checkkey == PrintProcess) { // print process + // if print was aborted + if (HMI_flag.abort_flag && !HMI_flag.home_flag) { // Print Stop + HMI_flag.abort_flag = false; + if (!HMI_flag.abort_action) { + HMI_flag.abort_action = true; + ui.abort_print(); + return Goto_PrintDone(); + } + } duration_t elapsed = print_job_timer.duration(); // print timer if (sdprint && card.isPrinting()) { uint8_t percentDone = card.percentDone(); - static uint8_t last_percentValue = 101; - if (last_percentValue != percentDone) { // print percent - last_percentValue = percentDone; - if (percentDone) { + if (_percent_done != percentDone) { // print percent _percent_done = percentDone; Draw_Print_ProgressBar(); } - } // Estimate remaining time every 20 seconds static millis_t next_remain_time_update = 0; - if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) { + if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag && !HMI_flag.remain_flag) { _remain_time = (elapsed.value - dwin_heat_time) / (_percent_done * 0.01f) - (elapsed.value - dwin_heat_time); next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; Draw_Print_ProgressRemain(); @@ -1634,69 +1427,63 @@ void EachMomentUpdate() { } } - else if (dwin_abort_flag && !HMI_flag.home_flag) { // Print Stop - dwin_abort_flag = false; - dwin_zoffset = BABY_Z_VAR; - select_page.set(PAGE_PRINT); - Goto_Main_Menu(); - } #if ENABLED(POWER_LOSS_RECOVERY) else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off - static bool recovery_flag = false; - - recovery.dwin_flag = false; - recovery_flag = true; - - auto update_selection = [&](const bool sel) { - HMI_flag.select_flag = sel; - const uint16_t c1 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color; - DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345); - DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346); - const uint16_t c2 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color; - DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345); - DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346); - }; - - Popup_Window_Resume(); - update_selection(true); - - // TODO: Get the name of the current file from someplace - // - //(void)recovery.interrupted_file_exists(); - SdFile *dir = nullptr; - const char * const filename = card.diveToFile(true, dir, recovery.info.sd_filename); - card.selectFileByName(filename); - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 252, card.longest_filename()); - DWIN_UpdateLCD(); + return Goto_PowerLossRecovery(); + } + #endif // POWER_LOSS_RECOVERY - while (recovery_flag) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_ENTER) { - recovery_flag = false; - if (HMI_flag.select_flag) break; - TERN_(POWER_LOSS_RECOVERY, queue.inject(F("M1000C"))); - return HMI_StartFrame(true); - } - else - update_selection(encoder_diffState == ENCODER_DIFF_CW); - - DWIN_UpdateLCD(); - } - watchdog_refresh(); - } + DWIN_UpdateLCD(); +} +#if ENABLED(POWER_LOSS_RECOVERY) + void Popup_PowerLossRecovery() { + DWINUI::ClearMenuArea(); + Draw_Popup_Bkgd(); + if (HMI_IsChinese()) { + DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 115); + DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 167); + DWINUI::Draw_IconWB(ICON_Cancel_C, 26, 280); + DWINUI::Draw_IconWB(ICON_Continue_C, 146, 280); + } + else { + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 70, GET_TEXT_F(MSG_OUTAGE_RECOVERY)); + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 147, F("It looks like the last")); + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 167, F("file was interrupted.")); + DWINUI::Draw_Button(BTN_Cancel, 26, 280); + DWINUI::Draw_Button(BTN_Continue, 146, 280); + } + SdFile *dir = nullptr; + const char * const filename = card.diveToFile(true, dir, recovery.info.sd_filename); + card.selectFileByName(filename); + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 207, card.longest_filename()); + Draw_Select_Highlight(HMI_flag.select_flag); + DWIN_UpdateLCD(); + } + + void onClick_PowerLossRecovery() { + if (HMI_flag.select_flag) { + queue.inject(F("M1000C")); + select_page.reset(); + return Goto_Main_Menu(); + } + else { select_print.set(PRINT_SETUP); queue.inject(F("M1000")); sdprint = true; - Goto_PrintProcess(); - Draw_Status_Area(true); + return Goto_PrintProcess(); } - #endif // POWER_LOSS_RECOVERY + } + + void Goto_PowerLossRecovery() { + recovery.dwin_flag = false; + LCD_MESSAGE_F(GET_TEXT_F(MSG_CONTINUE_PRINT_JOB)); + Goto_Popup(Popup_PowerLossRecovery, onClick_PowerLossRecovery); + } + +#endif // POWER_LOSS_RECOVERY - DWIN_UpdateLCD(); -} void DWIN_HandleScreen() { switch (checkkey) { @@ -1708,68 +1495,75 @@ void DWIN_HandleScreen() { case SetFloat: HMI_SetFloat(); break; case SetPFloat: HMI_SetPFloat(); break; case SelectFile: HMI_SelectFile(); break; - case Homing: break; - case Leveling: break; case PrintProcess: HMI_Printing(); break; - case PrintDone: HMI_PrintDone(); break; - case PauseOrStop: HMI_PauseOrStop(); break; - case Info: HMI_Popup(); break; - case WaitResponse: HMI_Popup(); break; - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case FilamentPurge: HMI_FilamentPurge(); break; - #endif - case NothingToDo: break; + case Popup: HMI_Popup(); break; + case Leveling: //TERN_(ProUI, HMI_WaitForUser()); + break; case Locked: HMI_LockScreen(); break; + case PrintDone: + TERN_(HAS_ESDIAG, case ESDiagProcess:) + case WaitResponse: HMI_WaitForUser(); break; + case Homing: + case PidProcess: + case NothingToDo: break; default: break; } } +bool IDisPopUp() { // If ID is popup... + return (checkkey == NothingToDo) + || (checkkey == WaitResponse) + || (checkkey == Homing) + || (checkkey == Leveling) + || (checkkey == PidProcess) + || TERN0(HAS_ESDIAG, (checkkey == ESDiagProcess)) + || (checkkey == Popup); +} + void HMI_SaveProcessID(const uint8_t id) { if (checkkey != id) { - if ((checkkey != NothingToDo) && - (checkkey != WaitResponse) && - (checkkey != Homing) && - (checkkey != Leveling) && - (checkkey != PauseOrStop) && - (checkkey != FilamentPurge)) last_checkkey = checkkey; // if not a popup + if (!IDisPopUp()) last_checkkey = checkkey; // if previous is not a popup + if ((id == Popup) + || TERN0(HAS_ESDIAG, (id == ESDiagProcess)) + || (id == PrintDone) + || (id == Leveling) + || (id == WaitResponse)) wait_for_user = true; checkkey = id; } } -void DWIN_StartHoming() { +void DWIN_HomingStart() { HMI_flag.home_flag = true; HMI_SaveProcessID(Homing); - Title.ShowCaption(F("Axis Homing")); - DWIN_Draw_Popup(ICON_BLTouch, F("Axis Homing"), F("Please wait until done.")); + Title.ShowCaption(GET_TEXT_F(MSG_HOMING)); + DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT)); } -void DWIN_CompletedHoming() { +void DWIN_HomingDone() { HMI_flag.home_flag = false; dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); - if (dwin_abort_flag) { - planner.finish_and_disable(); - } - HMI_ReturnScreen(); + if (HMI_flag.abort_action) DWIN_Print_Aborted(); else HMI_ReturnScreen(); } -void DWIN_MeshLevelingStart() { +void DWIN_LevelingStart() { #if HAS_ONESTEP_LEVELING HMI_SaveProcessID(Leveling); - Title.ShowCaption(F("Bed Leveling")); - DWIN_Draw_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), F("Please wait until done.")); + Title.ShowCaption(GET_TEXT_F(MSG_BED_LEVELING)); + DWIN_Show_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT)); #elif ENABLED(MESH_BED_LEVELING) Draw_ManualMesh_Menu(); #endif } -void DWIN_CompletedLeveling() { TERN_(HAS_MESH, DWIN_MeshViewer()); } +void DWIN_LevelingDone() { + TERN_(HAS_ONESTEP_LEVELING, if (planner.leveling_active) Goto_MeshViewer()); +} #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { char msg[33] = ""; char str_1[6] = ""; - sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), xpos, ypos, - dtostrf(zval, 1, 2, str_1)); + sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), xpos, ypos, dtostrf(zval, 1, 2, str_1)); ui.set_status(msg); } #endif @@ -1807,66 +1601,63 @@ void DWIN_PidTuning(pidresult_t result) { } } -// Update filename on print -void DWIN_Print_Header(const char *text = nullptr) { - static char headertxt[31] = ""; // Print header text - - if (text != nullptr) { - const int8_t size = _MIN((unsigned) 30, strlen_P(text)); - LOOP_L_N(i, size) headertxt[i] = text[i]; - headertxt[size] = '\0'; - } - if (checkkey == PrintProcess || checkkey == PrintDone) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 60, DWIN_WIDTH, 60+16); - DWINUI::Draw_CenteredString(60, headertxt); - } -} - -void Draw_Title(TitleClass* title) { - DWIN_Draw_Rectangle(1, HMI_data.TitleBg_color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); - if (title->frameid) - DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1); - else - DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); -} - -void Draw_Menu(MenuClass* menu) { - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); - DWIN_Draw_Rectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); - DWIN_ResetStatusLine(); -} - -// Startup routines -void DWIN_Startup() { - DWINUI::init(); - DWINUI::onCursorDraw = Draw_Menu_Cursor; - DWINUI::onCursorErase = Erase_Menu_Cursor; - DWINUI::onTitleDraw = Draw_Title; - DWINUI::onMenuDraw = Draw_Menu; - HMI_SetLanguage(); -} - // Started a Print Job void DWIN_Print_Started(const bool sd) { - sdprint = card.isPrinting() || sd; + sdprint = IS_SD_PRINTING() || sd; _percent_done = 0; _remain_time = 0; + HMI_flag.remain_flag = false; + HMI_flag.pause_flag = false; + HMI_flag.pause_action = false; + HMI_flag.abort_flag = false; + HMI_flag.abort_action = false; HMI_flag.print_finish = false; Goto_PrintProcess(); } +// Pause a print job +void DWIN_Print_Pause() { + ICON_ResumeOrPause(); +} + +// Resume print job +void DWIN_Print_Resume() { + HMI_flag.pause_action = false; + ICON_ResumeOrPause(); + if (printJobOngoing()) { + LCD_MESSAGE(MSG_RESUME_PRINT); + Goto_PrintProcess(); + } +} + // Ended print job void DWIN_Print_Finished() { - if (checkkey == PrintProcess || printingIsActive()) { + if (HMI_flag.abort_flag || checkkey == PrintDone) return; + TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel()); + HMI_flag.pause_flag = false; + wait_for_heatup = false; + planner.finish_and_disable(); thermalManager.cooldown(); - HMI_flag.print_finish = true; - } + Goto_PrintDone(); +} + +// Print was aborted +void DWIN_Print_Aborted() { + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Print_Aborted")); + HMI_flag.abort_action = false; + wait_for_heatup = false; + planner.finish_and_disable(); + thermalManager.cooldown(); + Goto_PrintDone(); } // Progress Bar update void DWIN_Progress_Update() { if (parser.seenval('P')) _percent_done = parser.byteval('P'); - if (parser.seenval('R')) _remain_time = parser.ulongval('R') * 60; + if (parser.seenval('R')) { + _remain_time = parser.ulongval('R') * 60; + HMI_flag.remain_flag = true; + } if (checkkey == PrintProcess) { Draw_Print_ProgressBar(); Draw_Print_ProgressRemain(); @@ -1902,11 +1693,18 @@ void DWIN_SetColorDefaults() { void DWIN_SetDataDefaults() { DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); - TERN_(HAS_HOTEND, HMI_data.HotendPidT = PREHEAT_1_TEMP_HOTEND); - TERN_(HAS_HEATED_BED, HMI_data.BedPidT = PREHEAT_1_TEMP_BED); - TERN_(HAS_HOTEND, HMI_data.PidCycles = 5); - TERN_(PREVENT_COLD_EXTRUSION, HMI_data.ExtMinT = EXTRUDE_MINTEMP); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + TERN_(HAS_HOTEND, HMI_data.HotendPidT = PREHEAT_1_TEMP_HOTEND); + TERN_(HAS_HEATED_BED, HMI_data.BedPidT = PREHEAT_1_TEMP_BED); + TERN_(HAS_HOTEND, HMI_data.PidCycles = 5); + #if ENABLED(PREVENT_COLD_EXTRUSION) + HMI_data.ExtMinT = EXTRUDE_MINTEMP; + ApplyExtMinT(); + #endif + #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + HMI_data.BedLevT = PREHEAT_1_TEMP_BED; + #endif + TERN_(BAUD_RATE_GCODE, SetBaud250K()); } void DWIN_StoreSettings(char *buff) { @@ -1914,83 +1712,117 @@ void DWIN_StoreSettings(char *buff) { } void DWIN_LoadSettings(const char *buff) { - memcpy(&HMI_data, buff, _MIN(sizeof(HMI_data), eeprom_data_size)); + // (void *)-> Avoid Warning when save data different from uintX_t in HMI_data_t struct + memcpy((void *)&HMI_data, buff, _MIN(sizeof(HMI_data), eeprom_data_size)); dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); if (HMI_data.Text_Color == HMI_data.Background_Color) DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT()); feedrate_percentage = 100; + TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate()); + #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + // Apply Case light brightness + caselight.brightness = HMI_data.CaseLight_Brightness; + caselight.update_brightness(); + #endif + #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + // Apply Led Color + leds.set_color(HMI_data.Led_Color); + #endif +} + +// Initialize or re-initialize the LCD +void MarlinUI::init_lcd() { + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Startup")); + DWINUI::init(); + DWIN_JPG_CacheTo1(Language_English); + Encoder_Configuration(); +} + +void DWIN_InitScreen() { + HMI_Init(); // draws boot screen + DWINUI::onCursorDraw = Draw_Menu_Cursor; + DWINUI::onCursorErase = Erase_Menu_Cursor; + DWINUI::onTitleDraw = Draw_Title; + DWINUI::onMenuDraw = Draw_Menu; + DWIN_DrawStatusLine(nullptr); + DWIN_Draw_Dashboard(); + Goto_Main_Menu(); +} + +void MarlinUI::update() { + EachMomentUpdate(); // Status update + HMI_SDCardUpdate(); // SD card update + DWIN_HandleScreen(); // Rotary encoder update } +void MarlinUI::refresh() { /* Nothing to see here */ } + +#if HAS_LCD_BRIGHTNESS + void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } +#endif + void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) { - DWIN_Draw_Popup(ICON_BLTouch, lcd_error, lcd_component); + DWIN_Draw_Popup(ICON_BLTouch, F("Printer killed:"), lcd_error); + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 270, F("Turn off the printer")); DWIN_UpdateLCD(); } void DWIN_RebootScreen() { DWIN_Frame_Clear(Color_Bg_Black); - DWINUI::Draw_Icon(ICON_LOGO, 71, 150); // CREALITY logo - DWINUI::Draw_CenteredString(Color_White, 200, F("Please wait until reboot.")); + DWIN_JPG_ShowAndCache(0); + DWINUI::Draw_CenteredString(Color_White, 220, GET_TEXT_F(MSG_PLEASE_WAIT_REBOOT)); DWIN_UpdateLCD(); delay(500); } void DWIN_Redraw_screen() { Draw_Main_Area(); - Draw_Status_Area(false); + hash_changed = true; + DWIN_DrawStatusMessage(); + DWIN_Draw_Dashboard(); } #if ENABLED(ADVANCED_PAUSE_FEATURE) - - void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button = 0) { + void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button /*= 0*/) { HMI_SaveProcessID(button ? WaitResponse : NothingToDo); - DWIN_Draw_Popup(ICON_BLTouch, F("Advanced Pause"), fmsg, button); - ui.reset_status(true); + DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), fmsg, button); } void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) { + //if (mode == PAUSE_MODE_SAME) return; + pause_mode = mode; switch (message) { - case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; - case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; - case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; - case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), ICON_Continue_E); break; - case PAUSE_MESSAGE_INSERT: DWIN_Popup_Continue(ICON_BLTouch, F("Advanced Pause"), GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; + case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 + case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) + case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break; + case PAUSE_MESSAGE_INSERT: DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; - case PAUSE_MESSAGE_PURGE: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)); break; - case PAUSE_MESSAGE_OPTION: DWIN_Popup_FilamentPurge(); break; + case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 + case PAUSE_MESSAGE_PURGE: + #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) + DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_CONT_PURGE)); + #else + DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)); + #endif + break; + case PAUSE_MESSAGE_OPTION: Goto_FilamentPurge(); break; case PAUSE_MESSAGE_RESUME: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break; - case PAUSE_MESSAGE_HEAT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), ICON_Continue_E); break; + case PAUSE_MESSAGE_HEAT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), BTN_Continue); break; case PAUSE_MESSAGE_HEATING: LCD_MESSAGE(MSG_FILAMENT_CHANGE_HEATING); break; - case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; + case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; // Exit from Pause, Load and Unload default: break; } } void Draw_Popup_FilamentPurge() { - DWIN_Draw_Popup(ICON_BLTouch, F("Advanced Pause"), F("Purge or Continue?")); - DWINUI::Draw_Icon(ICON_Confirm_E, 26, 280); - DWINUI::Draw_Icon(ICON_Continue_E, 146, 280); + DWIN_Draw_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), F("Purge or Continue?")); + DWINUI::Draw_Button(BTN_Confirm, 26, 280); + DWINUI::Draw_Button(BTN_Continue, 146, 280); Draw_Select_Highlight(true); - DWIN_UpdateLCD(); - } - - // Handle responses such as: - // - Purge More, Continue - // - General "Continue" response - void DWIN_Popup_FilamentPurge() { - HMI_SaveProcessID(FilamentPurge); - pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; - Draw_Popup_FilamentPurge(); } - void HMI_FilamentPurge() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) - Draw_Select_Highlight(false); - else if (encoder_diffState == ENCODER_DIFF_CCW) - Draw_Select_Highlight(true); - else if (encoder_diffState == ENCODER_DIFF_ENTER) { + void onClick_FilamentPurge() { if (HMI_flag.select_flag) pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button else { @@ -1998,7 +1830,10 @@ void DWIN_Redraw_screen() { pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button } } - DWIN_UpdateLCD(); + + void Goto_FilamentPurge() { + pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; + Goto_Popup(Draw_Popup_FilamentPurge, onClick_FilamentPurge); } #endif // ADVANCED_PAUSE_FEATURE @@ -2006,122 +1841,54 @@ void DWIN_Redraw_screen() { #if HAS_MESH void DWIN_MeshViewer() { if (!leveling_is_valid()) - DWIN_Popup_Continue(ICON_BLTouch, F("Mesh viewer"), F("No valid mesh")); + DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_MESH_VIEWER), GET_TEXT_F(MSG_NO_VALID_MESH)); else { HMI_SaveProcessID(WaitResponse); MeshViewer.Draw(); } } -#endif +#endif // HAS_MESH + +void DWIN_LockScreen() { + if (checkkey != Locked) { + lockScreen.rprocess = checkkey; + checkkey = Locked; + lockScreen.init(); + } +} + +void DWIN_UnLockScreen() { + if (checkkey == Locked) { + checkkey = lockScreen.rprocess; + Draw_Main_Area(); + } +} void HMI_LockScreen() { EncoderState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; lockScreen.onEncoder(encoder_diffState); - if (lockScreen.isUnlocked()) { - if (CurrentMenu == AdvancedSettings) - Draw_AdvancedSettings_Menu(); - else - Draw_Tune_Menu(); - } + if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); } -void DWIN_LockScreen(const bool flag) { - HMI_flag.lock_flag = flag; - checkkey = Locked; - lockScreen.init(); + +void Goto_ConfirmToPrint() { + card.openAndPrintFile(card.filename); + DWIN_Print_Started(true); } -// -// NEW MENU SUBSYSTEM ========================================================= -// +#if HAS_ESDIAG + void Draw_EndStopDiag() { + HMI_SaveProcessID(ESDiagProcess); + ESDiag.Draw(); + } +#endif -// On click functions - -// Generic onclick event without draw anything -// process: process id HMI destiny -// lo: low limit -// hi: high limit -// dp: decimal places, 0 for integers -// val: value / scaled value -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - checkkey = process; - HMI_value.MinValue = lo; - HMI_value.MaxValue = hi; - HMI_value.dp = dp; - HMI_value.Apply = Apply; - HMI_value.LiveUpdate = LiveUpdate; - HMI_value.Value = val; - EncoderRate.enabled = true; -} - -// Generic onclick event for integer values -// process: process id HMI destiny -// lo: scaled low limit -// hi: scaled high limit -// val: value -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate); - Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, HMI_value.Value); -} - -// Generic onclick event for float values -// process: process id HMI destiny -// lo: scaled low limit -// hi: scaled high limit -// val: value -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - const int32_t value = round(val * POW(10, dp)); - SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val); -} - -// Generic onclick event for integer values -// lo: scaled low limit -// hi: scaled high limit -// val: value -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -inline void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - SetValueOnClick(SetInt, lo, hi, val, Apply, LiveUpdate); -} - -// Generic onclick event for set pointer to 16 bit uinteger values -// lo: low limit -// hi: high limit -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - HMI_value.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; - const int32_t value = *HMI_value.P_Int; - SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate); -} - -// Generic onclick event for float values -// process: process id HMI destiny -// lo: low limit -// hi: high limit -// dp: decimal places -// val: value -inline void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - SetValueOnClick(SetFloat, lo, hi, dp, val, Apply, LiveUpdate); -} - -// Generic onclick event for set pointer to float values -// lo: low limit -// hi: high limit -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - SetValueOnClick(SetPFloat, lo, hi, dp, *HMI_value.P_Float, Apply, LiveUpdate); -} +//============================================================================= +// NEW MENU SUBSYSTEM +//============================================================================= + +// Tool functions #if ENABLED(EEPROM_SETTINGS) void WriteEeprom() { @@ -2144,22 +1911,34 @@ void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)( // Reset Printer void RebootPrinter() { - dwin_abort_flag = true; wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user thermalManager.disable_all_heaters(); planner.finish_and_disable(); DWIN_RebootScreen(); - HAL_reboot(); + hal.reboot(); } -void Goto_InfoMenu(){ - checkkey = Info; +void Goto_Info_Menu(){ Draw_Info_Menu(); + HMI_SaveProcessID(WaitResponse); +} + +void Goto_Move_Menu() { + #if HAS_HOTEND + gcode.process_subcommands_now(F("G92E0")); // reset extruder position + planner.synchronize(); + #endif + Draw_Move_Menu(); } void DisableMotors() { queue.inject(F("M84")); } +void AutoLev() { queue.inject(F("G28XYO\nG28Z\nG29")); } // Force to get the current Z home position + void AutoHome() { queue.inject_P(G28_STR); } +void HomeX() { queue.inject(F("G28X")); } +void HomeY() { queue.inject(F("G28Y")); } +void HomeZ() { queue.inject(F("G28Z")); } void SetHome() { // Apply workspace offset, making the current position 0,0,0 @@ -2172,7 +1951,7 @@ void SetHome() { void ApplyZOffset() { TERN_(EEPROM_SETTINGS, settings.save()); } void LiveZOffset() { last_zoffset = dwin_zoffset; - dwin_zoffset = HMI_value.Value / 100.0f; + dwin_zoffset = MenuData.Value / 100.0f; #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) if (BABYSTEP_ALLOWED()) babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset); #endif @@ -2182,6 +1961,24 @@ void SetHome() { SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); } #endif + + void SetMoveZto0() { + char cmd[48] = ""; + char str_1[5] = "", str_2[5] = ""; + sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300"), + #if ENABLED(MESH_BED_LEVELING) + dtostrf(0, 1, 1, str_1), + dtostrf(0, 1, 1, str_2) + #else + dtostrf(X_CENTER, 1, 1, str_1), + dtostrf(Y_CENTER, 1, 1, str_2) + #endif + ); + gcode.process_subcommands_now(cmd); + planner.synchronize(); + LCD_MESSAGE_F("Now adjust Z Offset"); + HMI_AudioFeedback(true); + } #endif #if HAS_PREHEAT @@ -2199,14 +1996,14 @@ void SetLanguage() { } void LiveMove() { - *HMI_value.P_Float = HMI_value.Value / MINUNITMULT; + *MenuData.P_Float = MenuData.Value / MINUNITMULT; if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, homing_feedrate(HMI_value.axis)); } } void ApplyMoveE() { - last_E = HMI_value.Value / MINUNITMULT; + last_E = MenuData.Value / MINUNITMULT; if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E)); @@ -2219,33 +2016,13 @@ void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS #if HAS_HOTEND void SetMoveE() { #if ENABLED(PREVENT_COLD_EXTRUSION) - if (thermalManager.tooColdToExtrude(0)) { - Popup_Window_ETempTooLow(); - return; - } + if (thermalManager.tooColdToExtrude(0)) + return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); #endif SetPFloatOnClick(last_E - (EXTRUDE_MAXLENGTH), last_E + (EXTRUDE_MAXLENGTH), UNITFDIGITS, ApplyMoveE); } #endif -void SetMoveZto0() { - char cmd[48] = ""; - char str_1[5] = "", str_2[5] = ""; - sprintf_P(cmd, PSTR("G28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300"), - #if ENABLED(MESH_BED_LEVELING) - dtostrf(0, 1, 1, str_1), - dtostrf(0, 1, 1, str_2) - #else - dtostrf(X_CENTER, 1, 1, str_1), - dtostrf(Y_CENTER, 1, 1, str_2) - #endif - ); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - LCD_MESSAGE_F("Now adjust Z Offset"); - HMI_AudioFeedback(true); -} - void SetPID(celsius_t t, heater_id_t h) { char cmd[48] = ""; char str_1[5] = "", str_2[5] = ""; @@ -2272,9 +2049,59 @@ void SetPID(celsius_t t, heater_id_t h) { } #endif +#if ENABLED(BAUD_RATE_GCODE) + void HMI_SetBaudRate() { + if (HMI_data.Baud115K) SetBaud115K(); else SetBaud250K(); + } + void SetBaudRate() { + HMI_SetBaudRate(); + Draw_Chkb_Line(CurrentMenu->line(), HMI_data.Baud115K); + DWIN_UpdateLCD(); + } + void SetBaud115K() { queue.inject(F("M575 P0 B115200")); HMI_data.Baud115K = true; } + void SetBaud250K() { queue.inject(F("M575 P0 B250000")); HMI_data.Baud115K = false; } +#endif + #if HAS_LCD_BRIGHTNESS - void LiveBrightness() { ui.set_brightness(HMI_value.Value); } - void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, nullptr, LiveBrightness); } + void ApplyBrightness() { ui.set_brightness(MenuData.Value); } + void LiveBrightness() { DWIN_LCD_Brightness(MenuData.Value); } + void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, ApplyBrightness, LiveBrightness); } + void TurnOffBacklight() { HMI_SaveProcessID(WaitResponse); ui.set_brightness(0); DWIN_Redraw_screen(); } +#endif + +#if ENABLED(CASE_LIGHT_MENU) + void SetCaseLight() { + caselight.on = !caselight.on; + caselight.update_enabled(); + Draw_Chkb_Line(CurrentMenu->line(), caselight.on); + DWIN_UpdateLCD(); + } + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + void LiveCaseLightBrightness() { HMI_data.CaseLight_Brightness = caselight.brightness = MenuData.Value; caselight.update_brightness(); } + void SetCaseLightBrightness() { SetIntOnClick(0, 255, caselight.brightness, nullptr, LiveCaseLightBrightness); } + #endif +#endif + +#if ENABLED(LED_CONTROL_MENU) + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + void SetLedStatus() { + leds.toggle(); + Draw_Chkb_Line(CurrentMenu->line(), leds.lights_on); + DWIN_UpdateLCD(); + } + #endif + #if ENABLED(HAS_COLOR_LEDS) + void LiveLedColorR() { leds.color.r = MenuData.Value; HMI_data.Led_Color = leds.color; leds.update(); } + void SetLedColorR() { SetIntOnClick(0, 255, leds.color.r, nullptr, LiveLedColorR); } + void LiveLedColorG() { leds.color.g = MenuData.Value; HMI_data.Led_Color = leds.color; leds.update(); } + void SetLedColorG() { SetIntOnClick(0, 255, leds.color.g, nullptr, LiveLedColorG); } + void LiveLedColorB() { leds.color.b = MenuData.Value; HMI_data.Led_Color = leds.color; leds.update(); } + void SetLedColorB() { SetIntOnClick(0, 255, leds.color.b, nullptr, LiveLedColorB); } + #if HAS_WHITE_LED + void LiveLedColorW() { leds.color.w = MenuData.Value; HMI_data.Led_Color = leds.color; leds.update(); } + void SetLedColorW() { SetIntOnClick(0, 255, leds.color.w, nullptr, LiveLedColorW); } + #endif + #endif #endif #if ENABLED(SOUND_MENU_ITEM) @@ -2285,23 +2112,36 @@ void SetPID(celsius_t t, heater_id_t h) { } #endif -void Goto_LockScreen() { DWIN_LockScreen(true); } - #if HAS_HOME_OFFSET - void ApplyHomeOffset() { set_home_offset(HMI_value.axis, HMI_value.Value / MINUNITMULT); } + void ApplyHomeOffset() { set_home_offset(HMI_value.axis, MenuData.Value / MINUNITMULT); } void SetHomeOffsetX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(-50, 50, UNITFDIGITS, ApplyHomeOffset); } void SetHomeOffsetY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(-50, 50, UNITFDIGITS, ApplyHomeOffset); } void SetHomeOffsetZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick( -2, 2, UNITFDIGITS, ApplyHomeOffset); } #endif #if HAS_BED_PROBE - void SetProbeOffsetX() { SetPFloatOnClick(-50, 50, UNITFDIGITS); } - void SetProbeOffsetY() { SetPFloatOnClick(-50, 50, UNITFDIGITS); } + void SetProbeOffsetX() { SetPFloatOnClick(-60, 60, UNITFDIGITS); } + void SetProbeOffsetY() { SetPFloatOnClick(-60, 60, UNITFDIGITS); } void SetProbeOffsetZ() { SetPFloatOnClick(-10, 10, 2); } void ProbeTest() { LCD_MESSAGE(MSG_M48_TEST); queue.inject(F("G28O\nM48 P10")); } + void ProbeStow() { probe.stow(); } + void ProbeDeploy() { probe.deploy(); } + + #ifdef BLTOUCH_HS_MODE + void SetHSMode() { + bltouch.high_speed_mode = !bltouch.high_speed_mode; + Draw_Chkb_Line(CurrentMenu->line(), bltouch.high_speed_mode); + DWIN_UpdateLCD(); + } + #endif + + #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + void SetBedLevT() { SetPIntOnClick(BED_MINTEMP, BED_MAX_TARGET); } + #endif + #endif #if HAS_FILAMENT_SENSOR @@ -2312,7 +2152,7 @@ void Goto_LockScreen() { DWIN_LockScreen(true); } DWIN_UpdateLCD(); } #if HAS_FILAMENT_RUNOUT_DISTANCE - void ApplyRunoutDistance() { runout.set_runout_distance(HMI_value.Value / MINUNITMULT); } + void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } void SetRunoutDistance() { SetFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), ApplyRunoutDistance); } #endif #endif @@ -2329,20 +2169,20 @@ void Goto_LockScreen() { DWIN_LockScreen(true); } void RestoreDefaultsColors() { DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWIN_Redraw_screen(); } void SelColor() { - HMI_value.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; - HMI_value.Color[0] = GetRColor(*HMI_value.P_Int); // Red - HMI_value.Color[1] = GetGColor(*HMI_value.P_Int); // Green - HMI_value.Color[2] = GetBColor(*HMI_value.P_Int); // Blue + MenuData.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; + HMI_value.Color[0] = GetRColor(*MenuData.P_Int); // Red + HMI_value.Color[1] = GetGColor(*MenuData.P_Int); // Green + HMI_value.Color[2] = GetBColor(*MenuData.P_Int); // Blue Draw_GetColor_Menu(); } void LiveRGBColor() { - HMI_value.Color[CurrentMenu->line() - 2] = HMI_value.Value; + HMI_value.Color[CurrentMenu->line() - 2] = MenuData.Value; uint16_t color = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); DWIN_Draw_Rectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); } @@ -2352,27 +2192,28 @@ void SetRGBColor() { } void DWIN_ApplyColor() { - *HMI_value.P_Int = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); - Draw_Status_Area(false); + *MenuData.P_Int = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); Draw_SelectColors_Menu(); - LCD_MESSAGE_F("Colors applied"); + hash_changed = true; + LCD_MESSAGE_F(GET_TEXT_F(MSG_COLORS_APPLIED)); + DWIN_Draw_Dashboard(); } void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } #if HAS_HOTEND - void ApplyHotendTemp() { thermalManager.setTargetHotend(HMI_value.Value, 0); } + void ApplyHotendTemp() { thermalManager.setTargetHotend(MenuData.Value, 0); } void SetHotendTemp() { SetIntOnClick(MIN_ETEMP, MAX_ETEMP, thermalManager.degTargetHotend(0), ApplyHotendTemp); } #endif #if HAS_HEATED_BED - void ApplyBedTemp() { thermalManager.setTargetBed(HMI_value.Value); } + void ApplyBedTemp() { thermalManager.setTargetBed(MenuData.Value); } void SetBedTemp() { SetIntOnClick(BED_MINTEMP, BED_MAX_TARGET, thermalManager.degTargetBed(), ApplyBedTemp); } #endif #if HAS_FAN - void ApplyFanSpeed() { thermalManager.set_fan_speed(0, HMI_value.Value); } + void ApplyFanSpeed() { thermalManager.set_fan_speed(0, MenuData.Value); } void SetFanSpeed() { SetIntOnClick(0, 255, thermalManager.fan_speed[0], ApplyFanSpeed); } #endif @@ -2405,16 +2246,16 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } void ApplyFlow() { planner.refresh_e_factor(0); } void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, ApplyFlow); } -// Leveling Bed Corners -void LevBed(uint8_t point) { +// Bed Tramming +TERN(HAS_ONESTEP_LEVELING, float, void) Tram(uint8_t point) { char cmd[100] = ""; #if HAS_ONESTEP_LEVELING + static bool inLev = false; + float xpos = 0, ypos = 0, zval = 0, margin = 0; char str_1[6] = "", str_2[6] = "", str_3[6] = ""; - #define fmt "X:%s, Y:%s, Z:%s" - float xpos = 0, ypos = 0, zval = 0; - float margin = PROBING_MARGIN; + if (inLev) return NAN; + margin = HMI_data.FullManualTramming ? 30 : PROBING_MARGIN; #else - #define fmt "M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300" int16_t xpos = 0, ypos = 0; int16_t margin = 30; #endif @@ -2442,35 +2283,120 @@ void LevBed(uint8_t point) { break; } + planner.synchronize(); + #if HAS_ONESTEP_LEVELING - planner.synchronize(); - gcode.process_subcommands_now(F("M420S0\nG28O")); - planner.synchronize(); - zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); - sprintf_P(cmd, PSTR(fmt), - dtostrf(xpos, 1, 1, str_1), - dtostrf(ypos, 1, 1, str_2), - dtostrf(zval, 1, 2, str_3) - ); - ui.set_status(cmd); + + if (HMI_data.FullManualTramming) { + planner.synchronize(); + sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%sY%sF5000\nG0Z0F300"), + dtostrf(xpos, 1, 1, str_1), + dtostrf(ypos, 1, 1, str_2) + ); + queue.inject(cmd); + } + else { + LIMIT(xpos, X_MIN_POS, (X_MAX_POS + probe.offset.x)); + LIMIT(ypos, Y_MIN_POS, (Y_MAX_POS + probe.offset.y)); + probe.stow(); + gcode.process_subcommands_now(F("M420S0\nG28O")); + planner.synchronize(); + inLev = true; + zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); + if (isnan(zval)) + ui.set_status(F("Position Not Reachable, check offsets")); + else { + sprintf_P(cmd, PSTR("X:%s, Y:%s, Z:%s"), + dtostrf(xpos, 1, 1, str_1), + dtostrf(ypos, 1, 1, str_2), + dtostrf(zval, 1, 2, str_3) + ); + ui.set_status(cmd); + } + inLev = false; + } + return zval; + #else - planner.synchronize(); - sprintf_P(cmd, PSTR(fmt), xpos, ypos); + + sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300"), xpos, ypos); queue.inject(cmd); + #endif } -void LevBedFL() { LevBed(0); } -void LevBedFR() { LevBed(1); } -void LevBedBR() { LevBed(2); } -void LevBedBL() { LevBed(3); } -void LevBedC () { LevBed(4); } +void TramFL() { Tram(0); } +void TramFR() { Tram(1); } +void TramBR() { Tram(2); } +void TramBL() { Tram(3); } +void TramC () { Tram(4); } + +#if HAS_ONESTEP_LEVELING + + void Trammingwizard() { + bed_mesh_t zval = {0}; + if (HMI_data.FullManualTramming) { + ui.set_status(F("Disable manual tramming")); + return; + } + zval[0][0] = Tram(0); + checkkey = NothingToDo; + MeshViewer.DrawMesh(zval, 2, 2); + zval[1][0] = Tram(1); + MeshViewer.DrawMesh(zval, 2, 2); + zval[1][1] = Tram(2); + MeshViewer.DrawMesh(zval, 2, 2); + zval[0][1] = Tram(3); + MeshViewer.DrawMesh(zval, 2, 2); + char str_1[6] = "", str_2[6] = ""; + ui.status_printf(0, F("Limits minZ: %s, maxZ: %s"), + dtostrf(MeshViewer.min, 1, 2, str_1), + dtostrf(MeshViewer.max, 1, 2, str_2) + ); + if (ABS(MeshViewer.max - MeshViewer.min) < 0.05) { + DWINUI::Draw_CenteredString(140,F("Corners leveled")); + DWINUI::Draw_CenteredString(160,F("Tolerance achieved!")); + } + else { + uint8_t p = 0; + float d, max = 0; + FSTR_P plabel; + LOOP_L_N(x,2) LOOP_L_N(y,2) { + d = ABS(zval[x][y] - MeshViewer.avg); + if (max < d) { + max = d; + p = x + 2 * y; + } + } + switch (p) { + case 0b00 : plabel = GET_TEXT_F(MSG_LEVBED_FL); break; + case 0b01 : plabel = GET_TEXT_F(MSG_LEVBED_FR); break; + case 0b10 : plabel = GET_TEXT_F(MSG_LEVBED_BL); break; + case 0b11 : plabel = GET_TEXT_F(MSG_LEVBED_BR); break; + default : plabel = F(""); break; + } + DWINUI::Draw_CenteredString(130, F("Corners not leveled")); + DWINUI::Draw_CenteredString(150, F("Knob adjustment required")); + DWINUI::Draw_CenteredString(Color_Green, 170, plabel); + } + DWINUI::Draw_Button(BTN_Continue, 86, 305); + checkkey = Menu; + HMI_SaveProcessID(WaitResponse); + } + + void SetManualTramming() { + HMI_data.FullManualTramming = !HMI_data.FullManualTramming; + Draw_Chkb_Line(CurrentMenu->line(), HMI_data.FullManualTramming); + DWIN_UpdateLCD(); + } + +#endif // HAS_ONESTEP_LEVELING #if ENABLED(MESH_BED_LEVELING) void ManualMeshStart(){ LCD_MESSAGE(MSG_UBL_BUILD_MESH_MENU); - gcode.process_subcommands_now(F("G28Z\nM211S0\nG29S1")); + gcode.process_subcommands_now(F("G28XYO\nG28Z\nM211S0\nG29S1")); planner.synchronize(); #ifdef MANUAL_PROBE_START_Z const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos); @@ -2479,7 +2405,7 @@ void LevBedC () { LevBed(4); } } void LiveMeshMoveZ() { - *HMI_value.P_Float = HMI_value.Value / POW(10, 2); + *MenuData.P_Float = MenuData.Value / POW(10, 2); if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, homing_feedrate(Z_AXIS)); @@ -2512,29 +2438,29 @@ void LevBedC () { LevBed(4); } #endif #endif -void ApplyMaxSpeed() { planner.set_max_feedrate(HMI_value.axis, HMI_value.Value / MINUNITMULT); } -void SetMaxSpeedX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[X_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[X_AXIS], ApplyMaxSpeed); } -void SetMaxSpeedY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[Y_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[Y_AXIS], ApplyMaxSpeed); } -void SetMaxSpeedZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[Z_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[Z_AXIS], ApplyMaxSpeed); } +void ApplyMaxSpeed() { planner.set_max_feedrate(HMI_value.axis, MenuData.Value / MINUNITMULT); } +void SetMaxSpeedX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[X_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[X_AXIS], ApplyMaxSpeed); } +void SetMaxSpeedY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[Y_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[Y_AXIS], ApplyMaxSpeed); } +void SetMaxSpeedZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[Z_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[Z_AXIS], ApplyMaxSpeed); } #if HAS_HOTEND - void SetMaxSpeedE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[E_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[E_AXIS], ApplyMaxSpeed); } + void SetMaxSpeedE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[E_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[E_AXIS], ApplyMaxSpeed); } #endif -void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, HMI_value.Value); } -void SetMaxAccelX() { HMI_value.axis = X_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[X_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[X_AXIS], ApplyMaxAccel); } -void SetMaxAccelY() { HMI_value.axis = Y_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[Y_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ApplyMaxAccel); } -void SetMaxAccelZ() { HMI_value.axis = Z_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[Z_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ApplyMaxAccel); } +void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, MenuData.Value); } +void SetMaxAccelX() { HMI_value.axis = X_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[X_AXIS], planner.settings.max_acceleration_mm_per_s2[X_AXIS], ApplyMaxAccel); } +void SetMaxAccelY() { HMI_value.axis = Y_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[Y_AXIS], planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ApplyMaxAccel); } +void SetMaxAccelZ() { HMI_value.axis = Z_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[Z_AXIS], planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ApplyMaxAccel); } #if HAS_HOTEND - void SetMaxAccelE() { HMI_value.axis = E_AXIS; SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[E_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[E_AXIS], ApplyMaxAccel); } + void SetMaxAccelE() { HMI_value.axis = E_AXIS; SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[E_AXIS], planner.settings.max_acceleration_mm_per_s2[E_AXIS], ApplyMaxAccel); } #endif #if HAS_CLASSIC_JERK - void ApplyMaxJerk() { planner.set_max_jerk(HMI_value.axis, HMI_value.Value / MINUNITMULT); } - void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[X_AXIS] * 2, UNITFDIGITS, planner.max_jerk[X_AXIS], ApplyMaxJerk); } - void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[Y_AXIS] * 2, UNITFDIGITS, planner.max_jerk[Y_AXIS], ApplyMaxJerk); } - void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[Z_AXIS] * 2, UNITFDIGITS, planner.max_jerk[Z_AXIS], ApplyMaxJerk); } + void ApplyMaxJerk() { planner.set_max_jerk(HMI_value.axis, MenuData.Value / MINUNITMULT); } + void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[X_AXIS], UNITFDIGITS, planner.max_jerk[X_AXIS], ApplyMaxJerk); } + void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Y_AXIS], UNITFDIGITS, planner.max_jerk[Y_AXIS], ApplyMaxJerk); } + void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Z_AXIS], UNITFDIGITS, planner.max_jerk[Z_AXIS], ApplyMaxJerk); } #if HAS_HOTEND - void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, default_max_jerk[E_AXIS] * 2, UNITFDIGITS, planner.max_jerk[E_AXIS], ApplyMaxJerk); } + void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[E_AXIS], UNITFDIGITS, planner.max_jerk[E_AXIS], ApplyMaxJerk); } #endif #endif @@ -2553,81 +2479,33 @@ void SetStepsZ() { HMI_value.axis = Z_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP void SetPidCycles() { SetPIntOnClick(3, 50); } void SetKp() { SetPFloatOnClick(0, 1000, 2); } void ApplyPIDi() { - *HMI_value.P_Float = scalePID_i(HMI_value.Value / POW(10, 2)); + *MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2)); thermalManager.updatePID(); } void ApplyPIDd() { - *HMI_value.P_Float = scalePID_d(HMI_value.Value / POW(10, 2)); + *MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2)); thermalManager.updatePID(); } void SetKi() { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - const float value = unscalePID_i(*HMI_value.P_Float); + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + const float value = unscalePID_i(*MenuData.P_Float); SetFloatOnClick(0, 1000, 2, value, ApplyPIDi); } void SetKd() { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - const float value = unscalePID_d(*HMI_value.P_Float); + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + const float value = unscalePID_d(*MenuData.P_Float); SetFloatOnClick(0, 1000, 2, value, ApplyPIDd); } #endif -// Menuitem Drawing functions ================================================= - -void onDrawMenuItem(MenuItemClass* menuitem, int8_t line) { - if (menuitem->icon) DWINUI::Draw_Icon(menuitem->icon, ICOX, MBASE(line) - 3); - if (menuitem->frameid) - DWIN_Frame_AreaCopy(menuitem->frameid, menuitem->frame.left, menuitem->frame.top, menuitem->frame.right, menuitem->frame.bottom, LBLX, MBASE(line)); - else if (menuitem->caption) - DWINUI::Draw_String(LBLX, MBASE(line) - 1, menuitem->caption); - DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); -} - -void onDrawSubMenu(MenuItemClass* menuitem, int8_t line) { - onDrawMenuItem(menuitem, line); - DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); -} - -void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, uint16_t value) { - onDrawMenuItem(menuitem, line); - Draw_Menu_IntValue(HMI_data.Background_Color, line, 4, value); -} - -void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line) { - const uint16_t value = *(uint16_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line) { - const uint8_t value = *(uint8_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) { - const uint32_t value = *(uint32_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) { - onDrawMenuItem(menuitem, line); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value); -} - -void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - const int8_t dp = UNITFDIGITS; - onDrawFloatMenu(menuitem, line, dp, value); -} - -void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - onDrawFloatMenu(menuitem, line, 2, value); -} +#if ENABLED(FWRETRACT) + void SetRetractLength() { SetPFloatOnClick( 0, 10, UNITFDIGITS); }; + void SetRetractSpeed() { SetPFloatOnClick( 1, 90, UNITFDIGITS); }; + void SetZRaise() { SetPFloatOnClick( 0, 2, 2); }; + void SetRecoverSpeed() { SetPFloatOnClick( 1, 90, UNITFDIGITS); }; +#endif -void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) { - onDrawMenuItem(menuitem, line); - Draw_Chkb_Line(line, checked); -} +// Special Menuitem Drawing functions ================================================= void onDrawBack(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 129, 72, 156, 84); @@ -2745,7 +2623,27 @@ void onDrawLanguage(MenuItemClass* menuitem, int8_t line) { void onDrawPwrLossR(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, recovery.enabled); } #endif -void onDrawEnableSound(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, ui.buzzer_enabled); } +#if ENABLED(BAUD_RATE_GCODE) + void onDrawBaudrate(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, HMI_data.Baud115K); } +#endif + +#if ENABLED(CASE_LIGHT_MENU) + void onDrawCaseLight(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, caselight.on); } +#endif + +#if ENABLED(LED_CONTROL_MENU) + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + void onDrawLedStatus(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, leds.lights_on); } + #endif +#endif + +#if ENABLED(SOUND_MENU_ITEM) + void onDrawEnableSound(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, ui.buzzer_enabled); } +#endif + +#ifdef BLTOUCH_HS_MODE + void onDrawHSMode(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, bltouch.high_speed_mode); } +#endif void onDrawSelColorItem(MenuItemClass* menuitem, int8_t line) { const uint16_t color = *(uint16_t*)static_cast(menuitem)->value; @@ -2853,7 +2751,7 @@ void onDrawSpeed(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedX(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(line)); // X + DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(line)); // X } onDrawPFloatMenu(menuitem, line); } @@ -2861,7 +2759,7 @@ void onDrawMaxSpeedX(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedY(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(line)); // Y + DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(line)); // Y } onDrawPFloatMenu(menuitem, line); } @@ -2869,7 +2767,7 @@ void onDrawMaxSpeedY(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(line) + 3); // Z + DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(line) + 3); // Z } onDrawPFloatMenu(menuitem, line); } @@ -2878,7 +2776,7 @@ void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedE(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(line)); // E + DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(line)); // E } onDrawPFloatMenu(menuitem, line); } @@ -2887,7 +2785,7 @@ void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { void onDrawAcc(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line) + 1); // ...Acceleration + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line) + 1); // ...Acceleration } onDrawSubMenu(menuitem, line); } @@ -2896,7 +2794,7 @@ void onDrawMaxAccelX(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 71, MBASE(line)); // X + DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 71, MBASE(line)); // X } onDrawPInt32Menu(menuitem, line); } @@ -2904,8 +2802,8 @@ void onDrawMaxAccelX(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelY(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 71, MBASE(line)); // Y + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 71, MBASE(line)); // Y } onDrawPInt32Menu(menuitem, line); } @@ -2913,8 +2811,8 @@ void onDrawMaxAccelY(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 71, MBASE(line)); // Z + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 71, MBASE(line)); // Z } onDrawPInt32Menu(menuitem, line); } @@ -2923,8 +2821,8 @@ void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelE(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 71, MBASE(line)); // E + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 71, MBASE(line)); // E } onDrawPInt32Menu(menuitem, line); } @@ -2935,7 +2833,7 @@ void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { void onDrawJerk(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(line) + 1); // ... + DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(line) + 1); // ... DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(line)); // ...Jerk } onDrawSubMenu(menuitem, line); @@ -3019,134 +2917,9 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) { } #endif -// HMI Control functions ====================================================== - -// Generic menu control using the encoder -void HMI_Menu() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (CurrentMenu != nullptr) CurrentMenu->onClick(); - } else if (CurrentMenu != nullptr) CurrentMenu->onScroll(encoder_diffState == ENCODER_DIFF_CW); -} - -// Get an integer value using the encoder without draw anything -// lo: low limit -// hi: high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_value.Value)) { - EncoderRate.enabled = false; - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.Value, lo, hi); - return 1; - } - return 0; -} - -// Get an integer value using the encoder -// lo: low limit -// hi: high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_value.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Int(HMI_data.Text_Color, HMI_data.Background_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, HMI_value.Value); - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.Value, lo, hi); - DWINUI::Draw_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, HMI_value.Value); - return 1; - } - return 0; -} - -// Set an integer using the encoder -void HMI_SetInt() { - int8_t val = HMI_GetInt(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; break; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} - -// Set an integer without drawing -void HMI_SetIntNoDraw() { - int8_t val = HMI_GetIntNoDraw(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; break; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} - -// Set an integer pointer variable using the encoder -void HMI_SetPInt() { - int8_t val = HMI_GetInt(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: *HMI_value.P_Int = HMI_value.Value; if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} - -// Get a scaled float value using the encoder -// dp: decimal places -// lo: scaled low limit -// hi: scaled high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_value.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp)); - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.Value, lo, hi); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp)); - return 1; - } - return 0; -} - -// Set a scaled float using the encoder -void HMI_SetFloat() { - const int8_t val = HMI_GetFloat(HMI_value.dp, HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} - -// Set a scaled float pointer variable using the encoder -void HMI_SetPFloat() { - const int8_t val = HMI_GetFloat(HMI_value.dp, HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: *HMI_value.P_Float = HMI_value.Value / POW(10, HMI_value.dp); if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} +#if HAS_ONESTEP_LEVELING + void onDrawManualTramming(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, HMI_data.FullManualTramming); } +#endif // Menu Creation and Drawing functions ====================================================== @@ -3159,156 +2932,194 @@ void SetMenuTitle(frame_rect_t cn, const __FlashStringHelper* fstr) { void Draw_Prepare_Menu() { checkkey = Menu; - if (PrepareMenu == nullptr) PrepareMenu = new MenuClass(); + if (!PrepareMenu) PrepareMenu = new MenuClass(); if (CurrentMenu != PrepareMenu) { CurrentMenu = PrepareMenu; SetMenuTitle({133, 1, 28, 13}, GET_TEXT_F(MSG_PREPARE)); DWINUI::MenuItemsPrepare(13); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); #if ENABLED(ADVANCED_PAUSE_FEATURE) - ADDMENUITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENT_MAN), onDrawSubMenu, Draw_FilamentMan_Menu); + MENU_ITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENT_MAN), onDrawSubMenu, Draw_FilamentMan_Menu); + #endif + MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_MOVE_AXIS), onDrawMoveSubMenu, Goto_Move_Menu); + MENU_ITEM(ICON_Tram, GET_TEXT_F(MSG_BED_TRAMMING), onDrawSubMenu, Draw_Tramming_Menu); + MENU_ITEM(ICON_CloseMotor, GET_TEXT_F(MSG_DISABLE_STEPPERS), onDrawDisableMotors, DisableMotors); + #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + MENU_ITEM(ICON_Homing, GET_TEXT_F(MSG_HOMING), onDrawSubMenu, Draw_Homing_Menu); + #else + MENU_ITEM(ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME), onDrawAutoHome, AutoHome); #endif - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_MOVE_AXIS), onDrawMoveSubMenu, Draw_Move_Menu); - ADDMENUITEM(ICON_LevBed, GET_TEXT_F(MSG_BED_LEVELING), onDrawSubMenu, Draw_LevBedCorners_Menu); - ADDMENUITEM(ICON_CloseMotor, GET_TEXT_F(MSG_DISABLE_STEPPERS), onDrawDisableMotors, DisableMotors); - ADDMENUITEM(ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME), onDrawAutoHome, AutoHome); #if ENABLED(MESH_BED_LEVELING) - ADDMENUITEM(ICON_ManualMesh, GET_TEXT_F(MSG_MANUAL_MESH), onDrawSubMenu, Draw_ManualMesh_Menu); + MENU_ITEM(ICON_ManualMesh, GET_TEXT_F(MSG_MANUAL_MESH), onDrawSubMenu, Draw_ManualMesh_Menu); + #endif + #if HAS_ONESTEP_LEVELING + MENU_ITEM(ICON_Level, GET_TEXT_F(MSG_AUTO_MESH), onDrawMenuItem, AutoLev); #endif #if HAS_ZOFFSET_ITEM - #if EITHER(HAS_BED_PROBE, BABYSTEPPING) - ADDMENUITEM(ICON_SetZOffset, GET_TEXT_F(MSG_PROBE_WIZARD), onDrawSubMenu, Draw_ZOffsetWiz_Menu); + #if HAS_BED_PROBE + MENU_ITEM(ICON_SetZOffset, GET_TEXT_F(MSG_PROBE_WIZARD), onDrawSubMenu, Draw_ZOffsetWiz_Menu); + #elif ENABLED(BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); #else - ADDMENUITEM(ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawHomeOffset, SetHome); + MENU_ITEM(ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawHomeOffset, SetHome); #endif #endif #if HAS_PREHEAT - ADDMENUITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, DoPreheat0); + MENU_ITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, DoPreheat0); #if PREHEAT_COUNT > 1 - ADDMENUITEM(ICON_ABSPreheat, PSTR("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, DoPreheat1); + MENU_ITEM(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); + MENU_ITEM(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); + MENU_ITEM(ICON_Cool, GET_TEXT_F(MSG_COOLDOWN), onDrawCooldown, DoCoolDown); + MENU_ITEM(ICON_Language, PSTR(GET_TEXT_F(MSG_UI_LANGUAGE)), onDrawLanguage, SetLanguage); } + ui.reset_status(true); CurrentMenu->draw(); } -void Draw_LevBedCorners_Menu() { +void Draw_Tramming_Menu() { DWINUI::ClearMenuArea(); checkkey = Menu; - if (LevBedMenu == nullptr) LevBedMenu = new MenuClass(); - if (CurrentMenu != LevBedMenu) { - CurrentMenu = LevBedMenu; + if (!TrammingMenu) TrammingMenu = new MenuClass(); + if (CurrentMenu != TrammingMenu) { + CurrentMenu = TrammingMenu; SetMenuTitle({0}, GET_TEXT_F(MSG_BED_TRAMMING)); // TODO: Chinese, English "Bed Tramming" JPG - DWINUI::MenuItemsPrepare(6); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_FL), onDrawMenuItem, LevBedFL); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_FR), onDrawMenuItem, LevBedFR); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_BR), onDrawMenuItem, LevBedBR); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_BL), onDrawMenuItem, LevBedBL); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_C ), onDrawMenuItem, LevBedC ); + DWINUI::MenuItemsPrepare(8); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); + MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_FL), onDrawMenuItem, TramFL); + MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_FR), onDrawMenuItem, TramFR); + MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_BR), onDrawMenuItem, TramBR); + MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_BL), onDrawMenuItem, TramBL); + MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_C ), onDrawMenuItem, TramC ); + #if HAS_ONESTEP_LEVELING + MENU_ITEM(ICON_ProbeSet, F("Bed tramming wizard"), onDrawMenuItem, Trammingwizard); + MENU_ITEM(ICON_ProbeSet, GET_TEXT_F(MSG_BED_TRAMMING_MANUAL), onDrawManualTramming, SetManualTramming); + #endif } CurrentMenu->draw(); } void Draw_Control_Menu() { checkkey = Menu; - if (ControlMenu == nullptr) ControlMenu = new MenuClass(); + if (!ControlMenu) ControlMenu = new MenuClass(); if (CurrentMenu != ControlMenu) { CurrentMenu = ControlMenu; SetMenuTitle({103, 1, 28, 14}, GET_TEXT_F(MSG_CONTROL)); - DWINUI::MenuItemsPrepare(9); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); - ADDMENUITEM(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawTempSubMenu, Draw_Temperature_Menu); - ADDMENUITEM(ICON_Motion, GET_TEXT_F(MSG_MOTION), onDrawMotionSubMenu, Draw_Motion_Menu); + DWINUI::MenuItemsPrepare(10); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); + #if ENABLED(CASE_LIGHT_MENU) + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawSubMenu, Draw_CaseLight_Menu); + #else + MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight); + #endif + #endif + #if ENABLED(LED_CONTROL_MENU) + MENU_ITEM(ICON_LedControl, GET_TEXT_F(MSG_LED_CONTROL), onDrawSubMenu, Draw_LedControl_Menu); + #endif + MENU_ITEM(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawTempSubMenu, Draw_Temperature_Menu); + MENU_ITEM(ICON_Motion, GET_TEXT_F(MSG_MOTION), onDrawMotionSubMenu, Draw_Motion_Menu); #if ENABLED(EEPROM_SETTINGS) - ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom); - ADDMENUITEM(ICON_ReadEEPROM, GET_TEXT_F(MSG_LOAD_EEPROM), onDrawReadEeprom, ReadEeprom); - ADDMENUITEM(ICON_ResumeEEPROM, GET_TEXT_F(MSG_RESTORE_DEFAULTS), onDrawResetEeprom, ResetEeprom); + MENU_ITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom); + MENU_ITEM(ICON_ReadEEPROM, GET_TEXT_F(MSG_LOAD_EEPROM), onDrawReadEeprom, ReadEeprom); + MENU_ITEM(ICON_ResumeEEPROM, GET_TEXT_F(MSG_RESTORE_DEFAULTS), onDrawResetEeprom, ResetEeprom); #endif - ADDMENUITEM(ICON_Reboot, GET_TEXT_F(MSG_RESET_PRINTER), onDrawMenuItem, RebootPrinter); - ADDMENUITEM(ICON_AdvSet, GET_TEXT_F(MSG_ADVANCED_SETTINGS), onDrawSubMenu, Draw_AdvancedSettings_Menu); - ADDMENUITEM(ICON_Info, GET_TEXT_F(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_InfoMenu); + MENU_ITEM(ICON_Reboot, GET_TEXT_F(MSG_RESET_PRINTER), onDrawMenuItem, RebootPrinter); + MENU_ITEM(ICON_Info, GET_TEXT_F(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_Info_Menu); } + ui.reset_status(true); CurrentMenu->draw(); } void Draw_AdvancedSettings_Menu() { checkkey = Menu; - if (AdvancedSettings == nullptr) AdvancedSettings = new MenuClass(); + if (!AdvancedSettings) AdvancedSettings = new MenuClass(); if (CurrentMenu != AdvancedSettings) { CurrentMenu = AdvancedSettings; SetMenuTitle({0}, GET_TEXT_F(MSG_ADVANCED_SETTINGS)); // TODO: Chinese, English "Advanced Settings" JPG - DWINUI::MenuItemsPrepare(12); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); + DWINUI::MenuItemsPrepare(17); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); + #if ENABLED(EEPROM_SETTINGS) + MENU_ITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom); + #endif #if HAS_HOME_OFFSET - ADDMENUITEM(ICON_HomeOffset, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawSubMenu, Draw_HomeOffset_Menu); + MENU_ITEM(ICON_HomeOffset, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawSubMenu, Draw_HomeOffset_Menu); #endif #if HAS_BED_PROBE - ADDMENUITEM(ICON_ProbeSet, GET_TEXT_F(MSG_ZPROBE_SETTINGS), onDrawSubMenu, Draw_ProbeSet_Menu); + MENU_ITEM(ICON_ProbeSet, GET_TEXT_F(MSG_ZPROBE_SETTINGS), onDrawSubMenu, Draw_ProbeSet_Menu); #endif #if HAS_HOTEND - ADDMENUITEM(ICON_PIDNozzle, F("Hotend PID Settings"), onDrawSubMenu, Draw_HotendPID_Menu); + MENU_ITEM(ICON_PIDNozzle, F("Hotend PID Settings"), onDrawSubMenu, Draw_HotendPID_Menu); #endif #if HAS_HEATED_BED - ADDMENUITEM(ICON_PIDbed, F("Bed PID Settings"), onDrawSubMenu, Draw_BedPID_Menu); + MENU_ITEM(ICON_PIDbed, F("Bed PID Settings"), onDrawSubMenu, Draw_BedPID_Menu); #endif #if HAS_FILAMENT_SENSOR - ADDMENUITEM(ICON_FilSet, GET_TEXT_F(MSG_FILAMENT_SET), onDrawSubMenu, Draw_FilSet_Menu); + MENU_ITEM(ICON_FilSet, GET_TEXT_F(MSG_FILAMENT_SET), onDrawSubMenu, Draw_FilSet_Menu); #endif #if ENABLED(POWER_LOSS_RECOVERY) - ADDMENUITEM(ICON_Pwrlossr, GET_TEXT_F(MSG_OUTAGE_RECOVERY), onDrawPwrLossR, SetPwrLossr); + MENU_ITEM(ICON_Pwrlossr, GET_TEXT_F(MSG_OUTAGE_RECOVERY), onDrawPwrLossR, SetPwrLossr); + #endif + #if ENABLED(BAUD_RATE_GCODE) + MENU_ITEM(ICON_SetBaudRate, F("115K baud"), onDrawBaudrate, SetBaudRate); #endif #if HAS_LCD_BRIGHTNESS - ADDMENUITEM_P(ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS), onDrawPInt8Menu, SetBrightness, &ui.brightness); + EDIT_ITEM(ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS), onDrawPInt8Menu, SetBrightness, &ui.brightness); #endif - ADDMENUITEM(ICON_Scolor, F("Select Colors"), onDrawSubMenu, Draw_SelectColors_Menu); + MENU_ITEM(ICON_Scolor, GET_TEXT_F(MSG_COLORS_SELECT), onDrawSubMenu, Draw_SelectColors_Menu); #if ENABLED(SOUND_MENU_ITEM) - ADDMENUITEM(ICON_Sound, F("Enable Sound"), onDrawEnableSound, SetEnableSound); + MENU_ITEM(ICON_Sound, GET_TEXT_F(MSG_SOUND_ENABLE), onDrawEnableSound, SetEnableSound); #endif #if HAS_MESH - ADDMENUITEM(ICON_MeshViewer, GET_TEXT_F(MSG_MESH_VIEW), onDrawSubMenu, DWIN_MeshViewer); + MENU_ITEM(ICON_MeshViewer, GET_TEXT_F(MSG_MESH_VIEW), onDrawSubMenu, DWIN_MeshViewer); #endif - ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen); + #if HAS_ESDIAG + MENU_ITEM(ICON_ESDiag, F("End-stops diag."), onDrawSubMenu, Draw_EndStopDiag); + #endif + #if ENABLED(PRINTCOUNTER) + MENU_ITEM(ICON_PrintStats, GET_TEXT_F(MSG_INFO_STATS_MENU), onDrawSubMenu, Goto_PrintStats); + MENU_ITEM(ICON_PrintStatsReset, GET_TEXT_F(MSG_INFO_PRINT_COUNT_RESET), onDrawSubMenu, PrintStats.Reset); + #endif + MENU_ITEM(ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN), onDrawMenuItem, DWIN_LockScreen); } + ui.reset_status(true); CurrentMenu->draw(); } void Draw_Move_Menu() { checkkey = Menu; - if (MoveMenu == nullptr) MoveMenu = new MenuClass(); + if (!MoveMenu) MoveMenu = new MenuClass(); if (CurrentMenu != MoveMenu) { CurrentMenu = MoveMenu; SetMenuTitle({192, 1, 42, 14}, GET_TEXT_F(MSG_MOVE_AXIS)); DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); - ADDMENUITEM_P(ICON_MoveX, GET_TEXT_F(MSG_MOVE_X), onDrawMoveX, SetMoveX, ¤t_position.x); - ADDMENUITEM_P(ICON_MoveY, GET_TEXT_F(MSG_MOVE_Y), onDrawMoveY, SetMoveY, ¤t_position.y); - ADDMENUITEM_P(ICON_MoveZ, GET_TEXT_F(MSG_MOVE_Z), onDrawMoveZ, SetMoveZ, ¤t_position.z); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); + EDIT_ITEM(ICON_MoveX, GET_TEXT_F(MSG_MOVE_X), onDrawMoveX, SetMoveX, ¤t_position.x); + EDIT_ITEM(ICON_MoveY, GET_TEXT_F(MSG_MOVE_Y), onDrawMoveY, SetMoveY, ¤t_position.y); + EDIT_ITEM(ICON_MoveZ, GET_TEXT_F(MSG_MOVE_Z), onDrawMoveZ, SetMoveZ, ¤t_position.z); #if HAS_HOTEND - ADDMENUITEM_P(ICON_Extruder, GET_TEXT_F(MSG_MOVE_E), onDrawMoveE, SetMoveE, ¤t_position.e); + EDIT_ITEM(ICON_Extruder, GET_TEXT_F(MSG_MOVE_E), onDrawMoveE, SetMoveE, ¤t_position.e); #endif } CurrentMenu->draw(); - if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: position is unknown"); + if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: current position is unknown, home axes"); } #if HAS_HOME_OFFSET void Draw_HomeOffset_Menu() { checkkey = Menu; - if (HomeOffMenu == nullptr) HomeOffMenu = new MenuClass(); + if (!HomeOffMenu) HomeOffMenu = new MenuClass(); if (CurrentMenu != HomeOffMenu) { CurrentMenu = HomeOffMenu; SetMenuTitle({0}, GET_TEXT_F(MSG_SET_HOME_OFFSETS)); // TODO: Chinese, English "Set Home Offsets" JPG DWINUI::MenuItemsPrepare(4); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); - ADDMENUITEM_P(ICON_HomeOffsetX, GET_TEXT_F(MSG_HOME_OFFSET_X), onDrawPFloatMenu, SetHomeOffsetX, &home_offset[X_AXIS]); - ADDMENUITEM_P(ICON_HomeOffsetY, GET_TEXT_F(MSG_HOME_OFFSET_Y), onDrawPFloatMenu, SetHomeOffsetY, &home_offset[Y_AXIS]); - ADDMENUITEM_P(ICON_HomeOffsetZ, GET_TEXT_F(MSG_HOME_OFFSET_Z), onDrawPFloatMenu, SetHomeOffsetZ, &home_offset[Z_AXIS]); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); + EDIT_ITEM(ICON_HomeOffsetX, GET_TEXT_F(MSG_HOME_OFFSET_X), onDrawPFloatMenu, SetHomeOffsetX, &home_offset[X_AXIS]); + EDIT_ITEM(ICON_HomeOffsetY, GET_TEXT_F(MSG_HOME_OFFSET_Y), onDrawPFloatMenu, SetHomeOffsetY, &home_offset[Y_AXIS]); + EDIT_ITEM(ICON_HomeOffsetZ, GET_TEXT_F(MSG_HOME_OFFSET_Z), onDrawPFloatMenu, SetHomeOffsetZ, &home_offset[Z_AXIS]); } CurrentMenu->draw(); } @@ -3317,16 +3128,24 @@ void Draw_Move_Menu() { #if HAS_BED_PROBE void Draw_ProbeSet_Menu() { checkkey = Menu; - if (ProbeSetMenu == nullptr) ProbeSetMenu = new MenuClass(); + if (!ProbeSetMenu) ProbeSetMenu = new MenuClass(); if (CurrentMenu != ProbeSetMenu) { CurrentMenu = ProbeSetMenu; SetMenuTitle({0}, GET_TEXT_F(MSG_ZPROBE_SETTINGS)); // TODO: Chinese, English "Probe Settings" JPG - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); - ADDMENUITEM_P(ICON_ProbeOffsetX, GET_TEXT_F(MSG_ZPROBE_XOFFSET), onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); - ADDMENUITEM_P(ICON_ProbeOffsetY, GET_TEXT_F(MSG_ZPROBE_YOFFSET), onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); - ADDMENUITEM_P(ICON_ProbeOffsetZ, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); - ADDMENUITEM(ICON_ProbeTest, GET_TEXT_F(MSG_M48_TEST), onDrawMenuItem, ProbeTest); + DWINUI::MenuItemsPrepare(9); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); + EDIT_ITEM(ICON_ProbeOffsetX, GET_TEXT_F(MSG_ZPROBE_XOFFSET), onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); + EDIT_ITEM(ICON_ProbeOffsetY, GET_TEXT_F(MSG_ZPROBE_YOFFSET), onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); + EDIT_ITEM(ICON_ProbeOffsetZ, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); + #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + EDIT_ITEM(ICON_Temperature, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); + #endif + #ifdef BLTOUCH_HS_MODE + MENU_ITEM(ICON_HSMode, F("Enable HS mode"), onDrawHSMode, SetHSMode); + #endif + MENU_ITEM(ICON_ProbeTest, GET_TEXT_F(MSG_M48_TEST), onDrawMenuItem, ProbeTest); + MENU_ITEM(ICON_ProbeStow, GET_TEXT_F(MSG_MANUAL_STOW), onDrawMenuItem, ProbeStow); + MENU_ITEM(ICON_ProbeDeploy, GET_TEXT_F(MSG_MANUAL_DEPLOY), onDrawMenuItem, ProbeDeploy); } CurrentMenu->draw(); } @@ -3335,24 +3154,30 @@ void Draw_Move_Menu() { #if HAS_FILAMENT_SENSOR void Draw_FilSet_Menu() { checkkey = Menu; - if (FilSetMenu == nullptr) FilSetMenu = new MenuClass(); + if (!FilSetMenu) FilSetMenu = new MenuClass(); if (CurrentMenu != FilSetMenu) { CurrentMenu = FilSetMenu; CurrentMenu->MenuTitle.SetCaption(GET_TEXT_F(MSG_FILAMENT_SET)); - DWINUI::MenuItemsPrepare(6); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); + DWINUI::MenuItemsPrepare(10); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); #if HAS_FILAMENT_SENSOR - ADDMENUITEM(ICON_Runout, GET_TEXT_F(MSG_RUNOUT_ENABLE), onDrawRunoutEnable, SetRunoutEnable); + MENU_ITEM(ICON_Runout, GET_TEXT_F(MSG_RUNOUT_ENABLE), onDrawRunoutEnable, SetRunoutEnable); #endif #if HAS_FILAMENT_RUNOUT_DISTANCE - ADDMENUITEM_P(ICON_Runout, F("Runout Distance"), onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); + EDIT_ITEM(ICON_Runout, F("Runout Distance"), onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); #endif #if ENABLED(PREVENT_COLD_EXTRUSION) - ADDMENUITEM_P(ICON_ExtrudeMinT, F("Extrude Min Temp."), onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); + EDIT_ITEM(ICON_ExtrudeMinT, F("Extrude Min Temp."), onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) - ADDMENUITEM_P(ICON_FilLoad, GET_TEXT_F(MSG_FILAMENT_LOAD), onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); - ADDMENUITEM_P(ICON_FilUnload, GET_TEXT_F(MSG_FILAMENT_UNLOAD), onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); + EDIT_ITEM(ICON_FilLoad, GET_TEXT_F(MSG_FILAMENT_LOAD), onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); + EDIT_ITEM(ICON_FilUnload, GET_TEXT_F(MSG_FILAMENT_UNLOAD), onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); + #endif + #if ENABLED(FWRETRACT) + EDIT_ITEM(ICON_FWRetLength, GET_TEXT_F(MSG_CONTROL_RETRACT), onDrawPFloatMenu, SetRetractLength, &fwretract.settings.retract_length); + EDIT_ITEM(ICON_FWRetSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_RETRACT_SPEED), onDrawPFloatMenu, SetRetractSpeed, &fwretract.settings.retract_feedrate_mm_s); + EDIT_ITEM(ICON_FWRetZRaise, GET_TEXT_F(MSG_CONTROL_RETRACT_ZHOP), onDrawPFloat2Menu, SetZRaise, &fwretract.settings.retract_zraise); + EDIT_ITEM(ICON_FWRecSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_UNRETRACT_SPEED), onDrawPFloatMenu, SetRecoverSpeed, &fwretract.settings.retract_recover_feedrate_mm_s); #endif } CurrentMenu->draw(); @@ -3361,80 +3186,133 @@ void Draw_Move_Menu() { void Draw_SelectColors_Menu() { checkkey = Menu; - if (SelectColorMenu == nullptr) SelectColorMenu = new MenuClass(); + if (!SelectColorMenu) SelectColorMenu = new MenuClass(); if (CurrentMenu != SelectColorMenu) { CurrentMenu = SelectColorMenu; - SetMenuTitle({0}, F("Select Colors")); // TODO: Chinese, English "Select Color" JPG + SetMenuTitle({0}, GET_TEXT_F(MSG_COLORS_SELECT)); // TODO: Chinese, English "Select Color" JPG DWINUI::MenuItemsPrepare(20); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); - ADDMENUITEM(ICON_StockConfiguration, GET_TEXT_F(MSG_RESTORE_DEFAULTS), onDrawMenuItem, RestoreDefaultsColors); - ADDMENUITEM_P(0, "Screen Background", onDrawSelColorItem, SelColor, &HMI_data.Background_Color); - ADDMENUITEM_P(0, "Cursor", onDrawSelColorItem, SelColor, &HMI_data.Cursor_color); - ADDMENUITEM_P(0, "Title Background", onDrawSelColorItem, SelColor, &HMI_data.TitleBg_color); - ADDMENUITEM_P(0, "Title Text", onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_color); - ADDMENUITEM_P(0, "Text", onDrawSelColorItem, SelColor, &HMI_data.Text_Color); - ADDMENUITEM_P(0, "Selected", onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); - ADDMENUITEM_P(0, "Split Line", onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); - ADDMENUITEM_P(0, "Highlight", onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); - ADDMENUITEM_P(0, "Status Background", onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); - ADDMENUITEM_P(0, "Status Text", onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); - ADDMENUITEM_P(0, "Popup Background", onDrawSelColorItem, SelColor, &HMI_data.PopupBg_color); - ADDMENUITEM_P(0, "Popup Text", onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); - ADDMENUITEM_P(0, "Alert Background", onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); - ADDMENUITEM_P(0, "Alert Text", onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); - ADDMENUITEM_P(0, "Percent Text", onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); - ADDMENUITEM_P(0, "Bar Fill", onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); - ADDMENUITEM_P(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); - ADDMENUITEM_P(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); + MENU_ITEM(ICON_StockConfiguration, GET_TEXT_F(MSG_RESTORE_DEFAULTS), onDrawMenuItem, RestoreDefaultsColors); + EDIT_ITEM(0, "Screen Background", onDrawSelColorItem, SelColor, &HMI_data.Background_Color); + EDIT_ITEM(0, "Cursor", onDrawSelColorItem, SelColor, &HMI_data.Cursor_color); + EDIT_ITEM(0, "Title Background", onDrawSelColorItem, SelColor, &HMI_data.TitleBg_color); + EDIT_ITEM(0, "Title Text", onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_color); + EDIT_ITEM(0, "Text", onDrawSelColorItem, SelColor, &HMI_data.Text_Color); + EDIT_ITEM(0, "Selected", onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); + EDIT_ITEM(0, "Split Line", onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); + EDIT_ITEM(0, "Highlight", onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); + EDIT_ITEM(0, "Status Background", onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); + EDIT_ITEM(0, "Status Text", onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); + EDIT_ITEM(0, "Popup Background", onDrawSelColorItem, SelColor, &HMI_data.PopupBg_color); + EDIT_ITEM(0, "Popup Text", onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); + EDIT_ITEM(0, "Alert Background", onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); + EDIT_ITEM(0, "Alert Text", onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); + EDIT_ITEM(0, "Percent Text", onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); + EDIT_ITEM(0, "Bar Fill", onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); + EDIT_ITEM(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); + EDIT_ITEM(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); } CurrentMenu->draw(); } void Draw_GetColor_Menu() { checkkey = Menu; - if (GetColorMenu == nullptr) GetColorMenu = new MenuClass(); + if (!GetColorMenu) GetColorMenu = new MenuClass(); if (CurrentMenu != GetColorMenu) { CurrentMenu = GetColorMenu; - SetMenuTitle({0}, F("Get Color")); // TODO: Chinese, English "Get Color" JPG + SetMenuTitle({0}, GET_TEXT_F(MSG_COLORS_GET)); // TODO: Chinese, English "Get Color" JPG DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, DWIN_ApplyColor); - ADDMENUITEM(ICON_Cancel, GET_TEXT_F(MSG_BUTTON_CANCEL), onDrawMenuItem, Draw_SelectColors_Menu); - ADDMENUITEM(0, "Red", onDrawGetColorItem, SetRGBColor); - ADDMENUITEM(1, "Green", onDrawGetColorItem, SetRGBColor); - ADDMENUITEM(2, "Blue", onDrawGetColorItem, SetRGBColor); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, DWIN_ApplyColor); + MENU_ITEM(ICON_Cancel, GET_TEXT_F(MSG_BUTTON_CANCEL), onDrawMenuItem, Draw_SelectColors_Menu); + MENU_ITEM(0, GET_TEXT_F(MSG_COLORS_RED), onDrawGetColorItem, SetRGBColor); + MENU_ITEM(1, GET_TEXT_F(MSG_COLORS_GREEN), onDrawGetColorItem, SetRGBColor); + MENU_ITEM(2, GET_TEXT_F(MSG_COLORS_BLUE), onDrawGetColorItem, SetRGBColor); } CurrentMenu->draw(); - DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335); + DWIN_Draw_Rectangle(1, *MenuData.P_Int, 20, 315, DWIN_WIDTH - 20, 335); } +#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + void Draw_CaseLight_Menu() { + checkkey = Menu; + if (!CaseLightMenu) CaseLightMenu = new MenuClass(); + if (CurrentMenu != CaseLightMenu) { + CurrentMenu = CaseLightMenu; + SetMenuTitle({0}, GET_TEXT_F(MSG_CASE_LIGHT)); // TODO: Chinese, English "Case Light" JPG + DWINUI::MenuItemsPrepare(3); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); + MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight); + EDIT_ITEM(ICON_Brightness, GET_TEXT_F(MSG_CASE_LIGHT_BRIGHTNESS), onDrawPInt8Menu, SetCaseLightBrightness, &caselight.brightness); + } + CurrentMenu->draw(); + } +#endif + +#if ENABLED(LED_CONTROL_MENU) + void Draw_LedControl_Menu() { + checkkey = Menu; + if (!LedControlMenu) LedControlMenu = new MenuClass(); + if (CurrentMenu != LedControlMenu) { + CurrentMenu = LedControlMenu; + SetMenuTitle({0}, GET_TEXT_F(MSG_LED_CONTROL)); // TODO: Chinese, English "LED Control" JPG + DWINUI::MenuItemsPrepare(6); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + MENU_ITEM(ICON_LedControl, GET_TEXT_F(MSG_LEDS), onDrawLedStatus, SetLedStatus); + #endif + #if (HAS_COLOR_LEDS) + EDIT_ITEM(ICON_LedControl, GET_TEXT_F(MSG_COLORS_RED), onDrawPInt8Menu, SetLedColorR, &leds.color.r); + EDIT_ITEM(ICON_LedControl, GET_TEXT_F(MSG_COLORS_GREEN), onDrawPInt8Menu, SetLedColorG, &leds.color.g); + EDIT_ITEM(ICON_LedControl, GET_TEXT_F(MSG_COLORS_BLUE), onDrawPInt8Menu, SetLedColorB, &leds.color.b); + #if ENABLED(HAS_WHITE_LED) + EDIT_ITEM(ICON_LedControl, GET_TEXT_F(MSG_COLORS_WHITE), onDrawPInt8Menu, SetLedColorW, &leds.color.w); + #endif + #endif + } + CurrentMenu->draw(); + } +#endif + void Draw_Tune_Menu() { checkkey = Menu; - if (TuneMenu == nullptr) TuneMenu = new MenuClass(); + if (!TuneMenu) TuneMenu = new MenuClass(); if (CurrentMenu != TuneMenu) { CurrentMenu = TuneMenu; SetMenuTitle({73, 2, 28, 12}, GET_TEXT_F(MSG_TUNE)); // TODO: Chinese, English "Tune" JPG - DWINUI::MenuItemsPrepare(10); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_PrintProcess); - ADDMENUITEM_P(ICON_Speed, GET_TEXT_F(MSG_SPEED), onDrawSpeedItem, SetSpeed, &feedrate_percentage); + DWINUI::MenuItemsPrepare(16); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_PrintProcess); + #if ENABLED(CASE_LIGHT_MENU) + MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight); + #elif ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) + MENU_ITEM(ICON_LedControl, GET_TEXT_F(MSG_LEDS), onDrawLedStatus, SetLedStatus); + #endif + EDIT_ITEM(ICON_Speed, GET_TEXT_F(MSG_SPEED), onDrawSpeedItem, SetSpeed, &feedrate_percentage); #if HAS_HOTEND - HotendTargetItem = ADDMENUITEM_P(ICON_HotendTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM(ICON_HotendTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = ADDMENUITEM_P(ICON_BedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM(ICON_BedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = ADDMENUITEM_P(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif #if HAS_ZOFFSET_ITEM && EITHER(HAS_BED_PROBE, BABYSTEPPING) - ADDMENUITEM_P(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawZOffset, SetZOffset, &BABY_Z_VAR); + EDIT_ITEM(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawZOffset, SetZOffset, &BABY_Z_VAR); + #endif + #if ENABLED(FWRETRACT) + EDIT_ITEM(ICON_FWRetLength, GET_TEXT_F(MSG_CONTROL_RETRACT), onDrawPFloatMenu, SetRetractLength, &fwretract.settings.retract_length); + EDIT_ITEM(ICON_FWRetSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_RETRACT_SPEED), onDrawPFloatMenu, SetRetractSpeed, &fwretract.settings.retract_feedrate_mm_s); + EDIT_ITEM(ICON_FWRetZRaise, GET_TEXT_F(MSG_CONTROL_RETRACT_ZHOP), onDrawPFloat2Menu, SetZRaise, &fwretract.settings.retract_zraise); + EDIT_ITEM(ICON_FWRecSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_UNRETRACT_SPEED), onDrawPFloatMenu, SetRecoverSpeed, &fwretract.settings.retract_recover_feedrate_mm_s); #endif - ADDMENUITEM_P(ICON_Flow, GET_TEXT_F(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + EDIT_ITEM(ICON_Flow, GET_TEXT_F(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); #if ENABLED(ADVANCED_PAUSE_FEATURE) - ADDMENUITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENTCHANGE), onDrawMenuItem, ChangeFilament); + MENU_ITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENTCHANGE), onDrawMenuItem, ChangeFilament); #endif - ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen); + MENU_ITEM(ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN), onDrawMenuItem, DWIN_LockScreen); #if HAS_LCD_BRIGHTNESS - ADDMENUITEM_P(ICON_Brightness, F("LCD Brightness"), onDrawPInt8Menu, SetBrightness, &ui.brightness); + EDIT_ITEM(ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS), onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM(ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS_OFF), onDrawMenuItem, TurnOffBacklight); #endif } CurrentMenu->draw(); @@ -3442,19 +3320,19 @@ void Draw_Tune_Menu() { void Draw_Motion_Menu() { checkkey = Menu; - if (MotionMenu == nullptr) MotionMenu = new MenuClass(); + if (!MotionMenu) MotionMenu = new MenuClass(); if (CurrentMenu != MotionMenu) { CurrentMenu = MotionMenu; SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MOTION)); // TODO: Chinese, English "Motion" JPG DWINUI::MenuItemsPrepare(6); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); - ADDMENUITEM(ICON_MaxSpeed, GET_TEXT_F(MSG_SPEED), onDrawSpeed, Draw_MaxSpeed_Menu); - ADDMENUITEM(ICON_MaxAccelerated, GET_TEXT_F(MSG_ACCELERATION), onDrawAcc, Draw_MaxAccel_Menu); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); + MENU_ITEM(ICON_MaxSpeed, GET_TEXT_F(MSG_SPEED), onDrawSpeed, Draw_MaxSpeed_Menu); + MENU_ITEM(ICON_MaxAccelerated, GET_TEXT_F(MSG_ACCELERATION), onDrawAcc, Draw_MaxAccel_Menu); #if HAS_CLASSIC_JERK - ADDMENUITEM(ICON_MaxJerk, GET_TEXT_F(MSG_JERK), onDrawJerk, Draw_MaxJerk_Menu); + MENU_ITEM(ICON_MaxJerk, GET_TEXT_F(MSG_JERK), onDrawJerk, Draw_MaxJerk_Menu); #endif - ADDMENUITEM(ICON_Step, GET_TEXT_F(MSG_STEPS_PER_MM), onDrawSteps, Draw_Steps_Menu); - ADDMENUITEM_P(ICON_Flow, GET_TEXT_F(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + MENU_ITEM(ICON_Step, GET_TEXT_F(MSG_STEPS_PER_MM), onDrawSteps, Draw_Steps_Menu); + EDIT_ITEM(ICON_Flow, GET_TEXT_F(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); } CurrentMenu->draw(); } @@ -3462,17 +3340,17 @@ void Draw_Motion_Menu() { #if ENABLED(ADVANCED_PAUSE_FEATURE) void Draw_FilamentMan_Menu() { checkkey = Menu; - if (FilamentMenu == nullptr) FilamentMenu = new MenuClass(); + if (!FilamentMenu) FilamentMenu = new MenuClass(); if (CurrentMenu != FilamentMenu) { CurrentMenu = FilamentMenu; SetMenuTitle({0}, GET_TEXT_F(MSG_FILAMENT_MAN)); // TODO: Chinese, English "Filament Management" JPG DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); - ADDMENUITEM(ICON_Park, GET_TEXT_F(MSG_FILAMENT_PARK_ENABLED), onDrawMenuItem, ParkHead); - ADDMENUITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENTCHANGE), onDrawMenuItem, ChangeFilament); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); + MENU_ITEM(ICON_Park, GET_TEXT_F(MSG_FILAMENT_PARK_ENABLED), onDrawMenuItem, ParkHead); + MENU_ITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENTCHANGE), onDrawMenuItem, ChangeFilament); #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - ADDMENUITEM(ICON_FilUnload, GET_TEXT_F(MSG_FILAMENTUNLOAD), onDrawMenuItem, UnloadFilament); - ADDMENUITEM(ICON_FilLoad, GET_TEXT_F(MSG_FILAMENTLOAD), onDrawMenuItem, LoadFilament); + MENU_ITEM(ICON_FilUnload, GET_TEXT_F(MSG_FILAMENTUNLOAD), onDrawMenuItem, UnloadFilament); + MENU_ITEM(ICON_FilLoad, GET_TEXT_F(MSG_FILAMENTLOAD), onDrawMenuItem, LoadFilament); #endif } CurrentMenu->draw(); @@ -3482,17 +3360,17 @@ void Draw_Motion_Menu() { #if ENABLED(MESH_BED_LEVELING) void Draw_ManualMesh_Menu() { checkkey = Menu; - if (ManualMesh == nullptr) ManualMesh = new MenuClass(); + if (!ManualMesh) ManualMesh = new MenuClass(); if (CurrentMenu != ManualMesh) { CurrentMenu = ManualMesh; SetMenuTitle({0}, GET_TEXT_F(MSG_MANUAL_MESH)); // TODO: Chinese, English "Manual Mesh Leveling" JPG DWINUI::MenuItemsPrepare(6); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); - ADDMENUITEM(ICON_ManualMesh, GET_TEXT_F(MSG_LEVEL_BED), onDrawMenuItem, ManualMeshStart); - MMeshMoveZItem = ADDMENUITEM_P(ICON_Zoffset, GET_TEXT_F(MSG_MOVE_Z), onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_UBL_CONTINUE_MESH), onDrawMenuItem, ManualMeshContinue); - ADDMENUITEM(ICON_MeshViewer, GET_TEXT_F(MSG_MESH_VIEW), onDrawSubMenu, DWIN_MeshViewer); - ADDMENUITEM(ICON_MeshSave, GET_TEXT_F(MSG_UBL_SAVE_MESH), onDrawMenuItem, ManualMeshSave); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); + MENU_ITEM(ICON_ManualMesh, GET_TEXT_F(MSG_LEVEL_BED), onDrawMenuItem, ManualMeshStart); + MMeshMoveZItem = EDIT_ITEM(ICON_Zoffset, GET_TEXT_F(MSG_MOVE_Z), onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); + MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_UBL_CONTINUE_MESH), onDrawMenuItem, ManualMeshContinue); + MENU_ITEM(ICON_MeshViewer, GET_TEXT_F(MSG_MESH_VIEW), onDrawSubMenu, DWIN_MeshViewer); + MENU_ITEM(ICON_MeshSave, GET_TEXT_F(MSG_UBL_SAVE_MESH), onDrawMenuItem, ManualMeshSave); } CurrentMenu->draw(); } @@ -3506,18 +3384,18 @@ void Draw_Motion_Menu() { CurrentMenu = PreheatMenu; SetMenuTitle(cn, fstr); DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Temperature_Menu); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Temperature_Menu); #if HAS_HOTEND - ADDMENUITEM_P(ICON_SetEndTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Preheat].hotend_temp); + EDIT_ITEM(ICON_SetEndTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Preheat].hotend_temp); #endif #if HAS_HEATED_BED - ADDMENUITEM_P(ICON_SetBedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Preheat].bed_temp); + EDIT_ITEM(ICON_SetBedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Preheat].bed_temp); #endif #if HAS_FAN - ADDMENUITEM_P(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Preheat].fan_speed); + EDIT_ITEM(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Preheat].fan_speed); #endif #if ENABLED(EEPROM_SETTINGS) - ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom); #endif } CurrentMenu->draw(); @@ -3525,20 +3403,20 @@ void Draw_Motion_Menu() { void Draw_Preheat1_Menu() { HMI_value.Preheat = 0; - if (PreheatMenu == nullptr) PreheatMenu = new MenuClass(); + if (!PreheatMenu) PreheatMenu = new MenuClass(); Draw_Preheat_Menu({59, 16, 81, 14}, F(PREHEAT_1_LABEL " Preheat Settings")); // TODO: English "PLA Settings" JPG } void Draw_Preheat2_Menu() { HMI_value.Preheat = 1; - if (PreheatMenu == nullptr) PreheatMenu = new MenuClass(); + if (!PreheatMenu) PreheatMenu = new MenuClass(); Draw_Preheat_Menu({142, 16, 82, 14}, F(PREHEAT_2_LABEL " Preheat Settings")); // TODO: English "ABS Settings" JPG } #ifdef PREHEAT_3_LABEL void Draw_Preheat3_Menu() { HMI_value.Preheat = 2; - if (PreheatMenu == nullptr) PreheatMenu = new MenuClass(); + if (!PreheatMenu) PreheatMenu = new MenuClass(); #define PREHEAT_3_TITLE PREHEAT_3_LABEL " Preheat Set." Draw_Preheat_Menu({0}, F(PREHEAT_3_TITLE)); // TODO: Chinese, English "Custom Preheat Settings" JPG } @@ -3548,26 +3426,26 @@ void Draw_Motion_Menu() { void Draw_Temperature_Menu() { checkkey = Menu; - if (TemperatureMenu == nullptr) TemperatureMenu = new MenuClass(); + if (!TemperatureMenu) TemperatureMenu = new MenuClass(); if (CurrentMenu != TemperatureMenu) { CurrentMenu = TemperatureMenu; SetMenuTitle({236, 2, 28, 12}, GET_TEXT_F(MSG_TEMPERATURE)); DWINUI::MenuItemsPrepare(7); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); #if HAS_HOTEND - HotendTargetItem = ADDMENUITEM_P(ICON_SetEndTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM(ICON_SetEndTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = ADDMENUITEM_P(ICON_SetBedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM(ICON_SetBedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = ADDMENUITEM_P(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif #if HAS_HOTEND - ADDMENUITEM(ICON_SetPLAPreheat, F(PREHEAT_1_LABEL " Preheat Settings"), onDrawPLAPreheatSubMenu, Draw_Preheat1_Menu); - ADDMENUITEM(ICON_SetABSPreheat, F(PREHEAT_2_LABEL " Preheat Settings"), onDrawABSPreheatSubMenu, Draw_Preheat2_Menu); + MENU_ITEM(ICON_SetPLAPreheat, F(PREHEAT_1_LABEL " Preheat Settings"), onDrawPLAPreheatSubMenu, Draw_Preheat1_Menu); + MENU_ITEM(ICON_SetABSPreheat, F(PREHEAT_2_LABEL " Preheat Settings"), onDrawABSPreheatSubMenu, Draw_Preheat2_Menu); #ifdef PREHEAT_3_LABEL - ADDMENUITEM(ICON_SetCustomPreheat, PREHEAT_3_TITLE, onDrawSubMenu, Draw_Preheat3_Menu); + MENU_ITEM(ICON_SetCustomPreheat, PREHEAT_3_TITLE, onDrawSubMenu, Draw_Preheat3_Menu); #endif #endif } @@ -3576,17 +3454,17 @@ void Draw_Temperature_Menu() { void Draw_MaxSpeed_Menu() { checkkey = Menu; - if (MaxSpeedMenu == nullptr) MaxSpeedMenu = new MenuClass(); + if (!MaxSpeedMenu) MaxSpeedMenu = new MenuClass(); if (CurrentMenu != MaxSpeedMenu) { CurrentMenu = MaxSpeedMenu; SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MAXSPEED)); DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); - ADDMENUITEM_P(ICON_MaxSpeedX, GET_TEXT_F(MSG_MAXSPEED_X), onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); - ADDMENUITEM_P(ICON_MaxSpeedY, GET_TEXT_F(MSG_MAXSPEED_Y), onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); - ADDMENUITEM_P(ICON_MaxSpeedZ, GET_TEXT_F(MSG_MAXSPEED_Z), onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); + EDIT_ITEM(ICON_MaxSpeedX, GET_TEXT_F(MSG_MAXSPEED_X), onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); + EDIT_ITEM(ICON_MaxSpeedY, GET_TEXT_F(MSG_MAXSPEED_Y), onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); + EDIT_ITEM(ICON_MaxSpeedZ, GET_TEXT_F(MSG_MAXSPEED_Z), onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); #if HAS_HOTEND - ADDMENUITEM_P(ICON_MaxSpeedE, GET_TEXT_F(MSG_MAXSPEED_E), onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[Z_AXIS]); + EDIT_ITEM(ICON_MaxSpeedE, GET_TEXT_F(MSG_MAXSPEED_E), onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]); #endif } CurrentMenu->draw(); @@ -3594,17 +3472,17 @@ void Draw_MaxSpeed_Menu() { void Draw_MaxAccel_Menu() { checkkey = Menu; - if (MaxAccelMenu == nullptr) MaxAccelMenu = new MenuClass(); + if (!MaxAccelMenu) MaxAccelMenu = new MenuClass(); if (CurrentMenu != MaxAccelMenu) { CurrentMenu = MaxAccelMenu; SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_ACCELERATION)); DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); - ADDMENUITEM_P(ICON_MaxAccX, GET_TEXT_F(MSG_AMAX_A), onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); - ADDMENUITEM_P(ICON_MaxAccY, GET_TEXT_F(MSG_AMAX_B), onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); - ADDMENUITEM_P(ICON_MaxAccZ, GET_TEXT_F(MSG_AMAX_C), onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); + EDIT_ITEM(ICON_MaxAccX, GET_TEXT_F(MSG_AMAX_A), onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); + EDIT_ITEM(ICON_MaxAccY, GET_TEXT_F(MSG_AMAX_B), onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + EDIT_ITEM(ICON_MaxAccZ, GET_TEXT_F(MSG_AMAX_C), onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); #if HAS_HOTEND - ADDMENUITEM_P(ICON_MaxAccE, GET_TEXT_F(MSG_AMAX_E), onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); + EDIT_ITEM(ICON_MaxAccE, GET_TEXT_F(MSG_AMAX_E), onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); #endif } CurrentMenu->draw(); @@ -3613,17 +3491,17 @@ void Draw_MaxAccel_Menu() { #if HAS_CLASSIC_JERK void Draw_MaxJerk_Menu() { checkkey = Menu; - if (MaxJerkMenu == nullptr) MaxJerkMenu = new MenuClass(); + if (!MaxJerkMenu) MaxJerkMenu = new MenuClass(); if (CurrentMenu != MaxJerkMenu) { CurrentMenu = MaxJerkMenu; SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_JERK)); DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); - ADDMENUITEM_P(ICON_MaxSpeedJerkX, GET_TEXT_F(MSG_VA_JERK), onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk[X_AXIS]); - ADDMENUITEM_P(ICON_MaxSpeedJerkY, GET_TEXT_F(MSG_VB_JERK), onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk[Y_AXIS]); - ADDMENUITEM_P(ICON_MaxSpeedJerkZ, GET_TEXT_F(MSG_VC_JERK), onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk[Z_AXIS]); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); + EDIT_ITEM(ICON_MaxSpeedJerkX, GET_TEXT_F(MSG_VA_JERK), onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk[X_AXIS]); + EDIT_ITEM(ICON_MaxSpeedJerkY, GET_TEXT_F(MSG_VB_JERK), onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk[Y_AXIS]); + EDIT_ITEM(ICON_MaxSpeedJerkZ, GET_TEXT_F(MSG_VC_JERK), onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk[Z_AXIS]); #if HAS_HOTEND - ADDMENUITEM_P(ICON_MaxSpeedJerkE, GET_TEXT_F(MSG_VE_JERK), onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]); + EDIT_ITEM(ICON_MaxSpeedJerkE, GET_TEXT_F(MSG_VE_JERK), onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]); #endif } CurrentMenu->draw(); @@ -3632,17 +3510,17 @@ void Draw_MaxAccel_Menu() { void Draw_Steps_Menu() { checkkey = Menu; - if (StepsMenu == nullptr) StepsMenu = new MenuClass(); + if (!StepsMenu) StepsMenu = new MenuClass(); if (CurrentMenu != StepsMenu) { CurrentMenu = StepsMenu; SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_STEPS_PER_MM)); DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); - ADDMENUITEM_P(ICON_StepX, GET_TEXT_F(MSG_A_STEPS), onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); - ADDMENUITEM_P(ICON_StepY, GET_TEXT_F(MSG_B_STEPS), onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); - ADDMENUITEM_P(ICON_StepZ, GET_TEXT_F(MSG_C_STEPS), onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); + EDIT_ITEM(ICON_StepX, GET_TEXT_F(MSG_A_STEPS), onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); + EDIT_ITEM(ICON_StepY, GET_TEXT_F(MSG_B_STEPS), onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); + EDIT_ITEM(ICON_StepZ, GET_TEXT_F(MSG_C_STEPS), onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); #if HAS_HOTEND - ADDMENUITEM_P(ICON_StepE, GET_TEXT_F(MSG_E_STEPS), onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); + EDIT_ITEM(ICON_StepE, GET_TEXT_F(MSG_E_STEPS), onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); #endif } CurrentMenu->draw(); @@ -3651,20 +3529,20 @@ void Draw_Steps_Menu() { #if HAS_HOTEND void Draw_HotendPID_Menu() { checkkey = Menu; - if (HotendPIDMenu == nullptr) HotendPIDMenu = new MenuClass(); + if (!HotendPIDMenu) HotendPIDMenu = new MenuClass(); if (CurrentMenu != HotendPIDMenu) { CurrentMenu = HotendPIDMenu; CurrentMenu->MenuTitle.SetCaption(F("Hotend PID Settings")); DWINUI::MenuItemsPrepare(8); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); - ADDMENUITEM(ICON_PIDNozzle, F("Hotend PID"), onDrawMenuItem, HotendPID); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); - ADDMENUITEM_P(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); - ADDMENUITEM_P(ICON_PIDcycles, GET_TEXT_F(MSG_PID_CYCLE), onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); + MENU_ITEM(ICON_PIDNozzle, F("Hotend PID"), onDrawMenuItem, HotendPID); + EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); + EDIT_ITEM(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); + EDIT_ITEM(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); + EDIT_ITEM(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); + EDIT_ITEM(ICON_PIDcycles, GET_TEXT_F(MSG_PID_CYCLE), onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); #if ENABLED(EEPROM_SETTINGS) - ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom); #endif } CurrentMenu->draw(); @@ -3674,42 +3552,60 @@ void Draw_Steps_Menu() { #if HAS_HEATED_BED void Draw_BedPID_Menu() { checkkey = Menu; - if (BedPIDMenu == nullptr) BedPIDMenu = new MenuClass(); + if (!BedPIDMenu) BedPIDMenu = new MenuClass(); if (CurrentMenu != BedPIDMenu) { CurrentMenu = BedPIDMenu; CurrentMenu->MenuTitle.SetCaption(F("Bed PID Settings")); DWINUI::MenuItemsPrepare(8); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); - ADDMENUITEM(ICON_PIDNozzle, F("Bed PID"), onDrawMenuItem,BedPID); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); - ADDMENUITEM_P(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); - ADDMENUITEM_P(ICON_PIDcycles, GET_TEXT_F(MSG_PID_CYCLE), onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); + MENU_ITEM(ICON_PIDNozzle, F("Bed PID"), onDrawMenuItem,BedPID); + EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); + EDIT_ITEM(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); + EDIT_ITEM(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); + EDIT_ITEM(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); + EDIT_ITEM(ICON_PIDcycles, GET_TEXT_F(MSG_PID_CYCLE), onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); #if ENABLED(EEPROM_SETTINGS) - ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom); #endif } CurrentMenu->draw(); } #endif -#if EITHER(HAS_BED_PROBE, BABYSTEPPING) +#if HAS_BED_PROBE void Draw_ZOffsetWiz_Menu() { checkkey = Menu; - if (ZOffsetWizMenu == nullptr) ZOffsetWizMenu = new MenuClass(); + if (!ZOffsetWizMenu) ZOffsetWizMenu = new MenuClass(); if (CurrentMenu != ZOffsetWizMenu) { CurrentMenu = ZOffsetWizMenu; CurrentMenu->MenuTitle.SetCaption(GET_TEXT_F(MSG_PROBE_WIZARD)); DWINUI::MenuItemsPrepare(4); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_Prepare_Menu); - ADDMENUITEM(ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME), onDrawMenuItem, AutoHome); - ADDMENUITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0); - ADDMENUITEM_P(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_Prepare_Menu); + MENU_ITEM(ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME), onDrawMenuItem, AutoHome); + MENU_ITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0); + EDIT_ITEM(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); } CurrentMenu->draw(); if (!axis_is_trusted(Z_AXIS)) LCD_MESSAGE_F("WARNING: Z position unknown, move Z to home"); } #endif -#endif // DWIN_CREALITY_LCD_ENHANCED +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + void Draw_Homing_Menu() { + checkkey = Menu; + if (!HomingMenu) HomingMenu = new MenuClass(); + if (CurrentMenu != HomingMenu) { + CurrentMenu = HomingMenu; + CurrentMenu->MenuTitle.SetCaption(GET_TEXT_F(MSG_HOMING)); + DWINUI::MenuItemsPrepare(5); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_Prepare_Menu); + MENU_ITEM(ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME), onDrawMenuItem, AutoHome); + MENU_ITEM(ICON_HomeX, GET_TEXT_F(MSG_AUTO_HOME_X), onDrawMenuItem, HomeX); + MENU_ITEM(ICON_HomeY, GET_TEXT_F(MSG_AUTO_HOME_Y), onDrawMenuItem, HomeY); + MENU_ITEM(ICON_HomeZ, GET_TEXT_F(MSG_AUTO_HOME_Z), onDrawMenuItem, HomeZ); + } + CurrentMenu->draw(); + } +#endif + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h similarity index 54% rename from Marlin/src/lcd/e3v2/enhanced/dwin.h rename to Marlin/src/lcd/e3v2/proui/dwin.h index 05b81c101992..b61ed846dfcb 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -22,30 +22,18 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.15.2 + * Date: 2022/03/01 */ -#include "../../../inc/MarlinConfigPre.h" +#include "dwin_defines.h" #include "dwinui.h" #include "../common/encoder.h" #include "../../../libs/BL24CXX.h" -#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY) - #define HAS_ONESTEP_LEVELING 1 -#endif - -#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) - #define JUST_BABYSTEP 1 -#endif - -#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) - #define HAS_ZOFFSET_ITEM 1 -#endif - -static constexpr size_t eeprom_data_size = 64; +#include "../../../inc/MarlinConfig.h" enum processID : uint8_t { // Process ID @@ -58,17 +46,16 @@ enum processID : uint8_t { SetPFloat, SelectFile, PrintProcess, - PrintDone, - Info, - - // Popup Windows - Homing, + Popup, Leveling, - PauseOrStop, - FilamentPurge, - WaitResponse, Locked, - NothingToDo, + Reboot, + PrintDone, + ESDiagProcess, + WaitResponse, + Homing, + PidProcess, + NothingToDo }; enum pidresult_t : uint8_t { @@ -85,68 +72,37 @@ enum pidresult_t : uint8_t { typedef struct { int8_t Color[3]; // Color components + pidresult_t pidresult = PID_DONE; int8_t Preheat = 0; // Material Select 0: PLA, 1: ABS, 2: Custom AxisEnum axis = X_AXIS; // Axis Select - int32_t MaxValue = 0; // Auxiliar max integer/scaled float value - int32_t MinValue = 0; // Auxiliar min integer/scaled float value - int8_t dp = 0; // Auxiliar decimal places - int32_t Value = 0; // Auxiliar integer / scaled float value - int16_t *P_Int = nullptr; // Auxiliar pointer to 16 bit integer variable - float *P_Float = nullptr; // Auxiliar pointer to float variable - void (*Apply)() = nullptr; // Auxiliar apply function - void (*LiveUpdate)() = nullptr; // Auxiliar live update function } HMI_value_t; -typedef struct { - uint16_t Background_Color = Def_Background_Color; - uint16_t Cursor_color = Def_Cursor_color; - uint16_t TitleBg_color = Def_TitleBg_color; - uint16_t TitleTxt_color = Def_TitleTxt_color; - uint16_t Text_Color = Def_Text_Color; - uint16_t Selected_Color = Def_Selected_Color; - uint16_t SplitLine_Color = Def_SplitLine_Color; - uint16_t Highlight_Color = Def_Highlight_Color; - uint16_t StatusBg_Color = Def_StatusBg_Color; - uint16_t StatusTxt_Color = Def_StatusTxt_Color; - uint16_t PopupBg_color = Def_PopupBg_color; - uint16_t PopupTxt_Color = Def_PopupTxt_Color; - uint16_t AlertBg_Color = Def_AlertBg_Color; - uint16_t AlertTxt_Color = Def_AlertTxt_Color; - uint16_t PercentTxt_Color = Def_PercentTxt_Color; - uint16_t Barfill_Color = Def_Barfill_Color; - uint16_t Indicator_Color = Def_Indicator_Color; - uint16_t Coordinate_Color = Def_Coordinate_Color; - #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; - #endif -} HMI_data_t; - typedef struct { uint8_t language; + bool remain_flag:1; // remain was override by M73 bool pause_flag:1; // printing is paused bool pause_action:1; // flag a pause action + bool abort_flag:1; // printing is aborting + bool abort_action:1; // flag a aborting action bool print_finish:1; // print was finished bool select_flag:1; // Popup button selected bool home_flag:1; // homing in course bool heat_flag:1; // 0: heating done 1: during heating - bool lock_flag:1; // 0: lock called from AdvSet 1: lock called from Tune } HMI_flag_t; extern HMI_value_t HMI_value; extern HMI_flag_t HMI_flag; -extern HMI_data_t HMI_data; extern uint8_t checkkey; extern millis_t dwin_heat_time; +// Popups +#if HAS_HOTEND || HAS_HEATED_BED + void DWIN_Popup_Temperature(const bool toohigh); +#endif +#if ENABLED(POWER_LOSS_RECOVERY) + void Popup_PowerLossRecovery(); +#endif + // SD Card void HMI_SDCardInit(); void HMI_SDCardUpdate(); @@ -154,76 +110,93 @@ void HMI_SDCardUpdate(); // Other void Goto_PrintProcess(); void Goto_Main_Menu(); -void Goto_InfoMenu(); -void Draw_Select_Highlight(const bool sel); -void Draw_Status_Area(const bool with_update); // Status Area +void Goto_Info_Menu(); +void Goto_PowerLossRecovery(); +void Goto_ConfirmToPrint(); +void DWIN_Draw_Dashboard(const bool with_update); // Status Area void Draw_Main_Area(); // Redraw main area; void DWIN_Redraw_screen(); // Redraw all screen elements -void HMI_StartFrame(const bool with_update); // Prepare the menu view void HMI_MainMenu(); // Main process screen void HMI_SelectFile(); // File page void HMI_Printing(); // Print page void HMI_ReturnScreen(); // Return to previous screen before popups void ApplyExtMinT(); void HMI_SetLanguageCache(); // Set the languaje image cache +void RebootPrinter(); +#if ENABLED(BAUD_RATE_GCODE) + void HMI_SetBaudRate(); + void SetBaud115K(); + void SetBaud250K(); +#endif +#if ENABLED(EEPROM_SETTINGS) + void WriteEeprom(); + void ReadEeprom(); + void ResetEeprom(); +#endif -void HMI_Init(); -void HMI_Popup(); +void HMI_WaitForUser(); void HMI_SaveProcessID(const uint8_t id); void HMI_AudioFeedback(const bool success=true); void EachMomentUpdate(); void update_variable(); +void DWIN_InitScreen(); void DWIN_HandleScreen(); -void DWIN_Update(); void DWIN_CheckStatusMessage(); -void DWIN_StartHoming(); -void DWIN_CompletedHoming(); +void DWIN_HomingStart(); +void DWIN_HomingDone(); #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval); + void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); #endif -void DWIN_MeshLevelingStart(); -void DWIN_CompletedLeveling(); +void DWIN_LevelingStart(); +void DWIN_LevelingDone(); void DWIN_PidTuning(pidresult_t result); -void DWIN_Print_Started(const bool sd = false); +void DWIN_Print_Started(const bool sd=false); +void DWIN_Print_Pause(); +void DWIN_Print_Resume(); void DWIN_Print_Finished(); +void DWIN_Print_Aborted(); #if HAS_FILAMENT_SENSOR void DWIN_FilamentRunout(const uint8_t extruder); #endif void DWIN_Progress_Update(); void DWIN_Print_Header(const char *text); void DWIN_SetColorDefaults(); +void DWIN_ApplyColor(); void DWIN_StoreSettings(char *buff); void DWIN_LoadSettings(const char *buff); void DWIN_SetDataDefaults(); void DWIN_RebootScreen(); #if ENABLED(ADVANCED_PAUSE_FEATURE) + void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button=0); void Draw_Popup_FilamentPurge(); - void DWIN_Popup_FilamentPurge(); + void Goto_FilamentPurge(); void HMI_FilamentPurge(); #endif // Utility and extensions +void DWIN_LockScreen(); +void DWIN_UnLockScreen(); void HMI_LockScreen(); -void DWIN_LockScreen(const bool flag = true); #if HAS_MESH void DWIN_MeshViewer(); #endif - -// HMI user control functions -void HMI_Menu(); -void HMI_SetInt(); -void HMI_SetPInt(); -void HMI_SetIntNoDraw(); -void HMI_SetFloat(); -void HMI_SetPFloat(); +#if HAS_GCODE_PREVIEW + void HMI_ConfirmToPrint(); +#endif +#if HAS_ESDIAG + void Draw_EndStopDiag(); +#endif +#if ENABLED(PRINTCOUNTER) + void Draw_PrintStats(); +#endif // Menu drawing functions void Draw_Control_Menu(); void Draw_AdvancedSettings_Menu(); void Draw_Prepare_Menu(); void Draw_Move_Menu(); -void Draw_LevBedCorners_Menu(); +void Draw_Tramming_Menu(); #if HAS_HOME_OFFSET void Draw_HomeOffset_Menu(); #endif @@ -233,8 +206,18 @@ void Draw_LevBedCorners_Menu(); #if HAS_FILAMENT_SENSOR void Draw_FilSet_Menu(); #endif +#if ENABLED(NOZZLE_PARK_FEATURE) + void Draw_ParkPos_Menu(); +#endif +void Draw_PhySet_Menu(); void Draw_SelectColors_Menu(); void Draw_GetColor_Menu(); +#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + void Draw_CaseLight_Menu(); +#endif +#if ENABLED(LED_CONTROL_MENU) + void Draw_LedControl_Menu(); +#endif void Draw_Tune_Menu(); void Draw_Motion_Menu(); #if ENABLED(ADVANCED_PAUSE_FEATURE) @@ -262,23 +245,6 @@ void Draw_Steps_Menu(); #if EITHER(HAS_BED_PROBE, BABYSTEPPING) void Draw_ZOffsetWiz_Menu(); #endif - -// Popup windows - -void DWIN_Draw_Popup(const uint8_t icon, const char * const cmsg1, FSTR_P const fmsg2, uint8_t button=0); -void DWIN_Draw_Popup(const uint8_t icon, FSTR_P const fmsg1=nullptr, FSTR_P const fmsg2=nullptr, uint8_t button=0); - -template -void DWIN_Popup_Confirm(const uint8_t icon, T amsg1, U amsg2) { - HMI_SaveProcessID(WaitResponse); - DWIN_Draw_Popup(icon, amsg1, amsg2, ICON_Confirm_E); // Button Confirm - DWIN_UpdateLCD(); -} - -#if HAS_HOTEND || HAS_HEATED_BED - void DWIN_Popup_Temperature(const bool toohigh); -#endif -#if HAS_HOTEND - void Popup_Window_ETempTooLow(); +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + void Draw_Homing_Menu(); #endif -void Popup_Window_Resume(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h new file mode 100644 index 000000000000..5065bb94d75b --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -0,0 +1,142 @@ +/** + * 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 + +/** + * DWIN general defines and data structs for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.2 + * Date: 2022/02/28 + */ + +//#define DEBUG_DWIN 1 +//#define NEED_HEX_PRINT 1 + +#include "../../../inc/MarlinConfigPre.h" +#include + +#if DISABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + #error "INDIVIDUAL_AXIS_HOMING_SUBMENU is required with ProUI." +#endif +#if DISABLED(LCD_SET_PROGRESS_MANUALLY) + #error "LCD_SET_PROGRESS_MANUALLY is required with ProUI." +#endif +#if DISABLED(STATUS_MESSAGE_SCROLLING) + #error "STATUS_MESSAGE_SCROLLING is required with ProUI." +#endif +#if DISABLED(BAUD_RATE_GCODE) + #error "BAUD_RATE_GCODE is required with ProUI." +#endif +#if DISABLED(SOUND_MENU_ITEM) + #error "SOUND_MENU_ITEM is required with ProUI." +#endif +#if DISABLED(PRINTCOUNTER) + #error "PRINTCOUNTER is required with ProUI." +#endif + +#include "../common/dwin_color.h" +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" +#endif + +#define Def_Background_Color RGB( 1, 12, 8) +#define Def_Cursor_color RGB(20, 49, 31) +#define Def_TitleBg_color RGB( 0, 23, 16) +#define Def_TitleTxt_color Color_White +#define Def_Text_Color Color_White +#define Def_Selected_Color Select_Color +#define Def_SplitLine_Color RGB( 0, 23, 16) +#define Def_Highlight_Color Color_White +#define Def_StatusBg_Color RGB( 0, 23, 16) +#define Def_StatusTxt_Color Color_Yellow +#define Def_PopupBg_color Color_Bg_Window +#define Def_PopupTxt_Color Popup_Text_Color +#define Def_AlertBg_Color Color_Bg_Red +#define Def_AlertTxt_Color Color_Yellow +#define Def_PercentTxt_Color Percent_Color +#define Def_Barfill_Color BarFill_Color +#define Def_Indicator_Color Color_White +#define Def_Coordinate_Color Color_White +#define Def_Button_Color RGB( 0, 23, 16) + +#define HAS_ESDIAG 1 + +#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + #define Def_Leds_Color LEDColorWhite() +#endif +#if ENABLED(CASELIGHT_USES_BRIGHTNESS) + #define Def_CaseLight_Brightness 255 +#endif + +typedef struct { + // Color settings + uint16_t Background_Color = Def_Background_Color; + uint16_t Cursor_color = Def_Cursor_color; + uint16_t TitleBg_color = Def_TitleBg_color; + uint16_t TitleTxt_color = Def_TitleTxt_color; + uint16_t Text_Color = Def_Text_Color; + uint16_t Selected_Color = Def_Selected_Color; + uint16_t SplitLine_Color = Def_SplitLine_Color; + uint16_t Highlight_Color = Def_Highlight_Color; + uint16_t StatusBg_Color = Def_StatusBg_Color; + uint16_t StatusTxt_Color = Def_StatusTxt_Color; + uint16_t PopupBg_color = Def_PopupBg_color; + uint16_t PopupTxt_Color = Def_PopupTxt_Color; + uint16_t AlertBg_Color = Def_AlertBg_Color; + uint16_t AlertTxt_Color = Def_AlertTxt_Color; + uint16_t PercentTxt_Color = Def_PercentTxt_Color; + uint16_t Barfill_Color = Def_Barfill_Color; + uint16_t Indicator_Color = Def_Indicator_Color; + uint16_t Coordinate_Color = Def_Coordinate_Color; + // Temperatures + #if HAS_HOTEND && defined(PREHEAT_1_TEMP_HOTEND) + int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND; + #endif + #if HAS_HEATED_BED && defined(PREHEAT_1_TEMP_BED) + int16_t BedPidT = PREHEAT_1_TEMP_BED; + #endif + #if HAS_HOTEND || HAS_HEATED_BED + int16_t PidCycles = 10; + #endif + #if ENABLED(PREVENT_COLD_EXTRUSION) + int16_t ExtMinT = EXTRUDE_MINTEMP; + #endif + int16_t BedLevT = PREHEAT_1_TEMP_BED; + TERN_(BAUD_RATE_GCODE, bool Baud115K = false); + bool FullManualTramming = false; + // Led + #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + LEDColor Led_Color = Def_Leds_Color; + #endif + // Case Light + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + uint8_t CaseLight_Brightness = Def_CaseLight_Brightness; + #endif +} HMI_data_t; + +static constexpr size_t eeprom_data_size = 64; +extern HMI_data_t HMI_data; + +#if PREHEAT_1_TEMP_BED + #undef LEVELING_BED_TEMP + #define LEVELING_BED_TEMP HMI_data.BedLevT +#endif diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp similarity index 72% rename from Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp rename to Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp index 681b318a15e0..3da3fc808624 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp @@ -21,20 +21,68 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.9.1 + * Date: 2022/02/08 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../inc/MarlinConfig.h" #include "dwin_lcd.h" +/*---------------------------------------- Numeric related functions ----------------------------------------*/ + +// Draw a numeric value +// bShow: true=display background color; false=don't display background color +// zeroFill: true=zero fill; false=no zero fill +// signedMode: 1=signed; 0=unsigned +// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// fNum: Number of decimal digits +// x/y: Upper-left coordinate +// value: Integer value +void DWIN_Draw_Value(uint8_t bShow, bool signedMode, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) { + size_t i = 0; + DWIN_Byte(i, 0x14); + // Bit 7: bshow + // Bit 6: 1 = signed; 0 = unsigned number; + // Bit 5: zeroFill + // Bit 4: zeroMode + // Bit 3-0: size + DWIN_Byte(i, (bShow * 0x80) | (signedMode * 0x40) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); + DWIN_Word(i, color); + DWIN_Word(i, bColor); + DWIN_Byte(i, signedMode && (value >= 0) ? iNum + 1 : iNum); + DWIN_Byte(i, fNum); + DWIN_Word(i, x); + DWIN_Word(i, y); + // Write a big-endian 64 bit integer + const size_t p = i + 1; + for (size_t count = 8; count--;) { // 7..0 + ++i; + DWIN_SendBuf[p + count] = value; + value >>= 8; + } + DWIN_Send(i); +} + +// Draw a numeric value +// value: positive unscaled float value +void DWIN_Draw_Value(uint8_t bShow, bool signedMode, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + const int32_t val = round(value * POW(10, fNum)); + DWIN_Draw_Value(bShow, signedMode, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val); +} + /*---------------------------------------- Picture related functions ----------------------------------------*/ // Display QR code @@ -157,4 +205,4 @@ void DWIN_SRAMToPic(uint8_t picID) { // DWIN_Send(i); //} -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h similarity index 75% rename from Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h rename to Marlin/src/lcd/e3v2/proui/dwin_lcd.h index 43cb098b9138..cdffb96f2f30 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h @@ -22,14 +22,32 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.9.1 + * Date: 2022/02/08 */ #include "../common/dwin_api.h" +// Draw a numeric value +// bShow: true=display background color; false=don't display background color +// zeroFill: true=zero fill; false=no zero fill +// signedMode: 1=signed; 0=unsigned +// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// fNum: Number of decimal digits +// x/y: Upper-left coordinate +// value: Integer value +void DWIN_Draw_Value(uint8_t bShow, bool signedMode, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value); +// value: positive unscaled float value +void DWIN_Draw_Value(uint8_t bShow, bool signedMode, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + // Display QR code // The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix // QR_Pixel: The pixel size occupied by each point of the QR code: 0x01-0x0F (1-16) diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp new file mode 100644 index 000000000000..59b6c0d328ae --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -0,0 +1,95 @@ +/** + * 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 . + * + */ + +/** + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.1 + * Date: 2022/02/28 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_LCD_PROUI) + +#include "dwin.h" +#include "dwinui.h" +#include "dwin_popup.h" + +#include "../../../MarlinCore.h" // for wait_for_user + +popupDrawFunc_t popupDraw = nullptr; +popupClickFunc_t popupClick = nullptr; +popupChangeFunc_t popupChange = nullptr; + +uint16_t HighlightYPos = 280; + +void Draw_Select_Highlight(const bool sel, const uint16_t ypos) { + HighlightYPos = ypos; + HMI_flag.select_flag = sel; + const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color, + c2 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color; + DWIN_Draw_Rectangle(0, c1, 25, ypos - 1, 126, ypos + 38); + DWIN_Draw_Rectangle(0, c1, 24, ypos - 2, 127, ypos + 39); + DWIN_Draw_Rectangle(0, c2, 145, ypos - 1, 246, ypos + 38); + DWIN_Draw_Rectangle(0, c2, 144, ypos - 2, 247, ypos + 39); +} + +void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) { + HMI_SaveProcessID(WaitResponse); + DWIN_Draw_Popup(icon, fmsg1, fmsg2, BTN_Continue); // Button Continue + DWIN_UpdateLCD(); +} + +void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) { + DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), fmsg2); + DWINUI::Draw_Button(BTN_Confirm, 26, 280); + DWINUI::Draw_Button(BTN_Cancel, 146, 280); + Draw_Select_Highlight(HMI_flag.select_flag); + DWIN_UpdateLCD(); +} + +void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick/*=nullptr*/, const popupChangeFunc_t fnChange/*=nullptr*/) { + popupDraw = fnDraw; + popupClick = fnClick; + popupChange = fnChange; + HMI_SaveProcessID(Popup); + HMI_flag.select_flag = false; + popupDraw(); +} + +void HMI_Popup() { + if (!wait_for_user) { + if (popupClick) popupClick(); + return; + } + else { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_CW || encoder_diffState == ENCODER_DIFF_CCW) { + const bool change = encoder_diffState != ENCODER_DIFF_CW; + if (popupChange) popupChange(change); else Draw_Select_Highlight(change, HighlightYPos); + DWIN_UpdateLCD(); + } + } +} + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.h b/Marlin/src/lcd/e3v2/proui/dwin_popup.h new file mode 100644 index 000000000000..0d864994754b --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.h @@ -0,0 +1,73 @@ +/** + * 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 + +/** + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.1 + * Date: 2022/02/28 + */ + +#include "dwinui.h" +#include "dwin.h" + +typedef void (*popupDrawFunc_t)(); +typedef void (*popupClickFunc_t)(); +typedef void (*popupChangeFunc_t)(const bool state); +extern popupDrawFunc_t popupDraw; + +void Draw_Select_Highlight(const bool sel, const uint16_t ypos); +inline void Draw_Select_Highlight(const bool sel) { Draw_Select_Highlight(sel, 280); }; +void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2); +void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2); +void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick=nullptr, const popupChangeFunc_t fnChange=nullptr); +void HMI_Popup(); + +inline void Draw_Popup_Bkgd() { + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330); + DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330); +} + +template +void DWIN_Draw_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) { + DWINUI::ClearMenuArea(); + Draw_Popup_Bkgd(); + if (icon) DWINUI::Draw_Icon(icon, 101, 105); + if (amsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, amsg1); + if (amsg2) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 240, amsg2); + if (button) DWINUI::Draw_Button(button, 86, 280); +} + +template +void DWIN_Show_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) { + DWIN_Draw_Popup(icon, amsg1, amsg2, button); + DWIN_UpdateLCD(); +} + +template +void DWIN_Popup_Confirm(const uint8_t icon, T amsg1, U amsg2) { + HMI_SaveProcessID(WaitResponse); + DWIN_Draw_Popup(icon, amsg1, amsg2, BTN_Confirm); // Button Confirm + DWIN_UpdateLCD(); +} + diff --git a/Marlin/src/lcd/e3v2/enhanced/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp similarity index 78% rename from Marlin/src/lcd/e3v2/enhanced/dwinui.cpp rename to Marlin/src/lcd/e3v2/proui/dwinui.cpp index 824aca07f866..ddc494fc8492 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -21,19 +21,20 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.15.1 + * Date: 2022/02/25 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../inc/MarlinConfig.h" #include "dwin_lcd.h" #include "dwinui.h" +#include "dwin_defines.h" //#define DEBUG_OUT 1 #include "../../../core/debug_out.h" @@ -48,7 +49,9 @@ xy_int_t DWINUI::cursor = { 0 }; uint16_t DWINUI::pencolor = Color_White; uint16_t DWINUI::textcolor = Def_Text_Color; uint16_t DWINUI::backcolor = Def_Background_Color; +uint16_t DWINUI::buttoncolor = Def_Button_Color; uint8_t DWINUI::font = font8x16; +FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); void (*DWINUI::onCursorErase)(const int8_t line)=nullptr; void (*DWINUI::onCursorDraw)(const int8_t line)=nullptr; @@ -56,18 +59,16 @@ void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr; void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr; void DWINUI::init() { - DEBUG_ECHOPGM("\r\nDWIN handshake "); - delay(750); // Delay here or init later in the boot process - const bool success = DWIN_Handshake(); - if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error."); + TERN_(DEBUG_DWIN, SERIAL_ECHOPGM("\r\nDWIN handshake ")); + delay(750); // Delay for wait to wakeup screen + const bool hs = DWIN_Handshake(); + TERN(DEBUG_DWIN, SERIAL_ECHOLNF(hs ? F("ok.") : F("error.")), UNUSED(hs)); DWIN_Frame_SetDir(1); - TERN(SHOW_BOOTSCREEN,,DWIN_Frame_Clear(Color_Bg_Black)); - DWIN_UpdateLCD(); - cursor.x = 0; - cursor.y = 0; + cursor.reset(); pencolor = Color_White; textcolor = Def_Text_Color; backcolor = Def_Background_Color; + buttoncolor = Def_Button_Color; font = font8x16; } @@ -93,7 +94,7 @@ uint8_t DWINUI::fontWidth(uint8_t cfont) { } } -// Get font character heigh +// Get font character height uint8_t DWINUI::fontHeight(uint8_t cfont) { switch (cfont) { case font6x12 : return 12; @@ -110,20 +111,21 @@ uint8_t DWINUI::fontHeight(uint8_t cfont) { } } -// Get screen x coodinates from text column +// Get screen x coordinates from text column uint16_t DWINUI::ColToX(uint8_t col) { return col * fontWidth(font); } -// Get screen y coodinates from text row +// Get screen y coordinates from text row uint16_t DWINUI::RowToY(uint8_t row) { return row * fontHeight(font); } // Set text/number color -void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor) { +void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { textcolor = fgcolor; backcolor = bgcolor; + buttoncolor = alcolor; } void DWINUI::SetTextColor(uint16_t fgcolor) { textcolor = fgcolor; @@ -156,16 +158,22 @@ void DWINUI::MoveBy(xy_int_t point) { cursor += point; } -// Draw a Centered string using DWIN_WIDTH -void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { - const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * fontWidth(size)) / 2 - 1; +// Draw a Centered string using arbitrary x1 and x2 margins +void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { + const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1; DWIN_Draw_String(bShow, size, color, bColor, x, y, string); } +// // Draw a Centered string using DWIN_WIDTH +// void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { +// const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * fontWidth(size)) / 2 - 1; +// DWIN_Draw_String(bShow, size, color, bColor, x, y, string); +// } + // Draw a char at cursor position -void DWINUI::Draw_Char(const char c) { +void DWINUI::Draw_Char(uint16_t color, const char c) { const char string[2] = { c, 0}; - DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, 1); + DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, 1); MoveBy(fontWidth(font), 0); } @@ -182,21 +190,26 @@ void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rli MoveBy(strlen(string) * fontWidth(font), 0); } -// Draw a signed floating point number -// bShow: true=display background color; false=don't display background color -// zeroFill: true=zero fill; false=no zero fill -// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space -// size: Font size -// bColor: Background color -// iNum: Number of whole digits -// fNum: Number of decimal digits -// x/y: Upper-left point -// value: Float value -void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value < 0 ? -value : value); - DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, value < 0 ? F("-") : F(" ")); +// ------------------------- Buttons ------------------------------// + +void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { + DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2); + Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); } +void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { + switch (id) { + case BTN_Cancel : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break; + case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break; + case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break; + case BTN_Print : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break; + case BTN_Save : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break; + default: break; + } +} + +// -------------------------- Extra -------------------------------// + // Draw a circle // color: circle color // x: the abscissa of the center of the circle @@ -244,13 +257,12 @@ void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) { // color1 : Start color // color2 : End color uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) { - uint8_t B,G,R; - float n; - n = (float)(val-minv)/(maxv-minv); - R = (1-n)*GetRColor(color1) + n*GetRColor(color2); - G = (1-n)*GetGColor(color1) + n*GetGColor(color2); - B = (1-n)*GetBColor(color1) + n*GetBColor(color2); - return RGB(R,G,B); + uint8_t B, G, R; + const float n = (float)(val - minv) / (maxv - minv); + R = (1 - n) * GetRColor(color1) + n * GetRColor(color2); + G = (1 - n) * GetGColor(color1) + n * GetGColor(color2); + B = (1 - n) * GetBColor(color1) + n * GetBColor(color2); + return RGB(R, G, B); } // Color Interpolator through Red->Yellow->Green->Blue @@ -258,33 +270,27 @@ uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t colo // minv : Minimum value // maxv : Maximum value uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { - uint8_t B,G,R; - const uint8_t maxB = 28; - const uint8_t maxR = 28; - const uint8_t maxG = 38; + uint8_t B, G, R; + const uint8_t maxB = 28, maxR = 28, maxG = 38; const int16_t limv = _MAX(abs(minv), abs(maxv)); - float n; - if (minv>=0) { - n = (float)(val-minv)/(maxv-minv); - } else { - n = (float)val/limv; - } - n = _MIN(1, n); - n = _MAX(-1, n); + float n = minv >= 0 ? (float)(val - minv) / (maxv - minv) : (float)val / limv; + LIMIT(n, -1, 1); if (n < 0) { R = 0; - G = (1+n)*maxG; - B = (-n)*maxB; - } else if (n < 0.5) { - R = maxR*n*2; + G = (1 + n) * maxG; + B = (-n) * maxB; + } + else if (n < 0.5) { + R = maxR * n * 2; G = maxG; B = 0; - } else { + } + else { R = maxR; - G = maxG*(1-n); + G = maxG * (1 - n); B = 0; } - return RGB(R,G,B); + return RGB(R, G, B); } // Draw a checkbox @@ -450,4 +456,4 @@ MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, void value = val; }; -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/enhanced/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h similarity index 67% rename from Marlin/src/lcd/e3v2/enhanced/dwinui.h rename to Marlin/src/lcd/e3v2/proui/dwinui.h index 078b3cc58bf4..1504dcd30598 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -22,10 +22,10 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.15.1 + * Date: 2022/02/25 */ #include "dwin_lcd.h" @@ -34,54 +34,89 @@ #include "../common/dwin_color.h" // Extra Icons +#define ICON_AdvSet ICON_Language +#define ICON_BedSizeX ICON_PrintSize +#define ICON_BedSizeY ICON_PrintSize +#define ICON_Binary ICON_Contact #define ICON_Brightness ICON_Motion #define ICON_Cancel ICON_StockConfiguration #define ICON_CustomPreheat ICON_SetEndTemp #define ICON_Error ICON_TempTooHigh +#define ICON_ESDiag ICON_Info #define ICON_ExtrudeMinT ICON_HotendTemp #define ICON_FilLoad ICON_WriteEEPROM #define ICON_FilMan ICON_ResumeEEPROM #define ICON_FilSet ICON_ResumeEEPROM #define ICON_FilUnload ICON_ReadEEPROM #define ICON_Flow ICON_StepE -#define ICON_LevBed ICON_SetEndTemp +#define ICON_Folder ICON_More +#define ICON_FWRetLength ICON_StepE +#define ICON_FWRetSpeed ICON_Setspeed +#define ICON_FWRetZRaise ICON_MoveZ +#define ICON_FWRecSpeed ICON_Setspeed +#define ICON_HomeX ICON_MoveX +#define ICON_HomeY ICON_MoveY +#define ICON_HomeZ ICON_MoveZ +#define ICON_HomeOffset ICON_AdvSet +#define ICON_HomeOffsetX ICON_StepX +#define ICON_HomeOffsetY ICON_StepY +#define ICON_HomeOffsetZ ICON_StepZ +#define ICON_HSMode ICON_StockConfiguration +#define ICON_InvertE0 ICON_StepE +#define ICON_Tram ICON_SetEndTemp +#define ICON_Level ICON_HotendTemp #define ICON_Lock ICON_Cool #define ICON_ManualMesh ICON_HotendTemp +#define ICON_MaxPosX ICON_MoveX +#define ICON_MaxPosY ICON_MoveY +#define ICON_MaxPosZ ICON_MoveZ #define ICON_MeshNext ICON_Axis +#define ICON_MeshPoints ICON_SetEndTemp #define ICON_MeshSave ICON_WriteEEPROM #define ICON_MeshViewer ICON_HotendTemp #define ICON_MoveZ0 ICON_HotendTemp #define ICON_Park ICON_Motion +#define ICON_ParkPos ICON_AdvSet +#define ICON_ParkPosX ICON_StepX +#define ICON_ParkPosY ICON_StepY +#define ICON_ParkPosZ ICON_StepZ +#define ICON_PhySet ICON_PrintSize +#define ICON_PIDbed ICON_SetBedTemp #define ICON_PIDcycles ICON_ResumeEEPROM #define ICON_PIDValue ICON_Contact +#define ICON_PrintStats ICON_PrintTime +#define ICON_PrintStatsReset ICON_RemainTime +#define ICON_ProbeDeploy ICON_SetEndTemp +#define ICON_ProbeMargin ICON_PrintSize +#define ICON_ProbeOffsetX ICON_StepX +#define ICON_ProbeOffsetY ICON_StepY +#define ICON_ProbeOffsetZ ICON_StepZ #define ICON_ProbeSet ICON_SetEndTemp +#define ICON_ProbeStow ICON_SetEndTemp #define ICON_ProbeTest ICON_SetEndTemp +#define ICON_ProbeZSpeed ICON_MaxSpeedZ #define ICON_Pwrlossr ICON_Motion #define ICON_Reboot ICON_ResumeEEPROM #define ICON_Runout ICON_MaxAccE #define ICON_Scolor ICON_MaxSpeed +#define ICON_SetBaudRate ICON_Setspeed #define ICON_SetCustomPreheat ICON_SetEndTemp #define ICON_Sound ICON_Cool - -// Default UI Colors -#define Def_Background_Color Color_Bg_Black -#define Def_Cursor_color Rectangle_Color -#define Def_TitleBg_color Color_Bg_Blue -#define Def_TitleTxt_color Color_White -#define Def_Text_Color Color_White -#define Def_Selected_Color Select_Color -#define Def_SplitLine_Color Line_Color -#define Def_Highlight_Color Color_White -#define Def_StatusBg_Color RGB(0,20,20) -#define Def_StatusTxt_Color Color_Yellow -#define Def_PopupBg_color Color_Bg_Window -#define Def_PopupTxt_Color Popup_Text_Color -#define Def_AlertBg_Color Color_Bg_Red -#define Def_AlertTxt_Color Color_Yellow -#define Def_PercentTxt_Color Percent_Color -#define Def_Barfill_Color BarFill_Color -#define Def_Indicator_Color Color_White -#define Def_Coordinate_Color Color_White +#define ICON_CaseLight ICON_Motion +#define ICON_LedControl ICON_Motion + +// Buttons +#define BTN_Continue 85 +#define BTN_Cancel 87 +#define BTN_Confirm 89 +#define BTN_Print 90 +#define BTN_Save 91 + +// Extended and default UI Colors +#define Color_Black 0 +#define Color_Green RGB(0,63,0) +#define Color_Aqua RGB(0,63,31) +#define Color_Blue RGB(0,0,31) // UI element defines and constants #define DWIN_FONT_MENU font8x16 @@ -89,7 +124,11 @@ #define DWIN_FONT_HEAD font10x20 #define DWIN_FONT_ALERT font10x20 #define STATUS_Y 354 -#define LCD_WIDTH (DWIN_WIDTH / 8) +#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 + +// Minimum unit (0.1) : multiple (10) +#define UNITFDIGITS 1 +#define MINUNITMULT POW(10, UNITFDIGITS) constexpr uint16_t TITLE_HEIGHT = 30, // Title bar height MLINE = 53, // Menu line height @@ -111,8 +150,8 @@ constexpr uint16_t TITLE_HEIGHT = 30, // Title bar heig #define MBASE(L) (MYPOS(L) + CAPOFF) // Create and add a MenuItem object to the menu array -#define ADDMENUITEM(V...) DWINUI::MenuItemsAdd(new MenuItemClass(V)) -#define ADDMENUITEM_P(V...) DWINUI::MenuItemsAdd(new MenuItemPtrClass(V)) +#define MENU_ITEM(V...) DWINUI::MenuItemsAdd(new MenuItemClass(V)) +#define EDIT_ITEM(V...) DWINUI::MenuItemsAdd(new MenuItemPtrClass(V)) typedef struct { uint16_t left, top, right, bottom; } rect_t; typedef struct { uint16_t x, y, w, h; } frame_rect_t; @@ -182,7 +221,9 @@ namespace DWINUI { extern uint16_t pencolor; extern uint16_t textcolor; extern uint16_t backcolor; + extern uint16_t buttoncolor; extern uint8_t font; + extern FSTR_P const Author; extern void (*onCursorErase)(const int8_t line); extern void (*onCursorDraw)(const int8_t line); @@ -197,18 +238,20 @@ namespace DWINUI { // Get font character width uint8_t fontWidth(uint8_t cfont); + inline uint8_t fontWidth() { return fontWidth(font); }; - // Get font character heigh + // Get font character height uint8_t fontHeight(uint8_t cfont); + inline uint8_t fontHeight() { return fontHeight(font); }; - // Get screen x coodinates from text column + // Get screen x coordinates from text column uint16_t ColToX(uint8_t col); - // Get screen y coodinates from text row + // Get screen y coordinates from text row uint16_t RowToY(uint8_t row); // Set text/number color - void SetColors(uint16_t fgcolor, uint16_t bgcolor); + void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor); void SetTextColor(uint16_t fgcolor); void SetBackgroundColor(uint16_t bgcolor); @@ -236,6 +279,17 @@ namespace DWINUI { DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y); } + // Extend a frame box + // v: value to extend + inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) { + frame_rect_t t; + t.x = frame.x - v; + t.y = frame.y - v; + t.w = frame.w + 2 * v; + t.h = frame.h + 2 * v; + return t; + } + // Draw an Icon with transparent background from the library ICON // icon: Icon ID // x/y: Upper-left point @@ -243,6 +297,13 @@ namespace DWINUI { DWIN_ICON_Show(ICON, icon, x, y); } + // Draw an Icon from the library ICON with its background + // icon: Icon ID + // x/y: Upper-left point + inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) { + DWIN_ICON_Show(true, false, false, ICON, icon, x, y); + } + // Draw a positive integer // bShow: true=display background color; false=don't display background color // zeroFill: true=zero fill; false=no zero fill @@ -254,26 +315,56 @@ namespace DWINUI { // x/y: Upper-left coordinate // value: Integer value inline void Draw_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, x, y, value); + DWIN_Draw_Value(bShow, 0, zeroFill, zeroMode, size, color, bColor, iNum, 0, x, y, value); } inline void Draw_Int(uint8_t iNum, long value) { - DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + DWIN_Draw_Value(false, 0, true, 0, font, textcolor, backcolor, iNum, 0, cursor.x, cursor.y, value); MoveBy(iNum * fontWidth(font), 0); } inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value); + DWIN_Draw_Value(false, 0, true, 0, font, textcolor, backcolor, iNum, 0, x, y, value); } inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(false, true, 0, font, color, backcolor, iNum, x, y, value); + DWIN_Draw_Value(false, 0, true, 0, font, color, backcolor, iNum, 0, x, y, value); } inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(true, true, 0, font, color, bColor, iNum, x, y, value); + DWIN_Draw_Value(true, 0, true, 0, font, color, bColor, iNum, 0, x, y, value); } inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(true, true, 0, size, color, bColor, iNum, x, y, value); + DWIN_Draw_Value(true, 0, true, 0, size, color, bColor, iNum, 0, x, y, value); + } + + // Draw a signed integer + // bShow: true=display background color; false=don't display background color + // zeroFill: true=zero fill; false=no zero fill + // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space + // size: Font size + // color: Character color + // bColor: Background color + // iNum: Number of digits + // x/y: Upper-left coordinate + // value: Integer value + inline void Draw_Signed_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(bShow, 1, zeroFill, zeroMode, size, color, bColor, iNum, 0, x, y, value); + } + inline void Draw_Signed_Int(uint8_t iNum, long value) { + DWIN_Draw_Value(false, 1, true, 0, font, textcolor, backcolor, iNum, 0, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(font), 0); + } + inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(false, 1, true, 0, font, textcolor, backcolor, iNum, 0, x, y, value); + } + inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(false, 1, true, 0, font, color, backcolor, iNum, 0, x, y, value); + } + inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(true, 1, true, 0, font, color, bColor, iNum, 0, x, y, value); + } + inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(true, 1, true, 0, size, color, bColor, iNum, 0, x, y, value); } - // Draw a floating point number + // Draw a positive floating point number // bShow: true=display background color; false=don't display background color // zeroFill: true=zero fill; false=no zero fill // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space @@ -285,23 +376,23 @@ namespace DWINUI { // x/y: Upper-left point // value: Float value inline void Draw_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(bShow, 0, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + DWIN_Draw_Value(false, 0, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); MoveBy((iNum + fNum + 1) * fontWidth(font), 0); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + DWIN_Draw_Value(false, 0, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Float(uint16_t color, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, color, backcolor, iNum, fNum, x, y, value); + DWIN_Draw_Value(false, 0, true, 0, font, color, backcolor, iNum, fNum, x, y, value); } inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(true, true, 0, font, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(true, 0, true, 0, font, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(true, true, 0, size, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(true, 0, true, 0, size, color, bColor, iNum, fNum, x, y, value); } // Draw a signed floating point number @@ -309,31 +400,35 @@ namespace DWINUI { // zeroFill: true=zero fill; false=no zero fill // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space // size: Font size + // color: Character color // bColor: Background color // iNum: Number of whole digits // fNum: Number of decimal digits // x/y: Upper-left point // value: Float value - void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + inline void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + DWIN_Draw_Value(bShow, 1, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value); + } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + DWIN_Draw_Value(false, 1, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); MoveBy((iNum + fNum + 1) * fontWidth(font), 0); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + DWIN_Draw_Value(false, 1, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(false, true, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); + DWIN_Draw_Value(false, 1, true, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(true, true, 0, font, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(true, 1, true, 0, font, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(true, true, 0, size, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(true, 1, true, 0, size, color, bColor, iNum, fNum, x, y, value); } // Draw a char at cursor position - void Draw_Char(const char c); + void Draw_Char(uint16_t color, const char c); + inline void Draw_Char(const char c) { Draw_Char(textcolor, c); } // Draw a string at cursor position // color: Character color @@ -386,7 +481,10 @@ namespace DWINUI { // bColor: Background color // y: Upper coordinate of the string // *string: The string - void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string); + void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); + inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { + Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); + } inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); } @@ -412,6 +510,14 @@ namespace DWINUI { Draw_CenteredString(false, font, textcolor, backcolor, y, title); } + // Draw a box + // mode: 0=frame, 1=fill, 2=XOR fill + // color: Rectangle color + // frame: Box coordinates and size + inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) { + DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h); + } + // Draw a circle // Color: circle color // x: abscissa of the center of the circle @@ -440,6 +546,17 @@ namespace DWINUI { // color2 : End color uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2); + // ------------------------- Buttons ------------------------------// + + void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption); + inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) { + Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption)); + } + inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) { + Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption); + } + void Draw_Button(uint8_t id, uint16_t x, uint16_t y); + // -------------------------- Extra -------------------------------// // Draw a circle filled with color diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp new file mode 100644 index 000000000000..74eb94e751af --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -0,0 +1,108 @@ +/** + * 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 . + * + */ + +/** + * DWIN End Stops diagnostic page for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.2.2 + * Date: 2022/02/24 + */ + +#include "dwin_defines.h" + +#if BOTH(DWIN_LCD_PROUI, HAS_ESDIAG) + +#include "endstop_diag.h" + +#include "../../../core/types.h" +#include "../../marlinui.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin_popup.h" +#include "dwin.h" + +#if HAS_FILAMENT_SENSOR + #include "../../../feature/runout.h" +#endif + +#if HAS_BED_PROBE + #include "../../../module/probe.h" +#endif + +ESDiagClass ESDiag; + +void draw_es_label(FSTR_P const flabel=nullptr) { + DWINUI::cursor.x = 40; + if (flabel) DWINUI::Draw_String(F(flabel)); + DWINUI::Draw_String(F(": ")); + DWINUI::MoveBy(0, 25); +} + +void draw_es_state(const bool is_hit) { + const uint8_t LM = 130; + DWINUI::cursor.x = LM; + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); + is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN)); + DWINUI::MoveBy(0, 25); +} + +void ESDiagClass::Draw() { + Title.ShowCaption(F("End-stops Diagnostic")); + DWINUI::ClearMenuArea(); + Draw_Popup_Bkgd(); + DWINUI::Draw_Button(BTN_Continue, 86, 250); + DWINUI::cursor.y = 80; + #define ES_LABEL(S) draw_es_label(F(STR_##S)) + #if HAS_X_MIN + ES_LABEL(X_MIN); + #endif + #if HAS_Y_MIN + ES_LABEL(Y_MIN); + #endif + #if HAS_Z_MIN + ES_LABEL(Z_MIN); + #endif + #if HAS_FILAMENT_SENSOR + draw_es_label(F(STR_FILAMENT)); + #endif + Update(); +} + +void ESDiagClass::Update() { + DWINUI::cursor.y = 80; + #define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING) + #if HAS_X_MIN + ES_REPORT(X_MIN); + #endif + #if HAS_Y_MIN + ES_REPORT(Y_MIN); + #endif + #if HAS_Z_MIN + ES_REPORT(Z_MIN); + #endif + #if HAS_FILAMENT_SENSOR + draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE); + #endif + DWIN_UpdateLCD(); +} + +#endif // DWIN_LCD_PROUI && HAS_ESDIAG diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.h b/Marlin/src/lcd/e3v2/proui/endstop_diag.h new file mode 100644 index 000000000000..316a1e1ed3d9 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.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 + +/** + * DWIN End Stops diagnostic page for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.2.3 + * Date: 2022/02/24 + */ + +class ESDiagClass { +public: + void Draw(); + void Update(); +}; + +extern ESDiagClass ESDiag; diff --git a/Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp similarity index 91% rename from Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp rename to Marlin/src/lcd/e3v2/proui/lockscreen.cpp index ca772184f148..2895c01544b0 100644 --- a/Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -21,15 +21,15 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.6.3 - * Date: 2021/09/08 + * Lock screen implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.1 + * Date: 2021/11/09 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../core/types.h" #include "dwin_lcd.h" @@ -41,6 +41,7 @@ LockScreenClass lockScreen; uint8_t LockScreenClass::lock_pos = 0; bool LockScreenClass::unlocked = false; +uint8_t LockScreenClass::rprocess = 0; void LockScreenClass::init() { lock_pos = 0; @@ -72,4 +73,4 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) { DWIN_UpdateLCD(); } -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/enhanced/lockscreen.h b/Marlin/src/lcd/e3v2/proui/lockscreen.h similarity index 85% rename from Marlin/src/lcd/e3v2/enhanced/lockscreen.h rename to Marlin/src/lcd/e3v2/proui/lockscreen.h index f0c4c1fde8d2..ec967fe2db7c 100644 --- a/Marlin/src/lcd/e3v2/enhanced/lockscreen.h +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.h @@ -22,10 +22,10 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.6.3 - * Date: 2021/09/08 + * Lock screen implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.1 + * Date: 2021/11/09 */ #include "../common/encoder.h" @@ -36,10 +36,11 @@ class LockScreenClass { static bool unlocked; static uint8_t lock_pos; public: + static uint8_t rprocess; static void init(); static void onEncoder(EncoderState encoder_diffState); static void draw(); - static inline bool isUnlocked() { return unlocked; } + static bool isUnlocked() { return unlocked; } }; extern LockScreenClass lockScreen; diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp new file mode 100644 index 000000000000..6dfcb8595c87 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/menus.cpp @@ -0,0 +1,370 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * Menu functions for ProUI + * Author: Miguel A. Risco-Castillo + * Version: 1.2.1 + * Date: 2022/02/25 + * + * This program 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 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 Lesser General Public License + * along with this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_LCD_PROUI) + +#include "../common/encoder.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" +#include "menus.h" + +MenuData_t MenuData; + +// Menuitem Drawing functions ================================================= + +void Draw_Title(TitleClass* title) { + DWIN_Draw_Rectangle(1, HMI_data.TitleBg_color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); + if (title->frameid) + DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1); + else + DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); +} + +void Draw_Menu(MenuClass* menu) { + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + DWIN_Draw_Rectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); +} + +void Draw_Menu_Cursor(const int8_t line) { + DWIN_Draw_Rectangle(1, HMI_data.Cursor_color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); +} + +void Erase_Menu_Cursor(const int8_t line) { + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); +} + +void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * const label /*=nullptr*/, bool more /*=false*/) { + if (icon) DWINUI::Draw_Icon(icon, ICOX, MBASE(line) - 3); + if (label) DWINUI::Draw_String(LBLX, MBASE(line) - 1, (char*)label); + if (more) DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); +} + +void Draw_Chkb_Line(const uint8_t line, const bool checked) { + DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 16, MBASE(line) - 1, checked); +} + +void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value /*=0*/) { + DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); +} + +void onDrawMenuItem(MenuItemClass* menuitem, int8_t line) { + if (menuitem->icon) DWINUI::Draw_Icon(menuitem->icon, ICOX, MBASE(line) - 3); + if (menuitem->frameid) + DWIN_Frame_AreaCopy(menuitem->frameid, menuitem->frame.left, menuitem->frame.top, menuitem->frame.right, menuitem->frame.bottom, LBLX, MBASE(line)); + else if (menuitem->caption) + DWINUI::Draw_String(LBLX, MBASE(line) - 1, menuitem->caption); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); +} + +void onDrawSubMenu(MenuItemClass* menuitem, int8_t line) { + onDrawMenuItem(menuitem, line); + DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); +} + +void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, int32_t value) { + onDrawMenuItem(menuitem, line); + Draw_Menu_IntValue(HMI_data.Background_Color, line, 4, value); +} + +void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line) { + const int16_t value = *(int16_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line) { + const uint8_t value = *(uint8_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) { + const uint32_t value = *(uint32_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) { + onDrawMenuItem(menuitem, line); + DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value); +} + +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { + const float value = *(float*)static_cast(menuitem)->value; + const int8_t dp = UNITFDIGITS; + onDrawFloatMenu(menuitem, line, dp, value); +} + +void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { + const float value = *(float*)static_cast(menuitem)->value; + onDrawFloatMenu(menuitem, line, 2, value); +} + +void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) { + onDrawMenuItem(menuitem, line); + Draw_Chkb_Line(line, checked); +} + +//----------------------------------------------------------------------------- +// On click functions +//----------------------------------------------------------------------------- + +// Generic onclick event without draw +// process: process id HMI destiny +// lo: low limit +// hi: high limit +// dp: decimal places, 0 for integers +// val: value / scaled value +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + checkkey = process; + MenuData.MinValue = lo; + MenuData.MaxValue = hi; + MenuData.dp = dp; + MenuData.Apply = Apply; + MenuData.LiveUpdate = LiveUpdate; + MenuData.Value = val; + EncoderRate.enabled = true; +} + +// Generic onclick event for integer values +// process: process id HMI destiny +// lo: scaled low limit +// hi: scaled high limit +// val: value +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate); + Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, MenuData.Value); +} + +// Generic onclick event for float values +// process: process id HMI destiny +// lo: scaled low limit +// hi: scaled high limit +// val: value +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + const int32_t value = round(val * POW(10, dp)); + SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate); + DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val); +} + +// Generic onclick event for integer values +// lo: scaled low limit +// hi: scaled high limit +// val: value +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + SetValueOnClick(SetInt, lo, hi, val, Apply, LiveUpdate); +} + +// Generic onclick event for set pointer to 16 bit uinteger values +// lo: low limit +// hi: high limit +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + MenuData.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; + const int32_t value = *MenuData.P_Int; + SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate); +} + +// Generic onclick event for float values +// process: process id HMI destiny +// lo: low limit +// hi: high limit +// dp: decimal places +// val: value +void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + SetValueOnClick(SetFloat, lo, hi, dp, val, Apply, LiveUpdate); +} + +// Generic onclick event for set pointer to float values +// lo: low limit +// hi: high limit +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + SetValueOnClick(SetPFloat, lo, hi, dp, *MenuData.P_Float, Apply, LiveUpdate); +} + +// HMI Control functions ====================================================== + +// Generic menu control using the encoder +void HMI_Menu() { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + if (CurrentMenu) { + if (encoder_diffState == ENCODER_DIFF_ENTER) + CurrentMenu->onClick(); + else + CurrentMenu->onScroll(encoder_diffState == ENCODER_DIFF_CW); + } +} + +// Get an integer value using the encoder without draw anything +// lo: low limit +// hi: high limit +// Return value: +// 0 : no change +// 1 : live change +// 2 : apply change +int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (Apply_Encoder(encoder_diffState, MenuData.Value)) { + EncoderRate.enabled = false; + checkkey = Menu; + return 2; + } + LIMIT(MenuData.Value, lo, hi); + return 1; + } + return 0; +} + +// Get an integer value using the encoder +// lo: low limit +// hi: high limit +// Return value: +// 0 : no change +// 1 : live change +// 2 : apply change +int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (Apply_Encoder(encoder_diffState, MenuData.Value)) { + EncoderRate.enabled = false; + DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Background_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); + checkkey = Menu; + return 2; + } + LIMIT(MenuData.Value, lo, hi); + DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); + return 1; + } + return 0; +} + +// Set an integer using the encoder +void HMI_SetInt() { + int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; break; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Set an integer without drawing +void HMI_SetIntNoDraw() { + int8_t val = HMI_GetIntNoDraw(MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; break; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Set an integer pointer variable using the encoder +void HMI_SetPInt() { + int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: *MenuData.P_Int = MenuData.Value; if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Get a scaled float value using the encoder +// dp: decimal places +// lo: scaled low limit +// hi: scaled high limit +// Return value: +// 0 : no change +// 1 : live change +// 2 : apply change +int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (Apply_Encoder(encoder_diffState, MenuData.Value)) { + EncoderRate.enabled = false; + DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); + checkkey = Menu; + return 2; + } + LIMIT(MenuData.Value, lo, hi); + DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); + return 1; + } + return 0; +} + +// Set a scaled float using the encoder +void HMI_SetFloat() { + const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Set a scaled float pointer variable using the encoder +void HMI_SetPFloat() { + const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: *MenuData.P_Float = MenuData.Value / POW(10, MenuData.dp); if (MenuData.Apply) MenuData.Apply(); break; + } +} + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h new file mode 100644 index 000000000000..0147c1616b31 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -0,0 +1,94 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * Menu functions for ProUI + * Author: Miguel A. Risco-Castillo + * Version: 1.2.1 + * Date: 2022/02/25 + * + * This program 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 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 Lesser General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "dwinui.h" + +typedef struct { + int32_t MaxValue = 0; // Auxiliar max integer/scaled float value + int32_t MinValue = 0; // Auxiliar min integer/scaled float value + int8_t dp = 0; // Auxiliar decimal places + int32_t Value = 0; // Auxiliar integer / scaled float value + int16_t *P_Int = nullptr; // Auxiliar pointer to 16 bit integer variable + float *P_Float = nullptr; // Auxiliar pointer to float variable + void (*Apply)() = nullptr; // Auxiliar apply function + void (*LiveUpdate)() = nullptr; // Auxiliar live update function +} MenuData_t; + +extern MenuData_t MenuData; + +// Menuitem Drawing functions ================================================= +void Draw_Title(TitleClass* title); +void Draw_Menu(MenuClass* menu); +void Draw_Menu_Cursor(const int8_t line); +void Erase_Menu_Cursor(const int8_t line); +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false); +void Draw_Chkb_Line(const uint8_t line, const bool checked); +void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value=0); +void onDrawMenuItem(MenuItemClass* menuitem, int8_t line); +void onDrawSubMenu(MenuItemClass* menuitem, int8_t line); +void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, int32_t value); +void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line); +void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line); +void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line); +void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value); +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line); +void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line); +void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked); + +// On click functions ========================================================= +void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); + +// HMI user control functions ================================================= +void HMI_Menu(); +void HMI_SetInt(); +void HMI_SetPInt(); +void HMI_SetIntNoDraw(); +void HMI_SetFloat(); +void HMI_SetPFloat(); diff --git a/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp similarity index 50% rename from Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp rename to Marlin/src/lcd/e3v2/proui/meshviewer.cpp index 3824d63b2b48..0b22ae98d5ef 100644 --- a/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -1,12 +1,13 @@ /** - * DWIN Mesh Viewer - * Author: Miguel A. Risco-Castillo - * version: 3.8.1 - * Date: 2021/11/06 + * 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 Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the License, or + * 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, @@ -14,14 +15,21 @@ * 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 Lesser General Public License + * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ +/** + * Mesh Viewer for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * version: 3.12.1 + * Date: 2022/02/24 + */ + #include "../../../inc/MarlinConfigPre.h" -#if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_MESH) +#if BOTH(DWIN_LCD_PROUI, HAS_MESH) #include "meshviewer.h" @@ -30,49 +38,53 @@ #include "dwin_lcd.h" #include "dwinui.h" #include "dwin.h" +#include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" MeshViewerClass MeshViewer; -void MeshViewerClass::Draw() { +void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8_t sizey) { const int8_t mx = 25, my = 25; // Margins - const int16_t stx = (DWIN_WIDTH - 2 * mx) / (GRID_MAX_POINTS_X - 1), // Steps - sty = (DWIN_WIDTH - 2 * my) / (GRID_MAX_POINTS_Y - 1); + const int16_t stx = (DWIN_WIDTH - 2 * mx) / (sizex - 1), // Steps + sty = (DWIN_WIDTH - 2 * my) / (sizey - 1); const int8_t rmax = _MIN(mx - 2, stx / 2); const int8_t rmin = 7; - int16_t zmesh[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y], maxz =-32000, minz = 32000; + int16_t zmesh[sizex][sizey]; #define px(xp) (mx + (xp) * stx) #define py(yp) (30 + DWIN_WIDTH - my - (yp) * sty) #define rm(z) ((z - minz) * (rmax - rmin) / _MAX(1, (maxz - minz)) + rmin) - #define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 12, py(yp) - 6, zv) + #define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 18, py(yp) - 6, zv) #define DrawMeshHLine(yp) DWIN_Draw_HLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx) - #define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(GRID_MAX_POINTS_Y - 1), DWIN_WIDTH - 2 * my) - GRID_LOOP(x, y) { - const float v = Z_VALUES(x,y) * 100; + #define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(sizey - 1), DWIN_WIDTH - 2 * my) + int16_t maxz =-32000; int16_t minz = 32000; avg = 0; + LOOP_L_N(y, sizey) LOOP_L_N(x, sizex) { + const float v = isnan(zval[x][y]) ? 0 : round(zval[x][y] * 100); zmesh[x][y] = v; + avg += v; NOLESS(maxz, v); NOMORE(minz, v); } - Title.ShowCaption(F("Mesh Viewer")); + max = (float)maxz / 100; + min = (float)minz / 100; + avg = avg / (100 * sizex * sizey); DWINUI::ClearMenuArea(); - DWINUI::Draw_Icon(ICON_Continue_E, 86, 305); - DWIN_Draw_Rectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(GRID_MAX_POINTS_X - 1), py(GRID_MAX_POINTS_Y - 1)); - LOOP_S_L_N(x, 1, GRID_MAX_POINTS_X - 1) DrawMeshVLine(x); - LOOP_S_L_N(y, 1, GRID_MAX_POINTS_Y - 1) DrawMeshHLine(y); - LOOP_L_N(y, GRID_MAX_POINTS_Y) { + DWIN_Draw_Rectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(sizex - 1), py(sizey - 1)); + LOOP_S_L_N(x, 1, sizex - 1) DrawMeshVLine(x); + LOOP_S_L_N(y, 1, sizey - 1) DrawMeshHLine(y); + LOOP_L_N(y, sizey) { watchdog_refresh(); - LOOP_L_N(x, GRID_MAX_POINTS_X) { + LOOP_L_N(x, sizex) { uint16_t color = DWINUI::RainbowInt(zmesh[x][y], _MIN(-5, minz), _MAX(5, maxz)); uint8_t radius = rm(zmesh[x][y]); DWINUI::Draw_FillCircle(color, px(x), py(y), radius); - if (GRID_MAX_POINTS_X < 9) - DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 12, py(y) - 6, Z_VALUES(x,y)); + if (sizex < 9) + DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 18, py(y) - 6, zval[x][y]); else { char str_1[9]; str_1[0] = 0; switch (zmesh[x][y]) { case -999 ... -100: - DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y)); + DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 18, py(y) - 6, zval[x][y]); break; case -99 ... -1: sprintf_P(str_1, PSTR("-.%02i"), -zmesh[x][y]); @@ -84,7 +96,7 @@ void MeshViewerClass::Draw() { sprintf_P(str_1, PSTR(".%02i"), zmesh[x][y]); break; case 100 ... 999: - DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y)); + DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 18, py(y) - 6, zval[x][y]); break; } if (str_1[0]) @@ -92,11 +104,25 @@ void MeshViewerClass::Draw() { } } } +} + +void MeshViewerClass::Draw(bool withsave /*= false*/) { + Title.ShowCaption(F("Mesh Viewer")); + DrawMesh(Z_VALUES_ARR, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); + if (withsave) { + DWINUI::Draw_Button(BTN_Save, 26, 305); + DWINUI::Draw_Button(BTN_Continue, 146, 305); + Draw_Select_Highlight(HMI_flag.select_flag, 305); + } else DWINUI::Draw_Button(BTN_Continue, 86, 305); char str_1[6], str_2[6] = ""; ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), - dtostrf((float)minz / 100, 1, 2, str_1), - dtostrf((float)maxz / 100, 1, 2, str_2) + dtostrf(min, 1, 2, str_1), + dtostrf(max, 1, 2, str_2) ); } -#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_MESH +void Draw_MeshViewer() { MeshViewer.Draw(true); } +void onClick_MeshViewer() { if (HMI_flag.select_flag) WriteEeprom(); HMI_ReturnScreen(); } +void Goto_MeshViewer() { if (leveling_is_valid()) Goto_Popup(Draw_MeshViewer, onClick_MeshViewer); else HMI_ReturnScreen(); } + +#endif // DWIN_LCD_PROUI && HAS_MESH diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.h b/Marlin/src/lcd/e3v2/proui/meshviewer.h new file mode 100644 index 000000000000..f914bab4ae23 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -0,0 +1,43 @@ +/** + * 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 "../../../core/types.h" +#include "../../../feature/bedlevel/bedlevel.h" + +/** + * Mesh Viewer for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * version: 3.12.1 + * Date: 2022/02/24 + */ + +class MeshViewerClass { +public: + float avg, max, min; + void Draw(bool withsave = false); + void DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8_t sizey); +}; + +extern MeshViewerClass MeshViewer; + +void Goto_MeshViewer(); diff --git a/Marlin/src/lcd/e3v2/proui/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp new file mode 100644 index 000000000000..d4ca4ca2255f --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -0,0 +1,82 @@ +/** + * 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 . + * + */ + +/** + * Print Stats page for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.3.0 + * Date: 2022/02/24 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if BOTH(DWIN_LCD_PROUI, PRINTCOUNTER) + +#include "printstats.h" + +#include "../../../core/types.h" +#include "../../../MarlinCore.h" +#include "../../marlinui.h" +#include "../../../module/printcounter.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin_popup.h" +#include "dwin.h" + +PrintStatsClass PrintStats; + +void PrintStatsClass::Draw() { + char buf[50] = ""; + char str[30] = ""; + constexpr int8_t MRG = 30; + + Title.ShowCaption(GET_TEXT_F(MSG_INFO_STATS_MENU)); + DWINUI::ClearMenuArea(); + Draw_Popup_Bkgd(); + DWINUI::Draw_Button(BTN_Continue, 86, 250); + printStatistics ps = print_job_timer.getStats(); + + sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_PRINT_COUNT), ps.totalPrints); + DWINUI::Draw_String(MRG, 80, buf); + sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_COMPLETED_PRINTS), ps.finishedPrints); + DWINUI::Draw_String(MRG, 100, buf); + duration_t(print_job_timer.getStats().printTime).toDigital(str, true); + sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_TIME), str); + DWINUI::Draw_String(MRG, 120, buf); + duration_t(print_job_timer.getStats().longestPrint).toDigital(str, true); + sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_LONGEST), str); + DWINUI::Draw_String(MRG, 140, buf); + sprintf_P(buf, PSTR(S_FMT ": %s m"), GET_TEXT(MSG_INFO_PRINT_FILAMENT), dtostrf(ps.filamentUsed / 1000, 1, 2, str)); + DWINUI::Draw_String(MRG, 160, buf); +} + +void PrintStatsClass::Reset() { + print_job_timer.initStats(); + HMI_AudioFeedback(); +} + +void Goto_PrintStats() { + PrintStats.Draw(); + HMI_SaveProcessID(WaitResponse); +} + +#endif // DWIN_LCD_PROUI && PRINTCOUNTER diff --git a/Marlin/src/lcd/e3v2/proui/printstats.h b/Marlin/src/lcd/e3v2/proui/printstats.h new file mode 100644 index 000000000000..705c923da41b --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/printstats.h @@ -0,0 +1,39 @@ +/** + * 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 + +/** + * Print Stats page for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.3.0 + * Date: 2022/02/24 + */ + +class PrintStatsClass { +public: + static void Draw(); + static void Reset(); +}; + +extern PrintStatsClass PrintStats; + +void Goto_PrintStats(); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp b/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp index f49b17acc190..0ef818666837 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp @@ -155,7 +155,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) { if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder // The new panel ignores entries that don't end in .GCO or .gcode so add and pad them. - if (paneltype == AC_panel_new) { + if (paneltype <= AC_panel_new) { TFTSer.println("<<.GCO"); Chiron.SendtoTFTLN(F(".. .gcode")); } @@ -177,7 +177,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) { void FileNavigator::sendFile(panel_type_t paneltype) { if (filelist.isDir()) { // Add mandatory tags for new panel otherwise lines are ignored. - if (paneltype == AC_panel_new) { + if (paneltype <= AC_panel_new) { TFTSer.print(filelist.shortFilename()); TFTSer.println(".GCO"); TFTSer.print(filelist.shortFilename()); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp index 7a58963c11fe..b9fe8f967c0d 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp @@ -57,14 +57,16 @@ namespace ExtUI { void onPrintTimerStarted() { Chiron.TimerEvent(AC_timer_started); } void onPrintTimerPaused() { Chiron.TimerEvent(AC_timer_paused); } - void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); } + void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); } + void onPrintDone() {} + void onFilamentRunout(const extruder_t) { Chiron.FilamentRunout(); } + void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); } void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} void onFactoryReset() {} @@ -103,7 +105,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index 9f558e3a9867..fa85de2a8e84 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -86,13 +86,23 @@ void ChironTFT::Startup() { TFTSer.begin(115200); // wait for the TFT panel to initialise and finish the animation - delay_ms(250); + safe_delay(1000); // There are different panels for the Chiron with slightly different commands // So we need to know what we are working with. - // Panel type can be defined otherwise detect it automatically - if (panel_type == AC_panel_unknown) DetectPanelType(); + switch (panel_type) { + case AC_panel_new: + SERIAL_ECHOLNF(AC_msg_new_panel_set); + break; + case AC_panel_standard: + SERIAL_ECHOLNF(AC_msg_old_panel_set); + break; + default: + SERIAL_ECHOLNF(AC_msg_auto_panel_detection); + DetectPanelType(); + break; + } // Signal Board has reset SendtoTFTLN(AC_msg_main_board_has_reset); @@ -243,7 +253,7 @@ void ChironTFT::StatusChange(const char * const msg) { case AC_printer_probing: { // If probing completes ok save the mesh and park // Ignore the custom machine name - if (strcmp_P(msg + strlen(CUSTOM_MACHINE_NAME), MARLIN_msg_ready) == 0) { + if (strcmp_P(msg + strlen(MACHINE_NAME), MARLIN_msg_ready) == 0) { injectCommands(F("M500\nG27")); SendtoTFTLN(AC_msg_probing_complete); printer_state = AC_printer_idle; @@ -358,15 +368,14 @@ bool ChironTFT::ReadTFTCommand() { } int8_t ChironTFT::FindToken(char c) { - int8_t pos = 0; - do { + for (int8_t pos = 0; pos < command_len; pos++) { if (panel_command[pos] == c) { #if ACDEBUG(AC_INFO) SERIAL_ECHOLNPGM("Tpos:", pos, " ", c); #endif return pos; } - } while(++pos < command_len); + } #if ACDEBUG(AC_INFO) SERIAL_ECHOLNPGM("Not found: ", c); #endif @@ -433,7 +442,7 @@ void ChironTFT::SendFileList(int8_t startindex) { } void ChironTFT::SelectFile() { - if (panel_type == AC_panel_new) { + if (panel_type <= AC_panel_new) { strncpy(selectedfile, panel_command + 4, command_len - 3); selectedfile[command_len - 4] = '\0'; } @@ -456,7 +465,7 @@ void ChironTFT::SelectFile() { break; default: // enter sub folder // for new panel remove the '.GCO' tag that was added to the end of the path - if (panel_type == AC_panel_new) + if (panel_type <= AC_panel_new) selectedfile[strlen(selectedfile) - 4] = '\0'; filenavigator.changeDIR(selectedfile); SendtoTFTLN(AC_msg_sd_file_open_failed); @@ -469,8 +478,8 @@ void ChironTFT::ProcessPanelRequest() { // Break these up into logical blocks // as its easier to navigate than one huge switch case! int8_t tpos = FindToken('A'); // Panel request are 'A0' - 'A36' - if (tpos != -1) { - const int8_t req = atoi(&panel_command[tpos+1]); + if (tpos >= 0) { + const int8_t req = atoi(&panel_command[tpos + 1]); // Information requests A0 - A8 and A33 if (req <= 8 || req == 33) PanelInfo(req); @@ -486,16 +495,18 @@ void ChironTFT::ProcessPanelRequest() { // This may be a response to a panel type detection query if (panel_type == AC_panel_unknown) { tpos = FindToken('S'); // old panel will respond to 'SIZE' with 'SXY 480 320' - if (tpos != -1) { - if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') { + if (tpos >= 0) { + if (panel_command[tpos + 1] == 'X' && panel_command[tpos + 2] =='Y') { panel_type = AC_panel_standard; SERIAL_ECHOLNF(AC_msg_old_panel_detected); } } else { - tpos = FindToken('['); // new panel will respond to 'J200' with '[0]=0' - if (tpos != -1) { - if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') { + // new panel will respond to 'J200' with '[0]=0' + // it seems only after a power cycle so detection assumes a new panel + tpos = FindToken('['); + if (tpos >= 0) { + if (panel_command[tpos + 1] == '0' && panel_command[tpos + 2] ==']') { panel_type = AC_panel_new; SERIAL_ECHOLNF(AC_msg_new_panel_detected); } @@ -623,18 +634,18 @@ void ChironTFT::PanelAction(uint8_t req) { SelectFile(); break; - case 14: { // A14 Start Printing + case 14: // A14 Start Printing // Allows printer to restart the job if we don't want to recover if (printer_state == AC_printer_resuming_from_power_outage) { injectCommands(F("M1000 C")); // Cancel recovery printer_state = AC_printer_idle; } #if ACDebugLevel >= 1 - SERIAL_ECHOLNPAIR_F("Print: ", selectedfile); + SERIAL_ECHOLNPGM("Print: ", selectedfile); #endif printFile(selectedfile); SendtoTFTLN(AC_msg_print_from_sd_card); - } break; + break; case 15: // A15 Resuming from outage if (printer_state == AC_printer_resuming_from_power_outage) { @@ -801,28 +812,25 @@ void ChironTFT::PanelProcess(uint8_t req) { } } break; - case 30: { // A30 Auto leveling - if (FindToken('S') != -1) { // Start probing New panel adds spaces.. + case 30: // A30 Auto leveling + if (FindToken('S') >= 0) { // Start probing New panel adds spaces.. // Ignore request if printing if (isPrinting()) SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling else { - - SendtoTFTLN(AC_msg_start_probing); injectCommands(F("G28\nG29")); printer_state = AC_printer_probing; } } - else { + else SendtoTFTLN(AC_msg_start_probing); // Just enter levelling menu - } - } break; + break; - case 31: { // A31 Adjust all Probe Points + case 31: // A31 Adjust all Probe Points // The tokens can occur in different places on the new panel so we need to find it. - if (FindToken('C') != -1) { // Restore and apply original offsets + if (FindToken('C') >= 0) { // Restore and apply original offsets if (!isPrinting()) { injectCommands(F("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; @@ -830,7 +838,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } - else if (FindToken('D') != -1) { // Save Z Offset tables and restore leveling state + else if (FindToken('D') >= 0) { // Save Z Offset tables and restore leveling state if (!isPrinting()) { setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made injectCommands(F("M500")); @@ -839,7 +847,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } - else if (FindToken('G') != -1) { // Get current offset + else if (FindToken('G') >= 0) { // Get current offset SendtoTFT(F("A31V ")); // When printing use the live z Offset position // we will use babystepping to move the print head @@ -853,7 +861,7 @@ void ChironTFT::PanelProcess(uint8_t req) { else { int8_t tokenpos = FindToken('S'); - if (tokenpos != -1) { // Set offset (adjusts all points by value) + if (tokenpos >= 0) { // Set offset (adjusts all points by value) float Zshift = atof(&panel_command[tokenpos+1]); setSoftEndstopState(false); // disable endstops // Allow temporary Z position nudging during print @@ -907,18 +915,18 @@ void ChironTFT::PanelProcess(uint8_t req) { } } } - } break; + break; - case 32: { // A32 clean leveling beep flag + case 32: // A32 clean leveling beep flag // Ignore request if printing //if (isPrinting()) break; //injectCommands(F("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000")); //TFTSer.println(); - } break; + break; // A33 firmware info request see PanelInfo() - case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123 + case 34: // A34 Adjust single mesh point A34 C/S X1 Y1 V123 if (panel_command[3] == 'C') { // Restore original offsets injectCommands(F("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; @@ -950,7 +958,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } } - } break; + break; case 36: // A36 Auto leveling for new TFT bet that was a typo in the panel code! SendtoTFTLN(AC_msg_start_probing); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h index 0fd7770cddfb..e3609b5408df 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h @@ -89,6 +89,10 @@ #define AC_msg_mesh_changes_saved F("Mesh changes saved.") #define AC_msg_old_panel_detected F("Standard TFT panel detected!") #define AC_msg_new_panel_detected F("New TFT panel detected!") +#define AC_msg_auto_panel_detection F("Auto detect panel type (assuming new panel)") +#define AC_msg_old_panel_set F("Set for standard TFT panel.") +#define AC_msg_new_panel_set F("Set for new TFT panel.") + #define AC_msg_powerloss_recovery F("Resuming from power outage! select the same SD file then press resume") // Error messages must not contain spaces #define AC_msg_error_bed_temp F("Abnormal_bed_temp") @@ -161,10 +165,10 @@ namespace Anycubic { AC_menu_change_to_file, AC_menu_change_to_command }; - enum panel_type_t : uint8_t { + enum panel_type_t : uint8_t { // order is important here as we assume new panel if type is unknown AC_panel_unknown, - AC_panel_standard, - AC_panel_new + AC_panel_new, + AC_panel_standard }; enum last_error_t : uint8_t { AC_error_none, diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp index c0e1b4457897..da8f4e26a0ff 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp @@ -54,8 +54,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -95,7 +95,8 @@ namespace ExtUI { #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 98534ba65f87..729d4547a862 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -63,7 +63,7 @@ char AnycubicTFTClass::SelectedDirectory[30]; char AnycubicTFTClass::SelectedFile[FILENAME_LENGTH]; // Serial helpers -static void sendNewLine(void) { LCD_SERIAL.write('\r'); LCD_SERIAL.write('\n'); } +static void sendNewLine() { LCD_SERIAL.write('\r'); LCD_SERIAL.write('\n'); } static void send(const char *str) { LCD_SERIAL.print(str); } static void send_P(PGM_P str) { while (const char c = pgm_read_byte(str++)) diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.h b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.h index fa62b545dcdd..8fcadc1553fd 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.h +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.h @@ -39,7 +39,7 @@ enum AnycubicMediaPauseState { AMPAUSESTATE_PARKING, AMPAUSESTATE_PARKED, AMPAUSESTATE_FILAMENT_OUT, - AMPAUSESTATE_FIAMENT_PRUGING, + AMPAUSESTATE_FILAMENT_PURGING, AMPAUSESTATE_HEATER_TIMEOUT, AMPAUSESTATE_REHEATING, AMPAUSESTATE_REHEAT_FINISHED diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp index 262dcea36483..e2f11502e7d8 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp @@ -46,6 +46,12 @@ DGUSDisplay dgusdisplay; +#ifdef DEBUG_DGUSLCD_COMM + #define DEBUGLCDCOMM_ECHOPGM DEBUG_ECHOPGM +#else + #define DEBUGLCDCOMM_ECHOPGM(...) NOOP +#endif + // Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable constexpr uint8_t DGUS_HEADER1 = 0x5A; constexpr uint8_t DGUS_HEADER2 = 0xA5; @@ -154,19 +160,19 @@ void DGUSDisplay::ProcessRx() { case DGUS_IDLE: // Waiting for the first header byte receivedbyte = LCD_SERIAL.read(); - //DEBUG_ECHOPGM("< ",x); + //DEBUGLCDCOMM_ECHOPGM("< ", receivedbyte); if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN; break; case DGUS_HEADER1_SEEN: // Waiting for the second header byte receivedbyte = LCD_SERIAL.read(); - //DEBUG_ECHOPGM(" ",x); + //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte); rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE; break; case DGUS_HEADER2_SEEN: // Waiting for the length byte rx_datagram_len = LCD_SERIAL.read(); - DEBUG_ECHOPGM(" (", rx_datagram_len, ") "); + //DEBUGLCDCOMM_ECHOPGM(" (", rx_datagram_len, ") "); // Telegram min len is 3 (command and one word of payload) rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE; @@ -178,20 +184,20 @@ void DGUSDisplay::ProcessRx() { Initialized = true; // We've talked to it, so we defined it as initialized. uint8_t command = LCD_SERIAL.read(); - DEBUG_ECHOPGM("# ", command); + //DEBUGLCDCOMM_ECHOPGM("# ", command); uint8_t readlen = rx_datagram_len - 1; // command is part of len. unsigned char tmp[rx_datagram_len - 1]; unsigned char *ptmp = tmp; while (readlen--) { receivedbyte = LCD_SERIAL.read(); - DEBUG_ECHOPGM(" ", receivedbyte); + //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte); *ptmp++ = receivedbyte; } - DEBUG_ECHOPGM(" # "); + //DEBUGLCDCOMM_ECHOPGM(" # "); // mostly we'll get this: 5A A5 03 82 4F 4B -- ACK on 0x82, so discard it. if (command == DGUS_CMD_WRITEVAR && 'O' == tmp[0] && 'K' == tmp[1]) { - DEBUG_ECHOLNPGM(">"); + //DEBUGLCDCOMM_ECHOPGM(">"); rx_datagram_state = DGUS_IDLE; break; } @@ -253,16 +259,16 @@ void DGUSDisplay::loop() { rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE; uint8_t DGUSDisplay::rx_datagram_len = 0; -bool DGUSDisplay::Initialized = false; -bool DGUSDisplay::no_reentrance = false; +bool DGUSDisplay::Initialized = false, + DGUSDisplay::no_reentrance = false; // A SW memory barrier, to ensure GCC does not overoptimize loops #define sw_barrier() asm volatile("": : :"memory"); bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) { - // DEBUG_ECHOPGM("populate_VPVar ", VP); + //DEBUG_ECHOPGM("populate_VPVar ", VP); const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP); - // DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp); + //DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp); if (!pvp) return false; memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable)); return true; diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h index e486a0014570..17303c689bb9 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h @@ -29,6 +29,9 @@ #include // size_t +//#define DEBUG_DGUSLCD +//#define DEBUG_DGUSLCD_COMM + #if HAS_BED_PROBE #include "../../../module/probe.h" #endif @@ -95,14 +98,14 @@ class DGUSDisplay { // Checks two things: Can we confirm the presence of the display and has we initialized it. // (both boils down that the display answered to our chatting) - static inline bool isInitialized() { return Initialized; } + static bool isInitialized() { return Initialized; } private: static void WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen); static void WritePGM(const char str[], uint8_t len); static void ProcessRx(); - static inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); } + static uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); } static rx_datagram_state_t rx_datagram_state; static uint8_t rx_datagram_len; static bool Initialized, no_reentrance; diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 2b00fd16f8e2..9b25f8aeb13f 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -55,14 +55,14 @@ void (*DGUSScreenHandler::confirm_action_cb)() = nullptr; #if ENABLED(SDSUPPORT) int16_t DGUSScreenHandler::top_file = 0, DGUSScreenHandler::file_to_print = 0; - static ExtUI::FileList filelist; + ExtUI::FileList filelist; #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) filament_data_t filament_data; #endif -void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { +void DGUSScreenHandler::sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { DGUS_VP_Variable ramcopy; if (populate_VPVar(VP_MSGSTR1, &ramcopy)) { ramcopy.memadr = (void*) line1; @@ -76,13 +76,15 @@ void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, con ramcopy.memadr = (void*) line3; l3inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); } - if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { - ramcopy.memadr = (void*) line4; - l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); - } + #ifdef VP_MSGSTR4 + if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { + ramcopy.memadr = (void*) line4; + l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); + } + #endif } -void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1, bool l2, bool l3, bool l4) { +void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1, bool l2, bool l3, bool l4) { if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first. PopToOldScreen(); @@ -344,6 +346,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); } + #endif // SDSUPPORT void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { @@ -508,9 +511,9 @@ void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; default: return; } - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::setAxisSteps_per_mm(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(axis)); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel return; } @@ -531,9 +534,9 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo #endif #endif } - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::setAxisSteps_per_mm(value, extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } diff --git a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp index 04ba6b95c2c7..0041be82769f 100644 --- a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp +++ b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp @@ -73,8 +73,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -113,7 +113,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp index 750acece1c06..e7466bfe087f 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; @@ -268,7 +268,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { #endif } - DEBUG_ECHOLNPAIR_F("V3:", newvalue); + DEBUG_ECHOLNPGM("V3:", newvalue); *(float *)var.memadr = newvalue; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h index bb0bd2bd3b42..0bdf06ed7d57 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h @@ -37,15 +37,15 @@ class DGUSScreenHandler { // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); } - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); } - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. static void setstatusmessage(const char *msg); @@ -213,13 +213,13 @@ class DGUSScreenHandler { } // Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } + static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } // Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } + static bool IsScreenComplete() { return ScreenComplete; } - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } + static DGUSLCD_Screens getCurrentScreen() { return current_screen; } - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } + static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } private: static DGUSLCD_Screens current_screen; //< currently on screen diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp index f3f361f84e83..4c850183da0f 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp @@ -222,12 +222,12 @@ 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 - OPTARG(HAS_HOTEND, VP_E0_STEP_PER_MM) - OPTARG(HAS_MULTI_HOTEND, VP_E1_STEP_PER_MM) - , 0x0000 + VP_X_STEP_PER_MM, + VP_Y_STEP_PER_MM, + VP_Z_STEP_PER_MM, + OPTITEM(HAS_HOTEND, VP_E0_STEP_PER_MM) + OPTITEM(HAS_MULTI_HOTEND, VP_E1_STEP_PER_MM) + 0x0000 }; const uint16_t VPList_PIDE0[] PROGMEM = { diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp index 79a3cb91038d..d64ac143b031 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; @@ -268,7 +268,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { #endif } - DEBUG_ECHOLNPAIR_F("V3:", newvalue); + DEBUG_ECHOLNPGM("V3:", newvalue); *(float *)var.memadr = newvalue; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h index bb0bd2bd3b42..0bdf06ed7d57 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h @@ -37,15 +37,15 @@ class DGUSScreenHandler { // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); } - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); } - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. static void setstatusmessage(const char *msg); @@ -213,13 +213,13 @@ class DGUSScreenHandler { } // Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } + static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } // Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } + static bool IsScreenComplete() { return ScreenComplete; } - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } + static DGUSLCD_Screens getCurrentScreen() { return current_screen; } - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } + static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } private: static DGUSLCD_Screens current_screen; //< currently on screen diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index ff013967c08d..a7ec99d98281 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -40,7 +40,7 @@ #endif #if ENABLED(POWER_LOSS_RECOVERY) - #include "../../../../../feature/powerloss.h" + #include "../../../../feature/powerloss.h" #endif #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h index 407782f5595e..9ec2304a36aa 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h @@ -100,7 +100,7 @@ extern EX_FILAMENT_DEF ex_filament; typedef enum { UNRUNOUT_STATUS, RUNOUT_STATUS, - RUNOUT_WAITTING_STATUS, + RUNOUT_WAITING_STATUS, RUNOUT_BEGIN_STATUS, } RUNOUT_MKS_STATUS_DEF; diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 0e2a971fd1b8..bfa070df8736 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -48,7 +48,7 @@ #endif #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; #endif bool DGUSAutoTurnOff = false; @@ -65,7 +65,7 @@ void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t *line1, const uint1 dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true); } -void DGUSScreenHandler::sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) { +void DGUSScreenHandler::sendinfoscreen_en_mks(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4) { dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true); @@ -195,7 +195,7 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { case 0: { // Resume auto cs = getCurrentScreen(); - if (runout_mks.runout_status != RUNOUT_WAITTING_STATUS && runout_mks.runout_status != UNRUNOUT_STATUS) { + if (runout_mks.runout_status != RUNOUT_WAITING_STATUS && runout_mks.runout_status != UNRUNOUT_STATUS) { if (cs == MKSLCD_SCREEN_PRINT || cs == MKSLCD_SCREEN_PAUSE) GotoScreen(MKSLCD_SCREEN_PAUSE); return; @@ -399,7 +399,7 @@ void DGUSScreenHandler::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) { #if HAS_BED_PROBE int32_t value = swap32(*(int32_t *)val_ptr); float Offset = value / 100.0f; - DEBUG_ECHOLNPAIR_F("\nget int6 offset >> ", value, 6); + DEBUG_ECHOLNPGM("\nget int6 offset >> ", value, 6); #endif switch (var.VP) { @@ -756,7 +756,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { else if (manualMoveStep == 0x02) manualMoveStep = 100; else if (manualMoveStep == 0x03) manualMoveStep = 1000; - DEBUG_ECHOLNPGM("QUEUE LEN:", queue.length); + DEBUG_ECHOLNPGM("QUEUE LEN:", queue.ring_buffer.length); if (!print_job_timer.isPaused() && !queue.ring_buffer.empty()) return; @@ -909,7 +909,7 @@ void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void * DEBUG_ECHOLNPGM("HandleChangeLevelPoint_MKS"); const int16_t value_raw = swap16(*(int16_t*)val_ptr); - DEBUG_ECHOLNPAIR_F("value_raw:", value_raw); + DEBUG_ECHOLNPGM("value_raw:", value_raw); *(int16_t*)var.memadr = value_raw; @@ -924,7 +924,7 @@ void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void * const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::axis_t axis; switch (var.VP) { @@ -934,7 +934,7 @@ void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void * case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; } ExtUI::setAxisSteps_per_mm(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -946,7 +946,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::extruder_t extruder; switch (var.VP) { @@ -959,7 +959,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var #endif } ExtUI::setAxisSteps_per_mm(value, extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -971,7 +971,7 @@ void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *va const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::axis_t axis; switch (var.VP) { @@ -981,7 +981,7 @@ void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *va default: return; } ExtUI::setAxisMaxFeedrate_mm_s(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(axis)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -993,7 +993,7 @@ void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::extruder_t extruder; switch (var.VP) { @@ -1006,7 +1006,7 @@ void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, case VP_E1_MAX_SPEED: extruder = ExtUI::extruder_t::E1; break; } ExtUI::setAxisMaxFeedrate_mm_s(value, extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(extruder)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -1018,7 +1018,7 @@ void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::axis_t axis; switch (var.VP) { @@ -1028,7 +1028,7 @@ void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ case VP_Z_ACC_MAX_SPEED: axis = ExtUI::axis_t::Z; break; } ExtUI::setAxisMaxAcceleration_mm_s2(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(axis)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -1049,9 +1049,9 @@ void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void case VP_E1_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E1; settings.load(); break; #endif } - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::setAxisMaxAcceleration_mm_s2(value, extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(extruder)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -1115,7 +1115,7 @@ void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr #endif } - DEBUG_ECHOLNPAIR_F("V3:", newvalue); + DEBUG_ECHOLNPGM("V3:", newvalue); *(float *)var.memadr = newvalue; settings.save(); @@ -1175,7 +1175,7 @@ void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) float value = (float)value_len; - DEBUG_ECHOLNPAIR_F("Get Filament len value:", value); + DEBUG_ECHOLNPGM("Get Filament len value:", value); distanceFilament = value; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel @@ -1186,7 +1186,7 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ uint16_t value_len = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPAIR_F("filamentSpeed_mm_s value:", value_len); + DEBUG_ECHOLNPGM("filamentSpeed_mm_s value:", value_len); filamentSpeed_mm_s = value_len; @@ -1459,7 +1459,7 @@ void DGUSScreenHandler::LanguagePInit() { } } -void DGUSScreenHandler::DGUS_ExtrudeLoadInit(void) { +void DGUSScreenHandler::DGUS_ExtrudeLoadInit() { ex_filament.ex_length = distanceFilament; ex_filament.ex_load_unload_flag = 0; ex_filament.ex_need_time = filamentSpeed_mm_s; @@ -1469,7 +1469,7 @@ void DGUSScreenHandler::DGUS_ExtrudeLoadInit(void) { ex_filament.ex_tick_start = 0; } -void DGUSScreenHandler::DGUS_RunoutInit(void) { +void DGUSScreenHandler::DGUS_RunoutInit() { #if PIN_EXISTS(MT_DET_1) SET_INPUT_PULLUP(MT_DET_1_PIN); #endif @@ -1479,7 +1479,7 @@ void DGUSScreenHandler::DGUS_RunoutInit(void) { runout_mks.runout_status = UNRUNOUT_STATUS; } -void DGUSScreenHandler::DGUS_Runout_Idle(void) { +void DGUSScreenHandler::DGUS_Runout_Idle() { #if ENABLED(DGUS_MKS_RUNOUT_SENSOR) // scanf runout pin switch (runout_mks.runout_status) { @@ -1501,10 +1501,10 @@ void DGUSScreenHandler::DGUS_Runout_Idle(void) { case RUNOUT_BEGIN_STATUS: if (READ(MT_DET_1_PIN) != MT_DET_PIN_STATE) - runout_mks.runout_status = RUNOUT_WAITTING_STATUS; + runout_mks.runout_status = RUNOUT_WAITING_STATUS; break; - case RUNOUT_WAITTING_STATUS: + case RUNOUT_WAITING_STATUS: if (READ(MT_DET_1_PIN) == MT_DET_PIN_STATE) runout_mks.runout_status = RUNOUT_BEGIN_STATUS; break; diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h index 0c80cd260ef9..dbd124cbe9d9 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h @@ -37,19 +37,19 @@ class DGUSScreenHandler { // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); } - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); } - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); #if 0 static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4); - static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ; + static void sendinfoscreen_en_mks(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4); static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language); #endif @@ -94,10 +94,10 @@ class DGUSScreenHandler { static void DGUS_LanguageDisplay(uint8_t var); static void TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr); static void GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr); - static void LanguagePInit(void); - static void DGUS_Runout_Idle(void); - static void DGUS_RunoutInit(void); - static void DGUS_ExtrudeLoadInit(void); + static void LanguagePInit(); + static void DGUS_Runout_Idle(); + static void DGUS_RunoutInit(); + static void DGUS_ExtrudeLoadInit(); static void LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr); static void SD_FileBack(DGUS_VP_Variable &var, void *val_ptr); @@ -280,13 +280,13 @@ class DGUSScreenHandler { } // Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } + static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } // Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } + static bool IsScreenComplete() { return ScreenComplete; } - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } + static DGUSLCD_Screens getCurrentScreen() { return current_screen; } - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } + static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } private: static DGUSLCD_Screens current_screen; //< currently on screen diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp index b77c92b7eb95..aaa8b72e1182 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; @@ -268,7 +268,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { #endif } - DEBUG_ECHOLNPAIR_F("V3:", newvalue); + DEBUG_ECHOLNPGM("V3:", newvalue); *(float *)var.memadr = newvalue; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h index bb0bd2bd3b42..0bdf06ed7d57 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h @@ -37,15 +37,15 @@ class DGUSScreenHandler { // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); } - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); } - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. static void setstatusmessage(const char *msg); @@ -213,13 +213,13 @@ class DGUSScreenHandler { } // Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } + static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } // Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } + static bool IsScreenComplete() { return ScreenComplete; } - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } + static DGUSLCD_Screens getCurrentScreen() { return current_screen; } - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } + static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } private: static DGUSLCD_Screens current_screen; //< currently on screen diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp index 1d97902c7171..15b3f5adcde4 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp @@ -57,7 +57,7 @@ void DGUSDisplay::Loop() { void DGUSDisplay::Init() { LCD_SERIAL.begin(LCD_BAUDRATE); - Read(DGUS_VERSION, 1); + ReadVersions(); } void DGUSDisplay::Read(uint16_t addr, uint8_t size) { @@ -158,6 +158,11 @@ void DGUSDisplay::WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t si } } +void DGUSDisplay::ReadVersions() { + if (gui_version != 0 && os_version != 0) return; + Read(DGUS_VERSION, 1); +} + void DGUSDisplay::SwitchScreen(DGUS_Screen screen) { DEBUG_ECHOLNPGM("SwitchScreen ", (uint8_t)screen); const uint8_t command[] = { 0x5A, 0x01, 0x00, (uint8_t)screen }; @@ -313,7 +318,7 @@ void DGUSDisplay::ProcessRx() { gcode.reset_stepper_timeout(); if (!vp.size) { - DEBUG_ECHOLN(); + DEBUG_EOL(); vp.rx_handler(vp, nullptr); rx_datagram_state = DGUS_IDLE; @@ -325,18 +330,15 @@ void DGUSDisplay::ProcessRx() { memset(buffer, 0, vp.size); for (uint8_t i = 0; i < dlen; i++) { - if (i >= vp.size) { - break; - } + if (i >= vp.size) break; - if (i + 1 < dlen && tmp[i + 3] == 0xFF && tmp[i + 4] == 0xFF) { + if (i + 1 < dlen && tmp[i + 3] == 0xFF && tmp[i + 4] == 0xFF) break; - } buffer[i] = tmp[i + 3]; } - DEBUG_ECHOLN(); + DEBUG_EOL(); vp.rx_handler(vp, buffer); rx_datagram_state = DGUS_IDLE; @@ -349,7 +351,7 @@ void DGUSDisplay::ProcessRx() { break; } - DEBUG_ECHOLN(); + DEBUG_EOL(); vp.rx_handler(vp, &tmp[3]); rx_datagram_state = DGUS_IDLE; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h index 1869f7940450..fa5bf3039696 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h @@ -69,6 +69,9 @@ class DGUSDisplay { // Until now I did not need to actively read from the display. That's why there is no ReadVariable // (I extensively use the auto upload of the display) + // Read GUI and OS version from screen + static void ReadVersions(); + // Force display into another screen. static void SwitchScreen(DGUS_Screen screen); // Play sounds using the display speaker. @@ -96,9 +99,9 @@ class DGUSDisplay { static size_t GetFreeTxBuffer(); static void FlushTx(); - // Checks two things: Can we confirm the presence of the display and has we initiliazed it. + // Checks two things: Can we confirm the presence of the display and has we initialized it. // (both boils down that the display answered to our chatting) - static inline bool IsInitialized() { + static bool IsInitialized() { return initialized; } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp index 17e7a3844592..6388e1683d05 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp @@ -100,37 +100,37 @@ void DGUSScreenHandler::Loop() { if (new_screen != DGUS_Screen::BOOT) { const DGUS_Screen screen = new_screen; new_screen = DGUS_Screen::BOOT; - - if (current_screen == screen) { + if (current_screen == screen) TriggerFullUpdate(); - } - else { + else MoveToScreen(screen); - } return; } if (!booted && ELAPSED(ms, 3000)) { booted = true; - if (current_screen == DGUS_Screen::BOOT) { + dgus_display.ReadVersions(); + + if (current_screen == DGUS_Screen::BOOT) MoveToScreen(DGUS_Screen::HOME); - } + return; } if (ELAPSED(ms, next_event_ms) || full_update) { next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS; - if (!SendScreenVPData(current_screen, full_update)) { + if (!SendScreenVPData(current_screen, full_update)) DEBUG_ECHOLNPGM("SendScreenVPData failed"); - } + return; } if (current_screen == DGUS_Screen::WAIT && ((wait_continue && !wait_for_user) - || (!wait_continue && IsPrinterIdle()))) { + || (!wait_continue && IsPrinterIdle())) + ) { MoveToScreen(wait_return_screen, true); return; } @@ -151,7 +151,6 @@ void DGUSScreenHandler::Loop() { if (eeprom_save > 0 && ELAPSED(ms, eeprom_save) && IsPrinterIdle()) { eeprom_save = 0; - queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE); return; } @@ -187,7 +186,6 @@ void DGUSScreenHandler::SettingsReset() { if (!settings_ready) { settings_ready = true; - Ready(); } @@ -225,9 +223,8 @@ void DGUSScreenHandler::LoadSettings(const char *buff) { } void DGUSScreenHandler::ConfigurationStoreWritten(bool success) { - if (!success) { + if (!success) SetStatusMessage(F("EEPROM write failed")); - } } void DGUSScreenHandler::ConfigurationStoreRead(bool success) { @@ -236,7 +233,6 @@ void DGUSScreenHandler::ConfigurationStoreRead(bool success) { } else if (!settings_ready) { settings_ready = true; - Ready(); } } @@ -245,33 +241,25 @@ void DGUSScreenHandler::PlayTone(const uint16_t frequency, const uint16_t durati UNUSED(duration); if (frequency >= 1 && frequency <= 255) { - if (duration >= 1 && duration <= 255) { + if (duration >= 1 && duration <= 255) dgus_display.PlaySound((uint8_t)frequency, (uint8_t)duration); - } - else { + else dgus_display.PlaySound((uint8_t)frequency); - } } } void DGUSScreenHandler::MeshUpdate(const int8_t xpos, const int8_t ypos) { if (current_screen != DGUS_Screen::LEVELING_PROBING) { - if (current_screen == DGUS_Screen::LEVELING_AUTOMATIC) { + if (current_screen == DGUS_Screen::LEVELING_AUTOMATIC) TriggerFullUpdate(); - } - return; } uint8_t point = ypos * GRID_MAX_POINTS_X + xpos; probing_icons[point < 16 ? 0 : 1] |= (1U << (point % 16)); - if (xpos >= GRID_MAX_POINTS_X - 1 - && ypos >= GRID_MAX_POINTS_Y - 1 - && !ExtUI::getMeshValid()) { - probing_icons[0] = 0; - probing_icons[1] = 0; - } + if (xpos >= GRID_MAX_POINTS_X - 1 && ypos >= GRID_MAX_POINTS_Y - 1 && !ExtUI::getMeshValid()) + probing_icons[0] = probing_icons[1] = 0; TriggerFullUpdate(); } @@ -282,15 +270,12 @@ void DGUSScreenHandler::PrintTimerStarted() { void DGUSScreenHandler::PrintTimerPaused() { dgus_display.PlaySound(3); - TriggerFullUpdate(); } void DGUSScreenHandler::PrintTimerStopped() { - if (current_screen != DGUS_Screen::PRINT_STATUS - && current_screen != DGUS_Screen::PRINT_ADJUST) { + if (current_screen != DGUS_Screen::PRINT_STATUS && current_screen != DGUS_Screen::PRINT_ADJUST) return; - } dgus_display.PlaySound(3); @@ -309,23 +294,19 @@ void DGUSScreenHandler::FilamentRunout(const ExtUI::extruder_t extruder) { #if ENABLED(SDSUPPORT) void DGUSScreenHandler::SDCardInserted() { - if (current_screen == DGUS_Screen::HOME) { + if (current_screen == DGUS_Screen::HOME) TriggerScreenChange(DGUS_Screen::PRINT); - } } void DGUSScreenHandler::SDCardRemoved() { - if (current_screen == DGUS_Screen::PRINT) { + if (current_screen == DGUS_Screen::PRINT) TriggerScreenChange(DGUS_Screen::HOME); - } } void DGUSScreenHandler::SDCardError() { SetStatusMessage(GET_TEXT_F(MSG_MEDIA_READ_ERROR)); - - if (current_screen == DGUS_Screen::PRINT) { + if (current_screen == DGUS_Screen::PRINT) TriggerScreenChange(DGUS_Screen::HOME); - } } #endif // SDSUPPORT diff --git a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp index 61b072a3f783..5c330bd6b472 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp @@ -83,8 +83,8 @@ namespace ExtUI { } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() { dgus_screen_handler.SettingsReset(); @@ -109,7 +109,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { dgus_screen_handler.MeshUpdate(xpos, ypos); diff --git a/Marlin/src/lcd/extui/example/example.cpp b/Marlin/src/lcd/extui/example/example.cpp index 8f38d2aba6d8..dd0f8e401e91 100644 --- a/Marlin/src/lcd/extui/example/example.cpp +++ b/Marlin/src/lcd/extui/example/example.cpp @@ -59,8 +59,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -99,7 +99,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp index 8b0c0f877c2b..dbee1e034b07 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp @@ -421,7 +421,7 @@ bool UIFlashStorage::is_present = false; uint32_t addr; uint8_t buff[write_page_size]; - strcpy_P( (char*) buff, (const char*) filename); + strcpy_P((char*)buff, FTOP(filename)); MediaFileReader reader; if (!reader.open((char*) buff)) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp index f0c0a59d3658..6d177c5a7b4c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp @@ -106,8 +106,8 @@ bool BioPrintingDialogBox::onTouchEnd(uint8_t tag) { } void BioPrintingDialogBox::setStatusMessage(FSTR_P message) { - char buff[strlen_P((const char*)message)+1]; - strcpy_P(buff, (const char*) message); + char buff[strlen_P(FTOP(message)) + 1]; + strcpy_P(buff, FTOP(message)); setStatusMessage(buff); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/compat.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/compat.h index 3b63b0fd5be6..afb380aa90ad 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/compat.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/compat.h @@ -43,8 +43,8 @@ #define min(a,b) ((a)<(b)?(a):(b)) #else namespace UI { - static inline uint32_t safe_millis() { return millis(); } - static inline void yield() {} + static uint32_t safe_millis() { return millis(); } + static void yield() {} }; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index 109814abf26d..1c7b3621f2b4 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -71,7 +71,6 @@ namespace ExtUI { } void onStatusChanged(const char *lcd_msg) { StatusScreen::setStatusMessage(lcd_msg); } - void onStatusChanged(FSTR_P lcd_msg) { StatusScreen::setStatusMessage(lcd_msg); } void onPrintTimerStarted() { InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_STARTED); @@ -81,7 +80,7 @@ namespace ExtUI { } void onPrintTimerPaused() {} - void onPrintFinished() {} + void onPrintDone() {} void onFilamentRunout(const extruder_t extruder) { char lcd_msg[30]; @@ -91,7 +90,7 @@ namespace ExtUI { } void onHomingStart() {} - void onHomingComplete() {} + void onHomingDone() {} void onFactoryReset() { InterfaceSettingsScreen::defaultSettings(); } void onStoreSettings(char *buff) { InterfaceSettingsScreen::saveSettings(buff); } @@ -119,7 +118,8 @@ namespace ExtUI { } #if HAS_LEVELING && HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t x, const int8_t y, const_float_t val) { BedMeshViewScreen::onMeshUpdate(x, y, val); } void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { BedMeshViewScreen::onMeshUpdate(x, y, state); } #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h index b8e687147ba9..da911c772daa 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h @@ -40,13 +40,13 @@ template struct port_pin { typedef port_t port; - static inline void set_high() {port::port() = (port::port() | bits);} - static inline void set_low() {port::port() = (port::port() & (~bits));} - static inline void set_input() {port::ddr() = (port::ddr() & (~bits));} - static inline void set_input_pullup() {set_input(); set_high();} - static inline void set_output() {port::ddr() = (port::ddr() | bits);} - static inline uint8_t read() {return port::pin() & bits;} - static inline void write(bool v) {if (v) set_high(); else set_low();} + static void set_high() {port::port() = (port::port() | bits);} + static void set_low() {port::port() = (port::port() & (~bits));} + static void set_input() {port::ddr() = (port::ddr() & (~bits));} + static void set_input_pullup() {set_input(); set_high();} + static void set_output() {port::ddr() = (port::ddr() | bits);} + static uint8_t read() {return port::pin() & bits;} + static void write(bool v) {if (v) set_high(); else set_low();} }; #define MAKE_AVR_PORT_PINS(ID) \ @@ -109,13 +109,13 @@ template struct arduino_digital_pin { static constexpr uint8_t pin = p; - static inline void set_high() {digitalWrite(p, HIGH);} - static inline void set_low() {digitalWrite(p, LOW);} - static inline void set_input() {pinMode(p, INPUT);} - static inline void set_input_pullup() {pinMode(p, INPUT_PULLUP);} - static inline void set_output() {pinMode(p, OUTPUT);} - static inline uint8_t read() {return digitalRead(p);} - static inline void write(bool v) {digitalWrite(p, v ? HIGH : LOW);} + static void set_high() {digitalWrite(p, HIGH);} + static void set_low() {digitalWrite(p, LOW);} + static void set_input() {pinMode(p, INPUT);} + static void set_input_pullup() {pinMode(p, INPUT_PULLUP);} + static void set_output() {pinMode(p, OUTPUT);} + static uint8_t read() {return digitalRead(p);} + static void write(bool v) {digitalWrite(p, v ? HIGH : LOW);} }; #define MAKE_ARDUINO_PINS(ID) typedef arduino_digital_pin ARDUINO_DIGITAL_##ID; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h index 24e93982c22a..648ed5330a98 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h @@ -242,10 +242,10 @@ class CommandProcessor : public CLCD::CommandFifo { } CommandProcessor& toggle2(int16_t x, int16_t y, int16_t w, int16_t h, FSTR_P no, FSTR_P yes, bool state, uint16_t options = FTDI::OPT_3D) { - char text[strlen_P((const char *)no) + strlen_P((const char *)yes) + 2]; - strcpy_P(text, (const char *)no); + char text[strlen_P(FTOP(no)) + strlen_P(FTOP(yes)) + 2]; + strcpy_P(text, FTOP(no)); strcat(text, "\xFF"); - strcat_P(text, (const char *)yes); + strcat_P(text, FTOP(yes)); return toggle(x, y, w, h, text, state, options); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h index 2ddab1b818b4..b204f04743a4 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h @@ -29,10 +29,10 @@ class SoundList { } list[]; public: static const uint8_t n; - static inline const char* name(uint8_t val) { + static const char* name(uint8_t val) { return (const char* ) pgm_read_ptr_far(&list[val].name); } - static inline FTDI::SoundPlayer::sound_t* data(uint8_t val) { + static FTDI::SoundPlayer::sound_t* data(uint8_t val) { return (FTDI::SoundPlayer::sound_t*) pgm_read_ptr_far(&list[val].data); } }; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp index b4d8156b39d8..c75cdf18121a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp @@ -135,9 +135,9 @@ namespace FTDI { } } - void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P pstr, uint16_t options, uint8_t font) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P fstr, uint16_t options, uint8_t font) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); draw_text_box(cmd, x, y, w, h, (const char*) str, options, font); } } // namespace FTDI diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp index 698bcdb15062..a6d014b56e3b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp @@ -33,6 +33,7 @@ namespace FTDI { const bool use_utf8 = has_utf8_chars(str); #define CHAR_WIDTH(c) use_utf8 ? utf8_fm.get_char_width(c) : clcd_fm.char_widths[(uint8_t)c] #else + constexpr bool use_utf8 = false; #define CHAR_WIDTH(c) utf8_fm.get_char_width(c) #endif FontMetrics utf8_fm(font); @@ -53,21 +54,17 @@ namespace FTDI { breakPoint = (char*)next; } - if (lineWidth > w) { - *breakPoint = '\0'; - strcpy_P(breakPoint,PSTR("...")); - } + if (lineWidth > w) + strcpy_P(breakPoint, PSTR("...")); cmd.apply_text_alignment(x, y, w, h, options); - #if ENABLED(TOUCH_UI_USE_UTF8) - if (use_utf8) { - draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options); - } else - #endif - { - cmd.CLCD::CommandFifo::text(x, y, font, options); - cmd.CLCD::CommandFifo::str(str); - } + if (use_utf8) { + TERN_(TOUCH_UI_USE_UTF8, draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options)); + } + else { + cmd.CLCD::CommandFifo::text(x, y, font, options); + cmd.CLCD::CommandFifo::str(str); + } } /** @@ -80,9 +77,9 @@ namespace FTDI { _draw_text_with_ellipsis(cmd, x, y, w, h, tmp, options, font); } - void draw_text_with_ellipsis(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P pstr, uint16_t options, uint8_t font) { - char tmp[strlen_P((const char*)pstr) + 3]; - strcpy_P(tmp, (const char*)pstr); + void draw_text_with_ellipsis(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P fstr, uint16_t options, uint8_t font) { + char tmp[strlen_P(FTOP(fstr)) + 3]; + strcpy_P(tmp, FTOP(fstr)); _draw_text_with_ellipsis(cmd, x, y, w, h, tmp, options, font); } } // namespace FTDI diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp index ca25dea3ca9d..d428f686b7bb 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp @@ -191,9 +191,9 @@ return render_utf8_text(nullptr, 0, 0, str, fs, maxlen); } - uint16_t FTDI::get_utf8_text_width(FSTR_P pstr, font_size_t fs) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + uint16_t FTDI::get_utf8_text_width(FSTR_P fstr, font_size_t fs) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); return get_utf8_text_width(str, fs); } @@ -234,9 +234,9 @@ cmd.cmd(RESTORE_CONTEXT()); } - void FTDI::draw_utf8_text(CommandProcessor& cmd, int x, int y, FSTR_P pstr, font_size_t fs, uint16_t options) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + void FTDI::draw_utf8_text(CommandProcessor& cmd, int x, int y, FSTR_P fstr, font_size_t fs, uint16_t options) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); draw_utf8_text(cmd, x, y, (const char*) str, fs, options); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp index 6cb85e47c49c..43e5c333651a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp @@ -69,8 +69,8 @@ void AboutScreen::onRedraw(draw_mode_t) { #endif draw_text_box(cmd, HEADING_POS, - #ifdef CUSTOM_MACHINE_NAME - F(CUSTOM_MACHINE_NAME) + #ifdef MACHINE_NAME + F(MACHINE_NAME) #else GET_TEXT_F(MSG_ABOUT_TOUCH_PANEL_1) #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp index 4415ed50fcee..ce3066ae41f2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp @@ -245,8 +245,8 @@ void BaseNumericAdjustmentScreen::widgets_t::adjuster(uint8_t tag, FSTR_P label, } if (_what & FOREGROUND) { - char b[strlen_P(value)+1]; - strcpy_P(b,value); + char b[strlen(value) + 1]; + strcpy(b, value); adjuster_sram_val(tag, label, b, is_enabled); } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp index 5076e58adf6e..6f428fa17487 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp @@ -77,7 +77,7 @@ const char *FilesScreen::getSelectedFilename(bool shortName) { } void FilesScreen::drawSelectedFile() { - if(mydata.selected_tag == 0xFF) return; + if (mydata.selected_tag == 0xFF) return; FileList files; files.seek(getSelectedFileIndex(), true); mydata.flags.is_dir = files.isDir(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp index be3a24438018..228bc5f96b47 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp @@ -41,13 +41,13 @@ void MaxAccelerationScreen::onRedraw(draw_mode_t what) { w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AMAX_E), getAxisMaxAcceleration_mm_s2(E0) ); #elif DISTINCT_E > 1 w.heading(GET_TEXT_F(MSG_AMAX_E)); - w.color(e_axis).adjuster( 8, F(LCD_STR_E0), getAxisMaxAcceleration_mm_s2(E0) ); - w.color(e_axis).adjuster(10, F(LCD_STR_E1), getAxisMaxAcceleration_mm_s2(E1) ); + w.color(e_axis).adjuster( 8, F(STR_E0), getAxisMaxAcceleration_mm_s2(E0) ); + w.color(e_axis).adjuster(10, F(STR_E1), getAxisMaxAcceleration_mm_s2(E1) ); #if DISTINCT_E > 2 - w.color(e_axis).adjuster(12, F(LCD_STR_E2), getAxisMaxAcceleration_mm_s2(E2) ); + w.color(e_axis).adjuster(12, F(STR_E2), getAxisMaxAcceleration_mm_s2(E2) ); #endif #if DISTINCT_E > 3 - w.color(e_axis).adjuster(14, F(LCD_STR_E3), getAxisMaxAcceleration_mm_s2(E3) ); + w.color(e_axis).adjuster(14, F(STR_E3), getAxisMaxAcceleration_mm_s2(E3) ); #endif #endif w.increments(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp index bca533c94f19..65dc947b7b48 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp @@ -42,13 +42,13 @@ void MaxVelocityScreen::onRedraw(draw_mode_t what) { w.color(e_axis) .adjuster( 8, GET_TEXT_F(MSG_VMAX_E), getAxisMaxFeedrate_mm_s(E0) ); #elif HAS_MULTI_EXTRUDER w.heading(GET_TEXT_F(MSG_VMAX_E)); - w.color(e_axis) .adjuster( 8, F(LCD_STR_E0), getAxisMaxFeedrate_mm_s(E0) ); - w.color(e_axis) .adjuster( 10, F(LCD_STR_E1), getAxisMaxFeedrate_mm_s(E1) ); + w.color(e_axis) .adjuster( 8, F(STR_E0), getAxisMaxFeedrate_mm_s(E0) ); + w.color(e_axis) .adjuster( 10, F(STR_E1), getAxisMaxFeedrate_mm_s(E1) ); #if EXTRUDERS > 2 - w.color(e_axis).adjuster( 12, F(LCD_STR_E2), getAxisMaxFeedrate_mm_s(E2) ); + w.color(e_axis).adjuster( 12, F(STR_E2), getAxisMaxFeedrate_mm_s(E2) ); #endif #if EXTRUDERS > 3 - w.color(e_axis).adjuster( 14, F(LCD_STR_E3), getAxisMaxFeedrate_mm_s(E3) ); + w.color(e_axis).adjuster( 14, F(STR_E3), getAxisMaxFeedrate_mm_s(E3) ); #endif #endif w.increments(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp index 4e76450683e9..7310577995e5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp @@ -345,8 +345,8 @@ void StatusScreen::draw_status_message(draw_mode_t what, const char *message) { } void StatusScreen::setStatusMessage(FSTR_P message) { - char buff[strlen_P((const char * const)message)+1]; - strcpy_P(buff, (const char * const) message); + char buff[strlen_P(FTOP(message)) + 1]; + strcpy_P(buff, FTOP(message)); setStatusMessage((const char *) buff); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/temperature_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/temperature_screen.cpp index ee53a82bee18..2dbf2d9f06a7 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/temperature_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/temperature_screen.cpp @@ -50,13 +50,13 @@ void TemperatureScreen::onRedraw(draw_mode_t what) { #elif HOTENDS == 1 w.adjuster( 2, GET_TEXT_F(MSG_NOZZLE), getTargetTemp_celsius(E0)); #else - w.adjuster( 2, F(LCD_STR_E0), getTargetTemp_celsius(E0)); - w.adjuster( 4, F(LCD_STR_E1), getTargetTemp_celsius(E1)); + w.adjuster( 2, F(STR_E0), getTargetTemp_celsius(E0)); + w.adjuster( 4, F(STR_E1), getTargetTemp_celsius(E1)); #if HOTENDS > 2 - w.adjuster( 6, F(LCD_STR_E2), getTargetTemp_celsius(E2)); + w.adjuster( 6, F(STR_E2), getTargetTemp_celsius(E2)); #endif #if HOTENDS > 3 - w.adjuster( 8, F(LCD_STR_E3), getTargetTemp_celsius(E3)); + w.adjuster( 8, F(STR_E3), getTargetTemp_celsius(E3)); #endif #endif #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h index 2e2597aec435..83e762430ce1 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h @@ -116,7 +116,6 @@ namespace Language_en { PROGMEM Language_Str MSG_LOAD_FILAMENT = u8"Load/Extrude"; PROGMEM Language_Str MSG_MOMENTARY = u8"Momentary"; PROGMEM Language_Str MSG_CONTINUOUS = u8"Continuous"; - PROGMEM Language_Str MSG_PLEASE_WAIT = u8"Please wait..."; PROGMEM Language_Str MSG_PRINT_MENU = u8"Print Menu"; PROGMEM Language_Str MSG_FINE_MOTION = u8"Fine motion"; PROGMEM Language_Str MSG_ENABLE_MEDIA = u8"Enable Media"; @@ -145,7 +144,6 @@ namespace Language_en { PROGMEM Language_Str MSG_LEVELING = u8"Leveling"; PROGMEM Language_Str MSG_AXIS_LEVELING = u8"Axis Leveling"; PROGMEM Language_Str MSG_PROBE_BED = u8"Probe Mesh"; - PROGMEM Language_Str MSG_MESH_VIEW = u8"View Mesh"; PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test (PLA)"; PROGMEM Language_Str MSG_MOVE_Z_TO_TOP = u8"Raise Z to Top"; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/pin_mappings.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/pin_mappings.h index 7c0bdd88e920..34026f4a26e6 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/pin_mappings.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/pin_mappings.h @@ -123,12 +123,12 @@ * 10 5V 5V 5V --> KILL [3] * * [1] This configuration allows daisy-chaining of the - * display and SD/USB on EXP2, except for [2] + * display and SD/FD on EXP2, except for [2] * * [2] The Ultimachine Einsy boards have a level shifter * on MISO enabled by SD_CSEL chip select, hence it * is not possible to run both the display and the - * SD/USB on EXP2. + * SD/FD on EXP2. * * [3] Archim Rambo provides 5V on this pin. On any other * board, divert this wire from the ribbon cable and diff --git a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp index f323728e2747..2d36a4e737dc 100644 --- a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp @@ -141,8 +141,8 @@ namespace ExtUI { void onFilamentRunout(const extruder_t extruder) {} void onUserConfirmRequired(const char * const) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} void onStoreSettings(char*) {} void onLoadSettings(const char*) {} @@ -151,7 +151,8 @@ namespace ExtUI { void onConfigurationStoreRead(bool) {} #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {} #endif diff --git a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h index 4683ff935187..72394286ac58 100644 --- a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h +++ b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h @@ -96,12 +96,12 @@ class SPIFlashStorage { static uint8_t m_pageData[SPI_FLASH_PageSize]; static uint32_t m_currentPage; static uint16_t m_pageDataUsed; - static inline uint16_t pageDataFree() { return SPI_FLASH_PageSize - m_pageDataUsed; } + static uint16_t pageDataFree() { return SPI_FLASH_PageSize - m_pageDataUsed; } static uint32_t m_startAddress; #if HAS_SPI_FLASH_COMPRESSION static uint8_t m_compressedData[SPI_FLASH_PageSize]; static uint16_t m_compressedDataUsed; - static inline uint16_t compressedDataFree() { return SPI_FLASH_PageSize - m_compressedDataUsed; } + static uint16_t compressedDataFree() { return SPI_FLASH_PageSize - m_compressedDataUsed; } #endif }; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_about.h b/Marlin/src/lcd/extui/mks_ui/draw_about.h index 4e7b318eda54..fdb76c5c4145 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_about.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_about.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_about(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_acceleration_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_acceleration_settings.h index e333e0ae5118..0147945edbde 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_acceleration_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_acceleration_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_acceleration_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_advance_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_advance_settings.h index 8848c34451bc..39c976413662 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_advance_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_advance_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_advance_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_auto_level_offset_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_auto_level_offset_settings.h index 38314f6bc2df..11c4f0502bbc 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_auto_level_offset_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_auto_level_offset_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_auto_level_offset_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.h b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.h index f8efeabc4093..f525273887c9 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_baby_stepping(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_change_speed.h b/Marlin/src/lcd/extui/mks_ui/draw_change_speed.h index 66662d8811a1..326e5d33a120 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_change_speed.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_change_speed.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif #define MIN_EXT_SPEED_PERCENT 10 diff --git a/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.h b/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.h index ff60f121a106..1414637ab7c0 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_cloud_bind(); @@ -33,5 +33,5 @@ void display_qrcode(uint8_t *qrcode_data); void cloud_unbind(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } #endif diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.h b/Marlin/src/lcd/extui/mks_ui/draw_dialog.h index 7e98a80c0a2b..ad26ec639fe1 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif enum { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_eeprom_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_eeprom_settings.h index 575ebbc6a2e6..f71886c855be 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_eeprom_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_eeprom_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_eeprom_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_encoder_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_encoder_settings.h index bbf0c3485877..0f57e444362a 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_encoder_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_encoder_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_encoder_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_error_message.h b/Marlin/src/lcd/extui/mks_ui/draw_error_message.h index 8963e7f477eb..5a4d75575f96 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_error_message.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_error_message.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif #ifndef PGM_P diff --git a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp index 85894a5e9255..0cacf90f36bd 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp @@ -55,7 +55,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; switch (obj->mks_obj_id) { case ID_E_ADD: - if (thermalManager.degHotend(uiCfg.extruderIndex) >= EXTRUDE_MINTEMP) { + if (thermalManager.hotEnoughToExtrude(uiCfg.extruderIndex)) { sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), uiCfg.extruStep, 60 * uiCfg.extruSpeed); queue.inject(public_buf_l); extrudeAmount += uiCfg.extruStep; @@ -63,9 +63,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } break; case ID_E_DEC: - if (thermalManager.degHotend(uiCfg.extruderIndex) >= EXTRUDE_MINTEMP) { + if (thermalManager.hotEnoughToExtrude(uiCfg.extruderIndex)) { sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed); - queue.enqueue_one_now(public_buf_l); + queue.inject(public_buf_l); extrudeAmount -= uiCfg.extruStep; disp_extru_amount(); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.h b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.h index 025276776784..27961bd6a916 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_extrusion(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_fan.h b/Marlin/src/lcd/extui/mks_ui/draw_fan.h index 0db87eb4f64e..739d62844642 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_fan.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_fan.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_fan(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.h b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.h index d3536a380ad1..8b09708445d4 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_filament_change(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_filament_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_filament_settings.h index 3d190e99c731..92b4091b6b70 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_filament_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_filament_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_filament_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_gcode.h b/Marlin/src/lcd/extui/mks_ui/draw_gcode.h index 4e1610431ef9..df752e7cc901 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_gcode.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_gcode.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_gcode(bool clear = false); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_home.h b/Marlin/src/lcd/extui/mks_ui/draw_home.h index 7375dc7aa8cb..ae7ce5f6c2bd 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_home.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_home.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_home(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_homing_sensitivity_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_homing_sensitivity_settings.h index e08639137341..11f0b2f403b5 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_homing_sensitivity_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_homing_sensitivity_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_homing_sensitivity_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.h index 7f5ffc3ac50d..5b990e1344e5 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_jerk_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_keyboard.h b/Marlin/src/lcd/extui/mks_ui/draw_keyboard.h index d89806c272d4..0db13cf88eab 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_keyboard.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_keyboard.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_keyboard(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_language.h b/Marlin/src/lcd/extui/mks_ui/draw_language.h index 4f51856f4f55..4f0ceefff22a 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_language.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_language.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_language(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp index 93d34a85785c..aee5573283e7 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp @@ -36,7 +36,8 @@ enum { ID_LEVEL_RETURN = 1, ID_LEVEL_POSITION, ID_LEVEL_COMMAND, - ID_LEVEL_ZOFFSET + ID_LEVEL_ZOFFSET, + ID_Z_OFFSET_WIZARD }; static void event_handler(lv_obj_t *obj, lv_event_t event) { @@ -57,6 +58,11 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_LEVEL_ZOFFSET: lv_draw_auto_level_offset_settings(); break; + #if ENABLED(PROBE_OFFSET_WIZARD) + case ID_Z_OFFSET_WIZARD: + lv_draw_z_offset_wizard(); + break; + #endif #endif } } @@ -67,6 +73,9 @@ void lv_draw_level_settings() { lv_screen_menu_item(scr, machine_menu.LevelingAutoCommandConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_LEVEL_COMMAND, 1); #if HAS_BED_PROBE lv_screen_menu_item(scr, machine_menu.LevelingAutoZoffsetConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_LEVEL_ZOFFSET, 2); + #if ENABLED(PROBE_OFFSET_WIZARD) + lv_screen_menu_item(scr, machine_menu.LevelingZoffsetWizard, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_Z_OFFSET_WIZARD, 3); + #endif #endif lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACK_POS_X + 10, PARA_UI_BACK_POS_Y, event_handler, ID_LEVEL_RETURN, true); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_level_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_level_settings.h index 06283d20955b..9b5056753e82 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_level_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_level_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_level_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_machine_para.h b/Marlin/src/lcd/extui/mks_ui/draw_machine_para.h index f495e8b35e5e..3853e7d9d821 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_machine_para.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_machine_para.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_machine_para(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_machine_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_machine_settings.h index f113f65fc1b0..ce12415a5288 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_machine_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_machine_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_machine_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_manuaLevel.h b/Marlin/src/lcd/extui/mks_ui/draw_manuaLevel.h index 29c8fa144ed3..4a234a85e7a6 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_manuaLevel.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_manuaLevel.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_manualLevel(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_max_feedrate_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_max_feedrate_settings.h index 45c3fd29db22..802693356fa6 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_max_feedrate_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_max_feedrate_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_max_feedrate_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_media_select.h b/Marlin/src/lcd/extui/mks_ui/draw_media_select.h index a698714a9dce..2274539277eb 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_media_select.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_media_select.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif extern void lv_draw_media_select(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_more.h b/Marlin/src/lcd/extui/mks_ui/draw_more.h index 86ee6f895fab..8e36e9d16ad7 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_more.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_more.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_more(); void lv_clear_more(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } #endif diff --git a/Marlin/src/lcd/extui/mks_ui/draw_motor_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_motor_settings.h index 5d26a402d034..309829aeda32 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_motor_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_motor_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_motor_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.h b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.h index 133a0444c157..60f55dc1d9a0 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_move_motor(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.h b/Marlin/src/lcd/extui/mks_ui/draw_number_key.h index fcff280d3b52..62f4e501b333 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_number_key(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_operation.h b/Marlin/src/lcd/extui/mks_ui/draw_operation.h index d58b3307b8f6..3d89f1dc25a9 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_operation.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_operation.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_operation(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_pause_message.h b/Marlin/src/lcd/extui/mks_ui/draw_pause_message.h index c3df8118a42d..97ce3988976e 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_pause_message.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_pause_message.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_pause_message(const PauseMessage msg); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_pause_position.h b/Marlin/src/lcd/extui/mks_ui/draw_pause_position.h index fd5459c64767..7dc4c1fbc2f6 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_pause_position.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_pause_position.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_pause_position(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_preHeat.h b/Marlin/src/lcd/extui/mks_ui/draw_preHeat.h index 023f1228b33a..ddb488eaa765 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_preHeat.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_preHeat.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_preHeat(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_print_file.h b/Marlin/src/lcd/extui/mks_ui/draw_print_file.h index 85eadc0a6bcc..01b0db83fbd1 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_print_file.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_print_file.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif typedef struct { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_printing.h b/Marlin/src/lcd/extui/mks_ui/draw_printing.h index b2a02a62da54..8055a0746a4e 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_printing.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_printing.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif enum { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp index 1596944bd899..39f270840be4 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp @@ -196,7 +196,7 @@ void lv_draw_ready_print() { buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 180, ICON_POS_Y, event_handler, ID_INFO_EXT); #endif #if HAS_HEATED_BED - buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", TERN(HAS_MULTI_HOTEND, 271, 210), ICON_POS_Y, event_handler, ID_INFO_BED); + buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", TERN(HAS_MULTI_HOTEND, 340, 210), ICON_POS_Y, event_handler, ID_INFO_BED); #endif TERN_(HAS_HOTEND, labelExt1 = lv_label_create_empty(scr)); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.h b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.h index 873be528ed1d..d5582936ce5b 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_ready_print(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_set.h b/Marlin/src/lcd/extui/mks_ui/draw_set.h index a270308e074e..11a38ea32f74 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_set.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_set.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_set(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_step_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_step_settings.h index 4f32f0a6c2b0..0678aaa7fe86 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_step_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_step_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_step_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.h index 99589a3a17c7..b3ab95dc6955 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_tmc_current_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_tmc_step_mode_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_tmc_step_mode_settings.h index aa42d9b87dba..0f58bb56ad06 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_tmc_step_mode_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_tmc_step_mode_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_tmc_step_mode_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_tool.h b/Marlin/src/lcd/extui/mks_ui/draw_tool.h index 0dc86b703072..db65ae5763f0 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_tool.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_tool.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_tool(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.h b/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.h index 567256a792e1..17ec9fc96c26 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_touch_calibration_screen(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.h index 863ff6fc7e84..15c783c362d0 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_tramming_pos_settings(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 66b2deda6605..d3f192e44f70 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -456,6 +456,10 @@ char *getDispText(int index) { } break; case MOVE_MOTOR_UI: strcpy(public_buf_l, move_menu.title); break; + + #if ENABLED(PROBE_OFFSET_WIZARD) + case Z_OFFSET_WIZARD_UI: break; + #endif case OPERATE_UI: switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { IF_DISABLED(TFT35, case OPERATE_UI: case PAUSE_UI:) @@ -785,6 +789,10 @@ void GUI_RefreshPage() { case MOVE_MOTOR_UI: break; + #if ENABLED(PROBE_OFFSET_WIZARD) + case Z_OFFSET_WIZARD_UI: break; + #endif + #if ENABLED(MKS_WIFI_MODULE) case WIFI_UI: if (temps_update_flag) { @@ -885,6 +893,9 @@ void clear_cur_ui() { case PRINT_FILE_UI: lv_clear_print_file(); break; case PRINTING_UI: lv_clear_printing(); break; case MOVE_MOTOR_UI: lv_clear_move_motor(); break; + #if ENABLED(PROBE_OFFSET_WIZARD) + case Z_OFFSET_WIZARD_UI: lv_clear_z_offset_wizard(); break; + #endif case OPERATE_UI: lv_clear_operation(); break; case PAUSE_UI: break; case EXTRUSION_UI: lv_clear_extrusion(); break; @@ -993,6 +1004,9 @@ void draw_return_ui() { break; case MOVE_MOTOR_UI: lv_draw_move_motor(); break; + #if ENABLED(PROBE_OFFSET_WIZARD) + case Z_OFFSET_WIZARD_UI: lv_draw_z_offset_wizard(); break; + #endif case OPERATE_UI: lv_draw_operation(); break; case PAUSE_UI: break; case EXTRUSION_UI: lv_draw_extrusion(); break; @@ -1331,7 +1345,6 @@ void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue) { lv_label_set_text((lv_obj_t*)btn->child_ll.head, curValue ? machine_menu.enable : machine_menu.disable); } - #if ENABLED(SDSUPPORT) void sd_detection() { @@ -1360,7 +1373,9 @@ void print_time_count() { } void LV_TASK_HANDLER() { - lv_task_handler(); + + if (TERN1(USE_SPI_DMA_TC, !get_lcd_dma_lock())) + lv_task_handler(); #if BOTH(MKS_TEST, SDSUPPORT) if (mks_test_flag == 0x1E) mks_hardware_test(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/mks_ui/draw_ui.h index 55ea6220e076..798e662220ef 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.h @@ -69,6 +69,7 @@ #include "draw_max_feedrate_settings.h" #include "draw_tmc_step_mode_settings.h" #include "draw_level_settings.h" +#include "draw_z_offset_wizard.h" #include "draw_tramming_pos_settings.h" #include "draw_auto_level_offset_settings.h" #include "draw_filament_change.h" @@ -178,7 +179,7 @@ #endif // ifdef TFT35 #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif extern char public_buf_m[100]; @@ -266,6 +267,7 @@ typedef enum { PRINT_FILE_UI, PRINTING_UI, MOVE_MOTOR_UI, + Z_OFFSET_WIZARD_UI, OPERATE_UI, PAUSE_UI, EXTRUSION_UI, diff --git a/Marlin/src/lcd/extui/mks_ui/draw_wifi.h b/Marlin/src/lcd/extui/mks_ui/draw_wifi.h index 4fa642b39c1e..a89bbd67d8c2 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_wifi.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_wifi.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif diff --git a/Marlin/src/lcd/extui/mks_ui/draw_wifi_list.h b/Marlin/src/lcd/extui/mks_ui/draw_wifi_list.h index 8dbedf832e78..81c3a00d4a57 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_wifi_list.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_wifi_list.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif void lv_draw_wifi_list(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.h b/Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.h index ff2739704953..81400856fdd8 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif #define WIFI_AP_TEXT "AP" diff --git a/Marlin/src/lcd/extui/mks_ui/draw_wifi_tips.h b/Marlin/src/lcd/extui/mks_ui/draw_wifi_tips.h index 4ffe6c1312a3..ad1523893243 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_wifi_tips.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_wifi_tips.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif diff --git a/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp new file mode 100644 index 000000000000..d95efd862ba9 --- /dev/null +++ b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp @@ -0,0 +1,228 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if BOTH(HAS_TFT_LVGL_UI, PROBE_OFFSET_WIZARD) + +#include "draw_ui.h" +#include + +#include "../../../gcode/queue.h" +#include "../../../module/motion.h" + +#include "../../../module/planner.h" +#include "../../../inc/MarlinConfig.h" +#include "../../../module/probe.h" + +#if HAS_LEVELING + #include "../../../feature/bedlevel/bedlevel.h" + bool leveling_was_active; +#endif + +extern lv_group_t *g; +static lv_obj_t *scr; + +static lv_obj_t *labelV, *buttonV, *labelP; +static lv_obj_t *labelP_z_offset_ref; +static lv_task_t *updatePosTask; +static char cur_label = 'Z'; +static float cur_pos = 0; +static float cur_OffsetPos = 0; + +// Global storage +float z_offset_backup, calculated_z_offset, z_offset_ref; + +enum { + ID_M_Z_P = 1, + ID_M_Z_N, + ID_M_STEP, + ID_M_SAVE, + ID_M_RETURN +}; + +void disp_cur_wizard_pos() { + char str_1[18]; + sprintf_P(public_buf_l, PSTR("%c:%s mm"), cur_label, dtostrf(cur_pos, 1, 3, str_1)); + if (labelP) lv_label_set_text(labelP, public_buf_l); + + sprintf_P(public_buf_l, PSTR("%c Offset:%s mm"), cur_label, dtostrf(cur_OffsetPos, 1, 3, str_1)); + if (labelP_z_offset_ref) lv_label_set_text(labelP_z_offset_ref, public_buf_l); +} + +static void event_handler(lv_obj_t *obj, lv_event_t event) { + char str_1[16]; + if (event != LV_EVENT_RELEASED) return; + //lv_clear_z_offset_wizard(); + if (!queue.ring_buffer.full(3)) { + bool do_inject = true; + float dist = uiCfg.move_dist; + switch (obj->mks_obj_id) { + case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break; + default: do_inject = false; + } + if (do_inject) { + sprintf_P(public_buf_l, PSTR("G91\nG1 %c%s F%d\nG90"), cur_label, dtostrf(dist, 1, 3, str_1), uiCfg.moveSpeed); + queue.inject(public_buf_l); + //calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; + disp_cur_wizard_pos(); + } + } + + switch (obj->mks_obj_id) { + case ID_M_STEP: + if (ABS((int)(10 * uiCfg.move_dist)) == 10) + uiCfg.move_dist = 0.025; + else if (ABS((int)(1000 * uiCfg.move_dist)) == 25) + uiCfg.move_dist = 0.1; + else + uiCfg.move_dist *= 10.0f; + disp_move_wizard_dist(); + break; + case ID_M_SAVE: + current_position.z = z_offset_ref; // Set Z to z_offset_ref, as we can expect it is at probe height + probe.offset.z = calculated_z_offset; + sync_plan_position(); + // Raise Z as if it was homed + do_z_clearance(Z_POST_CLEARANCE); + watchdog_refresh(); + draw_return_ui(); + return; + case ID_M_RETURN: + probe.offset.z = z_offset_backup; + SET_SOFT_ENDSTOP_LOOSE(false); + TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); + #if HOMING_Z_WITH_PROBE && defined(PROBE_OFFSET_WIZARD_START_Z) + set_axis_never_homed(Z_AXIS); // On cancel the Z position needs correction + queue.inject_P(PSTR("G28Z")); + #else // Otherwise do a Z clearance move like after Homing + do_z_clearance(Z_POST_CLEARANCE); + #endif + watchdog_refresh(); + draw_return_ui(); + return; + } + disp_cur_wizard_pos(); +} + +void refresh_wizard_pos(lv_task_t *) { + switch (cur_label) { + case 'Z': + cur_pos = current_position.z; + calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; + cur_OffsetPos = calculated_z_offset; + break; + default: return; + } + disp_cur_wizard_pos(); +} + +void lv_draw_z_offset_wizard() { + + set_all_unhomed(); + + // Store probe.offset.z for Case: Cancel + z_offset_backup = probe.offset.z; + + #ifdef PROBE_OFFSET_WIZARD_START_Z + probe.offset.z = PROBE_OFFSET_WIZARD_START_Z; + #endif + + // Store Bed-Leveling-State and disable + #if HAS_LEVELING + leveling_was_active = planner.leveling_active; + set_bed_leveling_enabled(leveling_was_active); + #endif + + queue.inject_P(PSTR("G28")); + + z_offset_ref = 0; // Set Z Value for Wizard Position to 0 + calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; + cur_OffsetPos = calculated_z_offset; + + scr = lv_screen_create(Z_OFFSET_WIZARD_UI, machine_menu.LevelingZoffsetTitle); + + lv_obj_t *buttonXI = lv_big_button_create(scr, "F:/bmp_zAdd.bin", move_menu.z_add, INTERVAL_V, titleHeight, event_handler, ID_M_Z_P); + lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW); + lv_big_button_create(scr, "F:/bmp_zDec.bin", move_menu.z_dec, INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Z_N); + + // button with image and label changed dynamically by disp_move_dist + buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP); + labelV = lv_label_create_empty(buttonV); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonV); + #endif + + // save and back + lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_save, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_SAVE); + // cancel and back + lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN); + + // We need to patch the title to leave some space on the right for displaying the status + lv_obj_t * z_offset_ref_title = lv_obj_get_child_back(scr, nullptr); + if (z_offset_ref_title != nullptr) lv_obj_set_width(z_offset_ref_title, (int)(TFT_WIDTH / 2) - 101); + labelP_z_offset_ref = lv_label_create(scr, (int)(TFT_WIDTH / 2) - 80, (int)(TFT_HEIGHT/2)-20, "Z Offset:0.0mm"); + + // We need to patch the Z Offset to leave some space in the middle for displaying the status + lv_obj_t * title= lv_obj_get_child_back(scr, nullptr); + if (title != nullptr) lv_obj_set_width(title, TFT_WIDTH - 101); + labelP = lv_label_create(scr, TFT_WIDTH - 100, TITLE_YPOS, "Z:0.0mm"); + + if (labelP != nullptr) + updatePosTask = lv_task_create(refresh_wizard_pos, 300, LV_TASK_PRIO_LOWEST, 0); + + disp_move_wizard_dist(); + disp_cur_wizard_pos(); +} + +void disp_move_wizard_dist() { + if ((int)(1000 * uiCfg.move_dist) == 25) + lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move0_1.bin"); + else if ((int)(10 * uiCfg.move_dist) == 1) + lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move1.bin"); + else if ((int)(10 * uiCfg.move_dist) == 10) + lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move10.bin"); + + if (gCfgItems.multiple_language) { + if ((int)(1000 * uiCfg.move_dist) == 25) { + lv_label_set_text(labelV, move_menu.step_0025mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if ((int)(10 * uiCfg.move_dist) == 1) { + lv_label_set_text(labelV, move_menu.step_01mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if ((int)(10 * uiCfg.move_dist) == 10) { + lv_label_set_text(labelV, move_menu.step_1mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void lv_clear_z_offset_wizard() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI && PROBE_OFFSET_WIZARD diff --git a/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.h b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.h new file mode 100644 index 000000000000..47a3d69c46d9 --- /dev/null +++ b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.h @@ -0,0 +1,36 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +void lv_draw_z_offset_wizard(); +void refresh_wizard_pos(); +void disp_cur_wizard_pos(); +void disp_move_wizard_dist(); +void lv_clear_z_offset_wizard(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp b/Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp index f3c87c03c4b5..aca1db0039ba 100644 --- a/Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp +++ b/Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp @@ -39,7 +39,7 @@ #include "../../../inc/MarlinConfig.h" #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif #define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH); diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp index 4305462162ca..a14fa4d1dfb2 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp @@ -45,7 +45,7 @@ #if PIN_EXISTS(MT_DET_2) bool mt_det2_sta; #endif - #if HAS_X_MIN || HAS_X_MAX + #if X_HOME_DIR bool endstopx1_sta; #else constexpr static bool endstopx1_sta = true; @@ -55,7 +55,7 @@ #else constexpr static bool endstopx2_sta = true; #endif - #if HAS_Y_MIN || HAS_Y_MAX + #if HAS_Y_AXIS && Y_HOME_DIR bool endstopy1_sta; #else constexpr static bool endstopy1_sta = true; @@ -65,7 +65,7 @@ #else constexpr static bool endstopy2_sta = true; #endif - #if HAS_Z_MIN || HAS_Z_MAX + #if HAS_Z_AXIS && Z_HOME_DIR bool endstopz1_sta; #else constexpr static bool endstopz1_sta = true; diff --git a/Marlin/src/lcd/extui/mks_ui/pic_manager.h b/Marlin/src/lcd/extui/mks_ui/pic_manager.h index 95405af1cf24..320cb20b0b8d 100644 --- a/Marlin/src/lcd/extui/mks_ui/pic_manager.h +++ b/Marlin/src/lcd/extui/mks_ui/pic_manager.h @@ -131,7 +131,7 @@ #define OTHERS_COMMAND_ADDR_4 OTHERS_COMMAND_ADDR_3 + 100 #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif union union32 { diff --git a/Marlin/src/lcd/extui/mks_ui/printer_operation.h b/Marlin/src/lcd/extui/mks_ui/printer_operation.h index 499799c6c78b..d9c0b741f23e 100644 --- a/Marlin/src/lcd/extui/mks_ui/printer_operation.h +++ b/Marlin/src/lcd/extui/mks_ui/printer_operation.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif #define MIN_FILE_PRINTED 100 //5000 diff --git a/Marlin/src/lcd/extui/mks_ui/tft_Language_en.h b/Marlin/src/lcd/extui/mks_ui/tft_Language_en.h index a41864eec479..5195986e3584 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_Language_en.h +++ b/Marlin/src/lcd/extui/mks_ui/tft_Language_en.h @@ -103,6 +103,8 @@ #define LEVELING_AUTO_COMMAND_EN "AutoLeveling command settings" #define LEVELING_AUTO_ZOFFSET_EN "Nozzle-to-probe offsets settings" +#define LEVELING_ZOFFSET_TITLE_EN "Machine Settings>Z Offset Wizard" + #define LEVELING_PARA_CONF_TITLE_EN "leveling setting" #define AUTO_LEVELING_ENABLE_EN "Enable auto leveling" #define BLTOUCH_LEVELING_ENABLE_EN "Enable BLTouch" @@ -293,6 +295,7 @@ #define CLOSE_TEXT_EN "Close" #define BACK_TEXT_EN "Back" +#define SAVE_TEXT_EN "Save" #define TOOL_PREHEAT_EN "Preheat" #define TOOL_EXTRUDE_EN "Extrusion" diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp index 837d7470d600..6e852a748703 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -127,16 +127,33 @@ void tft_lvgl_init() { watchdog_refresh(); // LVGL init takes time - #if MB(MKS_ROBIN_NANO) - OUT_WRITE(PB0, LOW); // HE1 - #endif - // Init TFT first! SPI_TFT.spi_init(SPI_FULL_SPEED); SPI_TFT.LCD_init(); watchdog_refresh(); // LVGL init takes time + #if ENABLED(USB_FLASH_DRIVE_SUPPORT) + uint16_t usb_flash_loop = 1000; + #if ENABLED(MULTI_VOLUME) && !HAS_SD_HOST_DRIVE + SET_INPUT_PULLUP(SD_DETECT_PIN); + if (READ(SD_DETECT_PIN) == LOW) card.changeMedia(&card.media_driver_sdcard); + else card.changeMedia(&card.media_driver_usbFlash); + #endif + do { + card.media_driver_usbFlash.idle(); + watchdog_refresh(); + delay(2); + } while (!card.media_driver_usbFlash.isInserted() && usb_flash_loop--); + card.mount(); + #elif HAS_LOGO_IN_FLASH + delay(1000); + watchdog_refresh(); + delay(1000); + #endif + + watchdog_refresh(); // LVGL init takes time + #if ENABLED(SDSUPPORT) UpdateAssets(); watchdog_refresh(); // LVGL init takes time @@ -235,19 +252,44 @@ void tft_lvgl_init() { #endif } +static lv_disp_drv_t* disp_drv_p; + +#if ENABLED(USE_SPI_DMA_TC) + bool lcd_dma_trans_lock = false; +#endif + +void dmc_tc_handler(struct __DMA_HandleTypeDef * hdma) { + #if ENABLED(USE_SPI_DMA_TC) + lv_disp_flush_ready(disp_drv_p); + lcd_dma_trans_lock = false; + TFT_SPI::Abort(); + #endif +} + void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) { uint16_t width = area->x2 - area->x1 + 1, height = area->y2 - area->y1 + 1; - SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height); + disp_drv_p = disp; - SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height); + SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height); - lv_disp_flush_ready(disp); // Indicate you are ready with the flushing + #if ENABLED(USE_SPI_DMA_TC) + lcd_dma_trans_lock = true; + SPI_TFT.tftio.WriteSequenceIT((uint16_t*)color_p, width * height); + TFT_SPI::DMAtx.XferCpltCallback = dmc_tc_handler; + #else + SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height); + lv_disp_flush_ready(disp_drv_p); // Indicate you are ready with the flushing + #endif W25QXX.init(SPI_QUARTER_SPEED); } +#if ENABLED(USE_SPI_DMA_TC) + bool get_lcd_dma_lock() { return lcd_dma_trans_lock; } +#endif + void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color) { uint16_t width, height; width = x2 - x1 + 1; diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h index e2786fd452cf..0368140b2858 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h @@ -27,7 +27,7 @@ */ #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif #include @@ -64,6 +64,8 @@ lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color); +bool get_lcd_dma_lock(); + #ifdef __cplusplus } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp index c69ccf65872b..6e9c37b0169e 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp @@ -578,6 +578,8 @@ void machine_setting_disp() { machine_menu.OutLength = FILAMENT_OUT_LENGTH_EN; machine_menu.OutSpeed = FILAMENT_OUT_SPEED_EN; + machine_menu.LevelingZoffsetTitle = LEVELING_ZOFFSET_TITLE_EN; + machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_EN; machine_menu.LevelingParaConf = LEVELING_PARA_CONF_EN; machine_menu.TrammingPosConf = TRAMMING_POS_EN; @@ -767,11 +769,12 @@ void disp_language_init() { move_menu.z_add = AXIS_Z_ADD_TEXT; move_menu.z_dec = AXIS_Z_DEC_TEXT; - move_menu.step_001mm = TEXT_001MM; - move_menu.step_005mm = TEXT_005MM; - move_menu.step_01mm = TEXT_01MM; - move_menu.step_1mm = TEXT_1MM; - move_menu.step_10mm = TEXT_10MM; + move_menu.step_001mm = TEXT_001MM; + move_menu.step_0025mm = TEXT_0025MM; + move_menu.step_005mm = TEXT_005MM; + move_menu.step_01mm = TEXT_01MM; + move_menu.step_1mm = TEXT_1MM; + move_menu.step_10mm = TEXT_10MM; home_menu.home_x = HOME_X_TEXT; home_menu.home_y = HOME_Y_TEXT; @@ -1346,6 +1349,7 @@ void disp_language_init() { case LANG_ENGLISH: common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_EN; common_menu.text_back = BACK_TEXT_EN; + common_menu.text_save = SAVE_TEXT_EN; common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_EN; common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_EN; common_menu.print_special_title = PRINTING_OTHER_LANGUGE; diff --git a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.h b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.h index 0d0285f322af..2a5135dded4f 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.h +++ b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.h @@ -101,6 +101,8 @@ typedef struct machine_common_disp { const char *OutLength; const char *OutSpeed; + const char *LevelingZoffsetTitle; + const char *LevelingParaConfTitle; const char *LevelingParaConf; const char *TrammingPosConf; @@ -294,6 +296,7 @@ extern machine_common_def machine_menu; typedef struct common_menu_disp { const char *text_back; + const char *text_save; const char *dialog_confirm_title; const char *close_machine_tips; const char *unbind_printer_tips; @@ -355,6 +358,7 @@ typedef struct move_menu_disp { const char *z_add; const char *z_dec; const char *step_001mm; + const char *step_0025mm; const char *step_005mm; const char *step_01mm; const char *step_1mm; @@ -777,6 +781,7 @@ extern eeprom_def eeprom_menu; #define AXIS_Z_ADD_TEXT "Z+" #define AXIS_Z_DEC_TEXT "Z-" #define TEXT_001MM "0.01 mm" +#define TEXT_0025MM "0.025 mm" #define TEXT_005MM "0.05 mm" #define TEXT_01MM "0.1 mm" #define TEXT_1MM "1 mm" diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h index cf32bad3969c..a7281fed4ada 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h @@ -39,17 +39,17 @@ class WifiSerial { void begin(uint32_t baud); void begin(uint32_t baud, uint8_t config); void end(); - int available(void); - int read(void); + int available(); + int read(); int write(uint8_t); // Interrupt handlers static int _tx_complete_irq(serial_t *obj); static void _rx_complete_irq(serial_t *obj); - void flush(void); - bool isHalfDuplex(void) const; - void enableHalfDuplexRx(void); + void flush(); + bool isHalfDuplex() const; + void enableHalfDuplexRx(); private: void setRx(uint32_t _rx); diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index f56d68366cbc..df90321c895d 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -345,7 +345,7 @@ static bool longName2DosName(const char *longName, char *dosName) { hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << hdma->ChannelIndex); SET_BIT(hdma->ErrorCode, HAL_DMA_ERROR_TE); // Update error code - hdma->State= HAL_DMA_STATE_READY; // Change the DMA state + hdma->State = HAL_DMA_STATE_READY; // Change the DMA state __HAL_UNLOCK(hdma); // Process Unlocked return HAL_ERROR; } @@ -2028,7 +2028,7 @@ void get_wifi_commands() { // Process critical commands early if (strcmp_P(command, PSTR("M108")) == 0) { wait_for_heatup = false; - TERN_(HAS_LCD_MENU, wait_for_user = false); + TERN_(HAS_MARLINUI_MENU, wait_for_user = false); } if (strcmp_P(command, PSTR("M112")) == 0) kill(FPSTR(M112_KILL_STR), nullptr, true); if (strcmp_P(command, PSTR("M410")) == 0) quickstop_stepper(); diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.h b/Marlin/src/lcd/extui/mks_ui/wifi_module.h index 15b90ab367c5..36998899b483 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.h +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif #include "../../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_upload.h b/Marlin/src/lcd/extui/mks_ui/wifi_upload.h index ff98173b9555..2daa505d9088 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_upload.h +++ b/Marlin/src/lcd/extui/mks_ui/wifi_upload.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ + extern "C" { #endif #define ESP_FIRMWARE_FILE "MksWifi.bin" diff --git a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp index c19d3aee46f0..c15175a28d9a 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp @@ -50,8 +50,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) { nextion.StatusChange(msg); } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() { nextion.PrintFinished(); } + void onHomingDone() {} + void onPrintDone() { nextion.PrintFinished(); } void onFactoryReset() {} @@ -90,7 +90,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index 2c1bde245c02..92349659eb3d 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -430,25 +430,24 @@ void NextionTFT::PanelInfo(uint8_t req) { break; case 36: // Endstop Info - #if HAS_X_MIN + #if X_HOME_TO_MIN SEND_VALasTXT("x1", READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); - #endif - #if HAS_X_MAX + #elif X_HOME_TO_MAX SEND_VALasTXT("x2", READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); #endif - #if HAS_Y_MIN + #if Y_HOME_TO_MIN SEND_VALasTXT("y1", READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); + #elif Y_HOME_TO_MAX + SEND_VALasTXT("y2", READ(X_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); #endif - #if HAS_Z_MIN + #if Z_HOME_TO_MIN SEND_VALasTXT("z1", READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); - #endif - #if HAS_Z_MAX + #elif Z_HOME_TO_MAX SEND_VALasTXT("z2", READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); #endif #if HAS_Z2_MIN SEND_VALasTXT("z2", READ(Z2_MIN_PIN) != Z2_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); - #endif - #if HAS_Z2_MAX + #elif HAS_Z2_MAX SEND_VALasTXT("z2", READ(Z2_MAX_PIN) != Z2_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); #endif #if HAS_BED_PROBE diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 54e7db55c290..0dad675cb75c 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -94,6 +94,10 @@ #include "../../feature/caselight.h" #endif +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../feature/powerloss.h" +#endif + #if ENABLED(BABYSTEPPING) #include "../../feature/babystep.h" #endif @@ -385,8 +389,10 @@ namespace ExtUI { return !thermalManager.tooColdToExtrude(extruder - E0); } - GcodeSuite::MarlinBusyState getHostKeepaliveState() { return TERN0(HOST_KEEPALIVE_FEATURE, gcode.busy_state); } - bool getHostKeepaliveIsPaused() { return TERN0(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive_is_paused()); } + #if ENABLED(HOST_KEEPALIVE_FEATURE) + GcodeSuite::MarlinBusyState getHostKeepaliveState() { return gcode.busy_state; } + bool getHostKeepaliveIsPaused() { return gcode.host_keepalive_is_paused(); } + #endif #if HAS_SOFTWARE_ENDSTOPS bool getSoftEndstopState() { return soft_endstop._enabled; } @@ -674,6 +680,11 @@ namespace ExtUI { #endif #endif + #if ENABLED(POWER_LOSS_RECOVERY) + bool getPowerLossRecoveryEnabled() { return recovery.enabled; } + void setPowerLossRecoveryEnabled(const bool value) { recovery.enable(value); } + #endif + #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t extruder) { return (extruder < EXTRUDERS) ? planner.extruder_advance_K[extruder - E0] : 0; @@ -852,16 +863,16 @@ namespace ExtUI { #endif #if ENABLED(BACKLASH_GCODE) - float getAxisBacklash_mm(const axis_t axis) { return backlash.distance_mm[axis]; } + float getAxisBacklash_mm(const axis_t axis) { return backlash.get_distance_mm((AxisEnum)axis); } void setAxisBacklash_mm(const_float_t value, const axis_t axis) - { backlash.distance_mm[axis] = constrain(value,0,5); } + { backlash.set_distance_mm((AxisEnum)axis, constrain(value,0,5)); } - float getBacklashCorrection_percent() { return ui8_to_percent(backlash.correction); } - void setBacklashCorrection_percent(const_float_t value) { backlash.correction = map(constrain(value, 0, 100), 0, 100, 0, 255); } + float getBacklashCorrection_percent() { return backlash.get_correction() * 100.0f; } + void setBacklashCorrection_percent(const_float_t value) { backlash.set_correction(constrain(value, 0, 100) / 100.0f); } #ifdef BACKLASH_SMOOTHING_MM - float getBacklashSmoothing_mm() { return backlash.smoothing_mm; } - void setBacklashSmoothing_mm(const_float_t value) { backlash.smoothing_mm = constrain(value, 0, 999); } + float getBacklashSmoothing_mm() { return backlash.get_smoothing_mm(); } + void setBacklashSmoothing_mm(const_float_t value) { backlash.set_smoothing_mm(constrain(value, 0, 999)); } #endif #endif @@ -1144,7 +1155,7 @@ namespace ExtUI { // At the moment we hook into MarlinUI methods, but this could be cleaned up in the future -void MarlinUI::init() { ExtUI::onStartup(); } +void MarlinUI::init_lcd() { ExtUI::onStartup(); } void MarlinUI::update() { ExtUI::onIdle(); } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 04a298ba582e..248bffb6f4ad 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -83,8 +83,10 @@ namespace ExtUI { void injectCommands(char * const); bool commandsInQueue(); - GcodeSuite::MarlinBusyState getHostKeepaliveState(); - bool getHostKeepaliveIsPaused(); + #if ENABLED(HOST_KEEPALIVE_FEATURE) + GcodeSuite::MarlinBusyState getHostKeepaliveState(); + bool getHostKeepaliveIsPaused(); + #endif bool isHeaterIdle(const heater_t); bool isHeaterIdle(const extruder_t); @@ -172,7 +174,8 @@ namespace ExtUI { float getMeshPoint(const xy_uint8_t &pos); void setMeshPoint(const xy_uint8_t &pos, const_float_t zval); void moveToMeshPoint(const xy_uint8_t &pos, const_float_t z); - void onMeshLevelingStart(); + void onLevelingStart(); + void onLevelingDone(); void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); inline void onMeshUpdate(const xy_int8_t &pos, const_float_t zval) { onMeshUpdate(pos.x, pos.y, zval); } @@ -196,7 +199,7 @@ namespace ExtUI { #endif inline void simulateUserClick() { - #if ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) + #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) ui.lcd_clicked = true; #endif } @@ -315,6 +318,11 @@ namespace ExtUI { #endif #endif + #if ENABLED(POWER_LOSS_RECOVERY) + bool getPowerLossRecoveryEnabled(); + void setPowerLossRecoveryEnabled(const bool); + #endif + #if ENABLED(PIDTEMP) float getPIDValues_Kp(const extruder_t); float getPIDValues_Ki(const extruder_t); @@ -398,14 +406,14 @@ namespace ExtUI { void onPrintTimerStarted(); void onPrintTimerPaused(); void onPrintTimerStopped(); - void onPrintFinished(); + void onPrintDone(); void onFilamentRunout(const extruder_t extruder); void onUserConfirmRequired(const char * const msg); void onUserConfirmRequired(FSTR_P const fstr); void onStatusChanged(const char * const msg); void onStatusChanged(FSTR_P const fstr); void onHomingStart(); - void onHomingComplete(); + void onHomingDone(); void onSteppersDisabled(); void onSteppersEnabled(); void onFactoryReset(); diff --git a/Marlin/src/lcd/fontutils.h b/Marlin/src/lcd/fontutils.h index 3901d4439fde..21aee1e93919 100644 --- a/Marlin/src/lcd/fontutils.h +++ b/Marlin/src/lcd/fontutils.h @@ -63,6 +63,7 @@ uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t /* Returns length of string in CHARACTERS, NOT BYTES */ uint8_t utf8_strlen(const char *pstart); uint8_t utf8_strlen_P(PGM_P pstart); +inline uint8_t utf8_strlen(FSTR_P fstart) { return utf8_strlen_P(FTOP(fstart)); } /* Returns start byte position of desired char number */ uint8_t utf8_byte_pos_by_char_num(const char *pstart, const uint8_t charnum); diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 8e4ff0e95cfc..1ebe13868717 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -107,23 +107,23 @@ namespace Language_an { LSTR MSG_ACC = _UxGT("Aceleracion"); LSTR MSG_VTRAV_MIN = _UxGT("Vel. viache min"); LSTR MSG_ACCELERATION = _UxGT("Accel"); - LSTR MSG_AMAX_A = _UxGT("Acel. max ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Acel. max ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Acel. max ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Acel. max ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Acel. max ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Acel. max ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Acel. max ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Acel. max ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Acel. max ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Acel. max ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Acel. max ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Acel. max ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Acel. max ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Acel. max ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Acel. max *"); LSTR MSG_A_RETRACT = _UxGT("Acel. retrac."); LSTR MSG_A_TRAVEL = _UxGT("Acel. Viaje"); LSTR MSG_STEPS_PER_MM = _UxGT("Trangos/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" trangos/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" trangos/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" trangos/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" trangos/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" trangos/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" trangos/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" trangos/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" trangos/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" trangos/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" trangos/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" trangos/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" trangos/mm"); LSTR MSG_E_STEPS = _UxGT("E trangos/mm"); LSTR MSG_EN_STEPS = _UxGT("* trangos/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -195,7 +195,7 @@ namespace Language_an { LSTR MSG_INFO_PROTOCOL = _UxGT("Protocolo"); LSTR MSG_CASE_LIGHT = _UxGT("Luz"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Conteo de impresion"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completadas"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tiempo total d'imp."); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 05209f771808..3137228c2d29 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -99,12 +99,12 @@ namespace Language_bg { LSTR MSG_A_RETRACT = _UxGT("A-откат"); LSTR MSG_A_TRAVEL = _UxGT("A-travel"); LSTR MSG_STEPS_PER_MM = _UxGT("Стъпки/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" стъпки/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" стъпки/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" стъпки/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" стъпки/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" стъпки/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" стъпки/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" стъпки/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" стъпки/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" стъпки/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" стъпки/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" стъпки/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" стъпки/mm"); LSTR MSG_E_STEPS = _UxGT("E стъпки/mm"); LSTR MSG_EN_STEPS = _UxGT("* стъпки/mm"); LSTR MSG_TEMPERATURE = _UxGT("Температура"); diff --git a/Marlin/src/lcd/language/language_ca.h b/Marlin/src/lcd/language/language_ca.h index 6fba76a552e1..0e16c1a1fa47 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -105,12 +105,12 @@ namespace Language_ca { LSTR MSG_A_RETRACT = _UxGT("Accel. retracc"); LSTR MSG_A_TRAVEL = _UxGT("Accel. Viatge"); LSTR MSG_STEPS_PER_MM = _UxGT("Passos/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" passos/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" passos/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" passos/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" passos/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" passos/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" passos/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" passos/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" passos/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" passos/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" passos/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" passos/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" passos/mm"); LSTR MSG_E_STEPS = _UxGT("Epassos/mm"); LSTR MSG_EN_STEPS = _UxGT("*passos/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -183,7 +183,7 @@ namespace Language_ca { LSTR MSG_INFO_PROTOCOL = _UxGT("Protocol"); LSTR MSG_CASE_LIGHT = _UxGT("Llum"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Total impressions"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Acabades"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Temps imprimint"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index 596591e0f66e..6f5d8445af82 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -60,7 +60,7 @@ namespace Language_cz { LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Uvolnit motory"); LSTR MSG_DEBUG_MENU = _UxGT("Nabídka ladění"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test ukaz. průběhu"); #else LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test uk. průběhu"); @@ -267,43 +267,43 @@ namespace Language_cz { LSTR MSG_SELECT_E = _UxGT("Vybrat *"); LSTR MSG_ACC = _UxGT("Zrychl"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + LSTR MSG_VB_JERK = _UxGT("Max ") STR_B _UxGT(" Jerk"); + LSTR MSG_VC_JERK = _UxGT("Max ") STR_C _UxGT(" Jerk"); + LSTR MSG_VI_JERK = _UxGT("Max ") STR_I _UxGT(" Jerk"); + LSTR MSG_VJ_JERK = _UxGT("Max ") STR_J _UxGT(" Jerk"); + LSTR MSG_VK_JERK = _UxGT("Max ") STR_K _UxGT(" Jerk"); LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Odchylka spoje"); LSTR MSG_VELOCITY = _UxGT("Rychlost"); - LSTR MSG_VMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Rychlost"); - LSTR MSG_VMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Rychlost"); - LSTR MSG_VMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Rychlost"); - LSTR MSG_VMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Rychlost"); - LSTR MSG_VMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Rychlost"); - LSTR MSG_VMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Rychlost"); - LSTR MSG_VMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Rychlost"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Rychlost"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Rychlost"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Rychlost"); + LSTR MSG_VMAX_I = _UxGT("Max ") STR_I _UxGT(" Rychlost"); + LSTR MSG_VMAX_J = _UxGT("Max ") STR_J _UxGT(" Rychlost"); + LSTR MSG_VMAX_K = _UxGT("Max ") STR_K _UxGT(" Rychlost"); + LSTR MSG_VMAX_E = _UxGT("Max ") STR_E _UxGT(" Rychlost"); LSTR MSG_VMAX_EN = _UxGT("Max * Rychlost"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VTrav Min"); LSTR MSG_ACCELERATION = _UxGT("Akcelerace"); - LSTR MSG_AMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Akcel"); - LSTR MSG_AMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Akcel"); - LSTR MSG_AMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Akcel"); - LSTR MSG_AMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Akcel"); - LSTR MSG_AMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Akcel"); - LSTR MSG_AMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Akcel"); - LSTR MSG_AMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Akcel"); + LSTR MSG_AMAX_A = _UxGT("Max ") STR_A _UxGT(" Akcel"); + LSTR MSG_AMAX_B = _UxGT("Max ") STR_B _UxGT(" Akcel"); + LSTR MSG_AMAX_C = _UxGT("Max ") STR_C _UxGT(" Akcel"); + LSTR MSG_AMAX_I = _UxGT("Max ") STR_I _UxGT(" Akcel"); + LSTR MSG_AMAX_J = _UxGT("Max ") STR_J _UxGT(" Akcel"); + LSTR MSG_AMAX_K = _UxGT("Max ") STR_K _UxGT(" Akcel"); + LSTR MSG_AMAX_E = _UxGT("Max ") STR_E _UxGT(" Akcel"); LSTR MSG_AMAX_EN = _UxGT("Max * Akcel"); LSTR MSG_A_RETRACT = _UxGT("A-retrakt"); LSTR MSG_A_TRAVEL = _UxGT("A-přejezd"); LSTR MSG_STEPS_PER_MM = _UxGT("Kroků/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" kroků/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" kroků/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" kroků/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" kroků/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" kroků/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" kroků/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" kroků/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" kroků/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" kroků/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" kroků/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" kroků/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" kroků/mm"); LSTR MSG_E_STEPS = _UxGT("E kroků/mm"); LSTR MSG_EN_STEPS = _UxGT("* kroků/mm"); LSTR MSG_TEMPERATURE = _UxGT("Teplota"); @@ -421,12 +421,12 @@ namespace Language_cz { LSTR MSG_PLEASE_RESET = _UxGT("Proveďte reset"); LSTR MSG_HEATING = _UxGT("Zahřívání..."); LSTR MSG_COOLING = _UxGT("Chlazení..."); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_BED_HEATING = _UxGT("Zahřívání podložky"); #else LSTR MSG_BED_HEATING = _UxGT("Zahřívání podl."); #endif - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_BED_COOLING = _UxGT("Chlazení podložky"); #else LSTR MSG_BED_COOLING = _UxGT("Chlazení podl."); @@ -465,7 +465,7 @@ namespace Language_cz { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Jas světla"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("NESPRÁVNÁ TISKÁRNA"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Počet tisků"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Dokončeno"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Celkový čas"); @@ -483,12 +483,12 @@ namespace Language_cz { LSTR MSG_INFO_MAX_TEMP = _UxGT("Teplota max"); LSTR MSG_INFO_PSU = _UxGT("Nap. zdroj"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Buzení motorů"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Motor %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Motor %"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC uložit EEPROM"); LSTR MSG_ERROR_TMC = _UxGT("TMC CHYBA SPOJENÍ"); @@ -535,7 +535,7 @@ namespace Language_cz { LSTR MSG_CYCLE_MIX = _UxGT("Střídat mix"); LSTR MSG_GRADIENT_MIX = _UxGT("Přechod mix"); LSTR MSG_REVERSE_GRADIENT = _UxGT("Opačný přechod"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_ACTIVE_VTOOL = _UxGT("Aktivní V-nástroj"); LSTR MSG_START_VTOOL = _UxGT("Spustit V-nástroj"); LSTR MSG_END_VTOOL = _UxGT("Ukončit V-nástroj"); diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index e03260557868..b022720b5cae 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -156,7 +156,7 @@ namespace Language_da { LSTR MSG_INFO_BOARD_MENU = _UxGT("Kort Info"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistors"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Ant. Prints"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Færdige"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Total print tid"); @@ -173,12 +173,12 @@ namespace Language_da { LSTR MSG_INFO_PSU = _UxGT("Strømfors."); LSTR MSG_DRIVE_STRENGTH = _UxGT("Driv Styrke"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driv %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Driv %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Driv %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Driv %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Driv %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Driv %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Driv %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Driv %"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Skriv"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 613880caa65d..a6782bb0acc2 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -42,7 +42,7 @@ namespace Language_de { LSTR MSG_MEDIA_INSERTED = _UxGT("Medium erkannt"); LSTR MSG_MEDIA_REMOVED = _UxGT("Medium entfernt"); LSTR MSG_MEDIA_WAITING = _UxGT("Warten auf Medium"); - LSTR MSG_SD_INIT_FAIL = _UxGT("SD Init fehlgesch."); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Medium Init fehlgesch."); LSTR MSG_MEDIA_READ_ERROR = _UxGT("Medium Lesefehler"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB Gerät entfernt"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("USB Start fehlge."); @@ -56,19 +56,42 @@ namespace Language_de { LSTR MSG_DISABLE_STEPPERS = _UxGT("Motoren deaktivieren"); // M84 :: Max length 19 characters LSTR MSG_DEBUG_MENU = _UxGT("Debug-Menü"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Statusbalken-Test"); + LSTR MSG_HOMING = _UxGT("Homing"); LSTR MSG_AUTO_HOME = _UxGT("Auto Home"); + LSTR MSG_AUTO_HOME_A = _UxGT("Home @"); LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); + LSTR MSG_FILAMENT_SET = _UxGT("Fila. Einstellungen"); + LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); + LSTR MSG_LEVBED_FL = _UxGT("Vorne Links"); + LSTR MSG_LEVBED_FR = _UxGT("Vorne Rechts"); + LSTR MSG_LEVBED_C = _UxGT("Mitte"); + LSTR MSG_LEVBED_BL = _UxGT("Hinten Links"); + LSTR MSG_LEVBED_BR = _UxGT("Hinten Rechts"); + LSTR MSG_MANUAL_MESH = _UxGT("manuelles Netz"); + LSTR MSG_AUTO_MESH = _UxGT("Netz auto. erstellen"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Z-Achsen ausgleichen"); + LSTR MSG_ITERATION = _UxGT("G34 Iteration: %i"); + LSTR MSG_DECREASING_ACCURACY = _UxGT("Genauigkeit sinkt!"); + LSTR MSG_ACCURACY_ACHIEVED = _UxGT("Genauigkeit erreicht"); LSTR MSG_LEVEL_BED_HOMING = _UxGT("XYZ homen"); LSTR MSG_LEVEL_BED_WAITING = _UxGT("Klick zum Starten"); LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Nächste Koordinate"); LSTR MSG_LEVEL_BED_DONE = _UxGT("Nivellieren fertig!"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Ausblendhöhe"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Setze Homeversatz"); + LSTR MSG_HOME_OFFSET_X = _UxGT("Homeversatz X"); + LSTR MSG_HOME_OFFSET_Y = _UxGT("Homeversatz Y"); + LSTR MSG_HOME_OFFSET_Z = _UxGT("Homeversatz Z"); + LSTR MSG_HOME_OFFSET_I = _UxGT("Homeversatz ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Homeversatz ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Homeversatz ") STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Homeversatz aktiv"); LSTR MSG_SET_ORIGIN = _UxGT("Setze Nullpunkte"); //"G92 X0 Y0 Z0" commented out in marlinui.cpp + LSTR MSG_TRAMMING_WIZARD = _UxGT("Tramming Assistent"); + LSTR MSG_SELECT_ORIGIN = _UxGT("Wählen Sie Ursprung"); + LSTR MSG_LAST_VALUE_SP = _UxGT("Letzter Wert "); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" Vorwärmen"); LSTR MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" Vorwärmen ~"); @@ -88,11 +111,21 @@ namespace Language_de { #endif LSTR MSG_PREHEAT_CUSTOM = _UxGT("benutzerdef. Heizen"); LSTR MSG_COOLDOWN = _UxGT("Abkühlen"); + LSTR MSG_CUTTER_FREQUENCY = _UxGT("Frequenz"); LSTR MSG_LASER_MENU = _UxGT("Laser"); - LSTR MSG_LASER_POWER = _UxGT("Laserleistung"); LSTR MSG_SPINDLE_MENU = _UxGT("Spindel-Steuerung"); + LSTR MSG_LASER_POWER = _UxGT("Laserleistung"); LSTR MSG_SPINDLE_POWER = _UxGT("Spindelleistung"); + LSTR MSG_LASER_TOGGLE = _UxGT("Laser umschalten"); + LSTR MSG_LASER_EVAC_TOGGLE = _UxGT("Gebläse umschalten"); + LSTR MSG_LASER_ASSIST_TOGGLE = _UxGT("Luftunterstützung"); + LSTR MSG_LASER_PULSE_MS = _UxGT("Test Impuls ms"); + LSTR MSG_LASER_FIRE_PULSE = _UxGT("Fire Impuls"); + LSTR MSG_FLOWMETER_FAULT = _UxGT("Feh. Kühlmittelfluss"); + LSTR MSG_SPINDLE_TOGGLE = _UxGT("Spindel umschalten"); + LSTR MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Vakuum umschalten"); + LSTR MSG_SPINDLE_FORWARD = _UxGT("Spindel vorwärts"); LSTR MSG_SPINDLE_REVERSE = _UxGT("Spindelrichtung"); LSTR MSG_SWITCH_PS_ON = _UxGT("Netzteil ein"); LSTR MSG_SWITCH_PS_OFF = _UxGT("Netzteil aus"); @@ -102,10 +135,18 @@ namespace Language_de { LSTR MSG_BED_LEVELING = _UxGT("Bett-Nivellierung"); LSTR MSG_LEVEL_BED = _UxGT("Bett nivellieren"); LSTR MSG_BED_TRAMMING = _UxGT("Bett ausrichten"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Manuelles ausrichten"); + LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Das Bett anpassen, bis zum auslösen."); + LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Ecken in der Toleranz. Bett ausger."); + LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Gute Punkte: "); + LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Letztes Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Nächste Ecke"); LSTR MSG_MESH_EDITOR = _UxGT("Netz Editor"); + LSTR MSG_MESH_VIEWER = _UxGT("Netzbetrachter"); LSTR MSG_EDIT_MESH = _UxGT("Netz bearbeiten"); + LSTR MSG_MESH_VIEW = _UxGT("Netz ansehen"); LSTR MSG_EDITING_STOPPED = _UxGT("Netzbearb. angeh."); + LSTR MSG_NO_VALID_MESH = _UxGT("Kein gültiges Netz"); LSTR MSG_PROBING_POINT = _UxGT("Messpunkt"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); @@ -121,6 +162,7 @@ namespace Language_de { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplizieren"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Spiegelkopie"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("vollstä. Kontrolle"); + LSTR MSG_IDEX_DUPE_GAP = _UxGT("X-Lücke duplizieren"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. Düse Z"); LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. Düse @"); LSTR MSG_UBL_DOING_G29 = _UxGT("G29 ausführen"); @@ -128,6 +170,7 @@ namespace Language_de { LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Berührungspunkt"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Netz manuell erst."); + LSTR MSG_UBL_MESH_WIZARD = _UxGT("UBL Netz Assistent"); LSTR MSG_UBL_BC_INSERT = _UxGT("Unterlegen & messen"); LSTR MSG_UBL_BC_INSERT2 = _UxGT("Messen"); LSTR MSG_UBL_BC_REMOVE = _UxGT("Entfernen & messen"); @@ -212,6 +255,10 @@ namespace Language_de { LSTR MSG_SET_LEDS_VIOLET = _UxGT("Violett"); LSTR MSG_SET_LEDS_WHITE = _UxGT("Weiß"); LSTR MSG_SET_LEDS_DEFAULT = _UxGT("Standard"); + LSTR MSG_LED_CHANNEL_N = _UxGT("Kanal ="); + LSTR MSG_LEDS2 = _UxGT("Lichter #2"); + LSTR MSG_NEO2_PRESETS = _UxGT("Licht #2 Voreinst."); + LSTR MSG_NEO2_BRIGHTNESS = _UxGT("Helligkeit"); LSTR MSG_CUSTOM_LEDS = _UxGT("Benutzerdefiniert"); LSTR MSG_INTENSITY_R = _UxGT("Intensität Rot"); LSTR MSG_INTENSITY_G = _UxGT("Intensität Grün"); @@ -224,6 +271,9 @@ namespace Language_de { LSTR MSG_MOVE_X = _UxGT("Bewege X"); LSTR MSG_MOVE_Y = _UxGT("Bewege Y"); LSTR MSG_MOVE_Z = _UxGT("Bewege Z"); + LSTR MSG_MOVE_I = _UxGT("Bewege ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Bewege ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Bewege ") STR_K; LSTR MSG_MOVE_E = _UxGT("Bewege Extruder"); LSTR MSG_MOVE_EN = _UxGT("Bewege Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend zu kalt"); @@ -232,7 +282,17 @@ namespace Language_de { LSTR MSG_MOVE_1MM = _UxGT(" 1,0 mm"); LSTR MSG_MOVE_10MM = _UxGT(" 10,0 mm"); LSTR MSG_MOVE_100MM = _UxGT("100,0 mm"); + LSTR MSG_MOVE_0001IN = _UxGT("0.001 in"); + LSTR MSG_MOVE_001IN = _UxGT("0.010 in"); + LSTR MSG_MOVE_01IN = _UxGT("0.100 in"); + LSTR MSG_MOVE_1IN = _UxGT("1.000 in"); LSTR MSG_SPEED = _UxGT("Geschw."); + LSTR MSG_MAXSPEED = _UxGT("Max Geschw. (mm/s)"); + LSTR MSG_MAXSPEED_X = _UxGT("Max ") STR_A _UxGT(" Geschw."); + LSTR MSG_MAXSPEED_Y = _UxGT("Max ") STR_B _UxGT(" Geschw."); + LSTR MSG_MAXSPEED_Z = _UxGT("Max ") STR_C _UxGT(" Geschw."); + LSTR MSG_MAXSPEED_E = _UxGT("Max ") STR_E _UxGT(" Geschw."); + LSTR MSG_MAXSPEED_A = _UxGT("Max @ Geschw."); LSTR MSG_BED_Z = _UxGT("Bett Z"); LSTR MSG_NOZZLE = _UxGT("Düse"); LSTR MSG_NOZZLE_N = _UxGT("Düse ~"); @@ -240,6 +300,10 @@ namespace Language_de { LSTR MSG_NOZZLE_STANDBY = _UxGT("Düse bereit"); LSTR MSG_BED = _UxGT("Bett"); LSTR MSG_CHAMBER = _UxGT("Gehäuse"); + LSTR MSG_COOLER = _UxGT("Laser-Kühlmittel"); + LSTR MSG_COOLER_TOGGLE = _UxGT("Kühler umschalten"); + LSTR MSG_FLOWMETER_SAFETY = _UxGT("Durchflusssicherheit"); + LSTR MSG_LASER = _UxGT("Laser"); LSTR MSG_FAN_SPEED = _UxGT("Lüfter"); LSTR MSG_FAN_SPEED_N = _UxGT("Lüfter ~"); LSTR MSG_STORED_FAN_N = _UxGT("Gespeich. Lüfter ~"); @@ -261,6 +325,7 @@ namespace Language_de { LSTR MSG_LCD_OFF = _UxGT("aus"); LSTR MSG_PID_AUTOTUNE = _UxGT("PID Autotune"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autotune *"); + LSTR MSG_PID_CYCLE = _UxGT("PID Zyklus"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID Tuning fertig"); LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge. Falscher Extruder"); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune fehlge. Temperatur zu hoch."); @@ -269,47 +334,46 @@ namespace Language_de { LSTR MSG_SELECT_E = _UxGT("Auswählen *"); LSTR MSG_ACC = _UxGT("Beschleunigung"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + LSTR MSG_VB_JERK = _UxGT("Max ") STR_B _UxGT(" Jerk"); + LSTR MSG_VC_JERK = _UxGT("Max ") STR_C _UxGT(" Jerk"); + LSTR MSG_VI_JERK = _UxGT("Max ") STR_I _UxGT(" Jerk"); + LSTR MSG_VJ_JERK = _UxGT("Max ") STR_J _UxGT(" Jerk"); + LSTR MSG_VK_JERK = _UxGT("Max ") STR_K _UxGT(" Jerk"); LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); LSTR MSG_VELOCITY = _UxGT("Geschwindigkeit"); - LSTR MSG_VMAX_A = _UxGT("V max ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("V max ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("V max ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("V max ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("V max ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("V max ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("V max ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("V max ") STR_A; + LSTR MSG_VMAX_B = _UxGT("V max ") STR_B; + LSTR MSG_VMAX_C = _UxGT("V max ") STR_C; + LSTR MSG_VMAX_I = _UxGT("V max ") STR_I; + LSTR MSG_VMAX_J = _UxGT("V max ") STR_J; + LSTR MSG_VMAX_K = _UxGT("V max ") STR_K; + LSTR MSG_VMAX_E = _UxGT("V max ") STR_E; LSTR MSG_VMAX_EN = _UxGT("V max *"); LSTR MSG_VMIN = _UxGT("V min "); LSTR MSG_VTRAV_MIN = _UxGT("V min Leerfahrt"); LSTR MSG_ACCELERATION = _UxGT("Beschleunigung"); - LSTR MSG_AMAX = _UxGT("A max "); // space intentional - LSTR MSG_AMAX_A = _UxGT("A max ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("A max ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("A max ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("A max ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("A max ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("A max ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("A max ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("A max ") STR_A; + LSTR MSG_AMAX_B = _UxGT("A max ") STR_B; + LSTR MSG_AMAX_C = _UxGT("A max ") STR_C; + LSTR MSG_AMAX_I = _UxGT("A max ") STR_I; + LSTR MSG_AMAX_J = _UxGT("A max ") STR_J; + LSTR MSG_AMAX_K = _UxGT("A max ") STR_K; + LSTR MSG_AMAX_E = _UxGT("A max ") STR_E; LSTR MSG_AMAX_EN = _UxGT("A max *"); LSTR MSG_A_RETRACT = _UxGT("A Einzug"); LSTR MSG_A_TRAVEL = _UxGT("A Leerfahrt"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("max. Frequenz"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("min. Vorschub"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" Steps/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" Steps/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" Steps/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" Steps/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" Steps/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" Steps/mm"); - LSTR MSG_E_STEPS = LCD_STR_E _UxGT(" Steps/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" Steps/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" Steps/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" Steps/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" Steps/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" Steps/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" Steps/mm"); + LSTR MSG_E_STEPS = STR_E _UxGT(" Steps/mm"); LSTR MSG_EN_STEPS = _UxGT("* Steps/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatur"); LSTR MSG_MOTION = _UxGT("Bewegung"); @@ -324,6 +388,9 @@ namespace Language_de { LSTR MSG_ADVANCE_K = _UxGT("Vorschubfaktor"); LSTR MSG_ADVANCE_K_E = _UxGT("Vorschubfaktor *"); LSTR MSG_CONTRAST = _UxGT("LCD-Kontrast"); + LSTR MSG_BRIGHTNESS = _UxGT("LCD-Helligkeit"); + LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD-Ruhezustand (s)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("LCD ausschalten"); LSTR MSG_STORE_EEPROM = _UxGT("Konfig. speichern"); LSTR MSG_LOAD_EEPROM = _UxGT("Konfig. laden"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Standardwerte laden"); @@ -334,7 +401,7 @@ namespace Language_de { LSTR MSG_SETTINGS_STORED = _UxGT("Einstell. gespei."); LSTR MSG_MEDIA_UPDATE = _UxGT("FW Update vom Medium"); LSTR MSG_RESET_PRINTER = _UxGT("Drucker neustarten"); - LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Aktualisieren"); + LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Aktualisieren"); LSTR MSG_INFO_SCREEN = _UxGT("Info"); LSTR MSG_PREPARE = _UxGT("Vorbereitung"); LSTR MSG_TUNE = _UxGT("Justierung"); @@ -350,23 +417,38 @@ namespace Language_de { LSTR MSG_BUTTON_RESET = _UxGT("Reseten"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ignorieren"); LSTR MSG_BUTTON_CANCEL = _UxGT("Abbrechen"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Bestätigen"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Fortsetzen"); LSTR MSG_BUTTON_DONE = _UxGT("Fertig"); LSTR MSG_BUTTON_BACK = _UxGT("Zurück"); LSTR MSG_BUTTON_PROCEED = _UxGT("Weiter"); + LSTR MSG_BUTTON_SKIP = _UxGT("Überspringen"); + LSTR MSG_BUTTON_INFO = _UxGT("Info"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Level"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Pause"); + LSTR MSG_BUTTON_RESUME = _UxGT("Fortsetzen"); + LSTR MSG_BUTTON_ADVANCED = _UxGT("Erweitert"); + LSTR MSG_BUTTON_SAVE = _UxGT("Speichern"); LSTR MSG_PAUSING = _UxGT("Pause..."); LSTR MSG_PAUSE_PRINT = _UxGT("SD-Druck pausieren"); + LSTR MSG_ADVANCED_PAUSE = _UxGT("Erweiterte Pause"); LSTR MSG_RESUME_PRINT = _UxGT("SD-Druck fortsetzen"); + LSTR MSG_HOST_START_PRINT = _UxGT("Host-Druck starten"); LSTR MSG_STOP_PRINT = _UxGT("SD-Druck abbrechen"); + LSTR MSG_END_LOOPS = _UxGT("Wiederholung beenden"); LSTR MSG_PRINTING_OBJECT = _UxGT("Objekt drucken"); LSTR MSG_CANCEL_OBJECT = _UxGT("Objekt abbrechen"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Objekt abbrechen ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Wiederh. n. Stroma."); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Druckauftrag fortset."); LSTR MSG_MEDIA_MENU = _UxGT("Druck vom Medium"); LSTR MSG_NO_MEDIA = _UxGT("Kein Medium"); LSTR MSG_DWELL = _UxGT("Warten..."); LSTR MSG_USERWAIT = _UxGT("Klick zum Fortsetzen"); LSTR MSG_PRINT_PAUSED = _UxGT("Druck pausiert..."); LSTR MSG_PRINTING = _UxGT("Druckt..."); + LSTR MSG_STOPPING = _UxGT("Stoppen..."); + LSTR MSG_REMAINING_TIME = _UxGT("Verbleiben"); LSTR MSG_PRINT_ABORTED = _UxGT("Druck abgebrochen"); LSTR MSG_PRINT_DONE = _UxGT("Druck fertig"); LSTR MSG_NO_MOVE = _UxGT("Motoren angeschaltet"); @@ -416,6 +498,7 @@ namespace Language_de { LSTR MSG_BLTOUCH_STOW = _UxGT("Einfahren"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Ausfahren"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Modus"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("High Speed"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Modus"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Modus"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); @@ -431,33 +514,43 @@ namespace Language_de { LSTR MSG_MANUAL_DEPLOY = _UxGT("Z-Sonde ausfahren"); LSTR MSG_MANUAL_STOW = _UxGT("Z-Sonde einfahren"); LSTR MSG_HOME_FIRST = _UxGT("Vorher %s%s%s homen"); + LSTR MSG_ZPROBE_SETTINGS = _UxGT("Sondeneinstellungen"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Sondenversatz"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Sondenversatz X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Sondenversatz Y"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Sondenversatz Z"); + LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Bewege Düse zum Bett"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); + LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Abbr. mit Endstopp"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("HEIZEN ERFOLGLOS"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("REDUND. TEMP-ABWEI."); LSTR MSG_THERMAL_RUNAWAY = " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("TEMP-FEHLER"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("BETT") " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("GEH.") " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); + LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Kühler Runaway"); + LSTR MSG_COOLING_FAILED = _UxGT("Kühlung fehlgeschla."); LSTR MSG_ERR_MAXTEMP = " " LCD_STR_THERMOMETER _UxGT(" ÜBERSCHRITTEN"); LSTR MSG_ERR_MINTEMP = " " LCD_STR_THERMOMETER _UxGT(" UNTERSCHRITTEN"); LSTR MSG_HALTED = _UxGT("DRUCKER GESTOPPT"); + LSTR MSG_PLEASE_WAIT = _UxGT("Bitte warten..."); LSTR MSG_PLEASE_RESET = _UxGT("Bitte neustarten"); - LSTR MSG_SHORT_DAY = _UxGT("t"); // One character only - LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character only + LSTR MSG_PREHEATING = _UxGT("vorheizen..."); LSTR MSG_HEATING = _UxGT("heizt..."); LSTR MSG_COOLING = _UxGT("kühlt..."); LSTR MSG_BED_HEATING = _UxGT("Bett heizt..."); LSTR MSG_BED_COOLING = _UxGT("Bett kühlt..."); + LSTR MSG_PROBE_HEATING = _UxGT("Sonde heizt..."); + LSTR MSG_PROBE_COOLING = _UxGT("Sonde kühlt..."); LSTR MSG_CHAMBER_HEATING = _UxGT("Gehäuse heizt..."); LSTR MSG_CHAMBER_COOLING = _UxGT("Gehäuse kühlt..."); + LSTR MSG_LASER_COOLING = _UxGT("Laser kühlt..."); LSTR MSG_DELTA_CALIBRATE = _UxGT("Delta kalibrieren"); LSTR MSG_DELTA_CALIBRATE_X = _UxGT("Kalibriere X"); LSTR MSG_DELTA_CALIBRATE_Y = _UxGT("Kalibriere Y"); @@ -475,8 +568,9 @@ namespace Language_de { LSTR MSG_3POINT_LEVELING = _UxGT("3-Punkt-Nivellierung"); LSTR MSG_LINEAR_LEVELING = _UxGT("Lineare Nivellierung"); LSTR MSG_BILINEAR_LEVELING = _UxGT("Bilineare Nivell."); - LSTR MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling"); + LSTR MSG_UBL_LEVELING = _UxGT("Einheit. Bettnivell."); LSTR MSG_MESH_LEVELING = _UxGT("Netz-Nivellierung"); + LSTR MSG_MESH_DONE = _UxGT("Nivellierung fertig"); LSTR MSG_INFO_STATS_MENU = _UxGT("Drucker-Statistik"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Board-Info"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistoren"); @@ -486,35 +580,51 @@ namespace Language_de { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: AUS"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: AN"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); + LSTR MSG_FAN_SPEED_FAULT = _UxGT("Fehler Lüftergeschw."); + LSTR MSG_CASE_LIGHT = _UxGT("Beleuchtung"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Helligkeit"); - LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Falscher Drucker"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Kein Medium eingelegt."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Bitte auf Neustart warten. "); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte das Hot-End vorheizen."); + LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Druckzähler zurücksetzen"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Gesamte Drucke"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Komplette Drucke"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Gesamte Druckzeit"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Längste Druckzeit"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Gesamt Extrudiert"); + LSTR MSG_COLORS_GET = _UxGT("Farbe"); + LSTR MSG_COLORS_SELECT = _UxGT("Farben auswählen"); + LSTR MSG_COLORS_APPLIED = _UxGT("Farben verwenden"); + LSTR MSG_COLORS_RED = _UxGT("Rot"); + LSTR MSG_COLORS_GREEN = _UxGT("Grün"); + LSTR MSG_COLORS_BLUE = _UxGT("Blau"); + LSTR MSG_COLORS_WHITE = _UxGT("Weiß"); + LSTR MSG_UI_LANGUAGE = _UxGT("UI Sprache"); + LSTR MSG_SOUND_ENABLE = _UxGT("Ton aktivieren"); + LSTR MSG_LOCKSCREEN = _UxGT("Bildschirm sperren"); #else LSTR MSG_INFO_PRINT_COUNT = _UxGT("Drucke"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Komplette"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Gesamte"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Längste"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extrud."); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte vorheizen"); #endif LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); LSTR MSG_INFO_PSU = _UxGT("Netzteil"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Motorleistung"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Treiber %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Treiber %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Treiber %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Treiber %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Treiber %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Treiber %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Treiber %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Treiber %"); LSTR MSG_ERROR_TMC = _UxGT("TMC Verbindungsfehler"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Werte speichern"); @@ -528,6 +638,8 @@ namespace Language_de { LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Düse: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout-Sensor"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Runout-Weg mm"); + LSTR MSG_RUNOUT_ENABLE = _UxGT("Runout aktivieren"); + LSTR MSG_FANCHECK = _UxGT("Lüftergeschw. prüfen"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing gescheitert"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Probing gescheitert"); @@ -639,4 +751,33 @@ namespace Language_de { #endif LSTR MSG_REHEAT = _UxGT("Erneut aufheizen"); LSTR MSG_REHEATING = _UxGT("Erneut aufhei. ..."); + LSTR MSG_REHEATDONE = _UxGT("Aufwärmen fertig"); + + LSTR MSG_PROBE_WIZARD = _UxGT("Sonden-Assistent"); + LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Sonden-Bezug"); + LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Bewege zur Position"); + + LSTR MSG_XATC = _UxGT("X-Verdreh-Assistent"); + LSTR MSG_XATC_DONE = _UxGT("X-Verdreh-Assi fertig!"); + LSTR MSG_XATC_UPDATE_Z_OFFSET = _UxGT("Z-Versatz Sonde akt. auf "); + + LSTR MSG_SOUND = _UxGT("Ton"); + + LSTR MSG_TOP_LEFT = _UxGT("Oben Links"); + LSTR MSG_BOTTOM_LEFT = _UxGT("Unten Links"); + LSTR MSG_TOP_RIGHT = _UxGT("Oben Rechts"); + LSTR MSG_BOTTOM_RIGHT = _UxGT("Unten Rechts"); + LSTR MSG_CALIBRATION_COMPLETED = _UxGT("Kalibrierung beendet"); + LSTR MSG_CALIBRATION_FAILED = _UxGT("Kalibrierung geschei."); + + LSTR MSG_DRIVER_BACKWARD = _UxGT(" Driver zurück"); + + LSTR MSG_SD_CARD = _UxGT("SD Karte"); + LSTR MSG_USB_DISK = _UxGT("USB Disk"); + + LSTR MSG_HOST_SHUTDOWN = _UxGT("Host abschalten"); + + LSTR MSG_SHORT_DAY = _UxGT("t"); // One character only + LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character only + LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character only } diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 3d1a79ea922b..f3cd7ef27898 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -50,7 +50,7 @@ namespace Language_el { LSTR MSG_MEDIA_READ_ERROR = MEDIA_TYPE_EN _UxGT(" σφάλμα ανάγνωσης"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB αφαιρέθη"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Αποτυχία εκκίνησης USB"); - LSTR MSG_SD_INIT_FAIL = _UxGT("Αποτυχία αρχικοποίησης SD"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Αποτυχία αρχικοποίησης SD"); LSTR MSG_MAIN = _UxGT("Αρχική Οθόνη"); LSTR MSG_RUN_AUTO_FILES = _UxGT("Αυτόματη εκκίνηση"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Απενεργοποίηση μοτέρ"); @@ -117,41 +117,41 @@ namespace Language_el { LSTR MSG_LCD_ON = _UxGT("Ενεργοποιημένο"); LSTR MSG_LCD_OFF = _UxGT("Απενεργοποιημένο"); LSTR MSG_ACC = _UxGT("Επιτάχυνση"); - LSTR MSG_VA_JERK = _UxGT("Vαντίδραση ") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("Vαντίδραση ") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("Vαντίδραση ") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("Vαντίδραση ") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("Vαντίδραση ") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("Vαντίδραση ") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("Vαντίδραση ") STR_A; + LSTR MSG_VB_JERK = _UxGT("Vαντίδραση ") STR_B; + LSTR MSG_VC_JERK = _UxGT("Vαντίδραση ") STR_C; + LSTR MSG_VI_JERK = _UxGT("Vαντίδραση ") STR_I; + LSTR MSG_VJ_JERK = _UxGT("Vαντίδραση ") STR_J; + LSTR MSG_VK_JERK = _UxGT("Vαντίδραση ") STR_K; LSTR MSG_VE_JERK = _UxGT("Vαντίδραση E"); - LSTR MSG_VMAX_A = _UxGT("V Μέγιστο") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("V Μέγιστο") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("V Μέγιστο") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("V Μέγιστο") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("V Μέγιστο") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("V Μέγιστο") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("V Μέγιστο") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("V Μέγιστο") STR_A; + LSTR MSG_VMAX_B = _UxGT("V Μέγιστο") STR_B; + LSTR MSG_VMAX_C = _UxGT("V Μέγιστο") STR_C; + LSTR MSG_VMAX_I = _UxGT("V Μέγιστο") STR_I; + LSTR MSG_VMAX_J = _UxGT("V Μέγιστο") STR_J; + LSTR MSG_VMAX_K = _UxGT("V Μέγιστο") STR_K; + LSTR MSG_VMAX_E = _UxGT("V Μέγιστο") STR_E; LSTR MSG_VMAX_EN = _UxGT("V Μέγιστο *"); LSTR MSG_VMIN = _UxGT("V Ελάχιστο"); LSTR MSG_VTRAV_MIN = _UxGT("Vελάχ. μετατόπιση"); LSTR MSG_ACCELERATION = _UxGT("Accel"); - LSTR MSG_AMAX_A = _UxGT("Aμεγ ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Aμεγ ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Aμεγ ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Aμεγ ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Aμεγ ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Aμεγ ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Aμεγ ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Aμεγ ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Aμεγ ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Aμεγ ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Aμεγ ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Aμεγ ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Aμεγ ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Aμεγ ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Aμεγ *"); LSTR MSG_A_RETRACT = _UxGT("Α-ανάσυρση"); LSTR MSG_A_TRAVEL = _UxGT("Α-μετατόπιση"); LSTR MSG_STEPS_PER_MM = _UxGT("Bήματα ανά μμ"); - LSTR MSG_A_STEPS = _UxGT("Bήματα ") LCD_STR_A _UxGT(" ανά μμ"); - LSTR MSG_B_STEPS = _UxGT("Bήματα ") LCD_STR_B _UxGT(" ανά μμ"); - LSTR MSG_C_STEPS = _UxGT("Bήματα ") LCD_STR_C _UxGT(" ανά μμ"); - LSTR MSG_I_STEPS = _UxGT("Bήματα ") LCD_STR_I _UxGT(" ανά μμ"); - LSTR MSG_J_STEPS = _UxGT("Bήματα ") LCD_STR_J _UxGT(" ανά μμ"); - LSTR MSG_K_STEPS = _UxGT("Bήματα ") LCD_STR_K _UxGT(" ανά μμ"); + LSTR MSG_A_STEPS = _UxGT("Bήματα ") STR_A _UxGT(" ανά μμ"); + LSTR MSG_B_STEPS = _UxGT("Bήματα ") STR_B _UxGT(" ανά μμ"); + LSTR MSG_C_STEPS = _UxGT("Bήματα ") STR_C _UxGT(" ανά μμ"); + LSTR MSG_I_STEPS = _UxGT("Bήματα ") STR_I _UxGT(" ανά μμ"); + LSTR MSG_J_STEPS = _UxGT("Bήματα ") STR_J _UxGT(" ανά μμ"); + LSTR MSG_K_STEPS = _UxGT("Bήματα ") STR_K _UxGT(" ανά μμ"); LSTR MSG_E_STEPS = _UxGT("Bήματα Ε ανά μμ"); LSTR MSG_EN_STEPS = _UxGT("Bήματα * ανά μμ"); LSTR MSG_TEMPERATURE = _UxGT("Θερμοκρασία"); @@ -202,6 +202,7 @@ namespace Language_el { LSTR MSG_HEATING_FAILED_LCD = _UxGT("Αποτυχία θέρμανσης"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("ΠΛΕΟΝΑΖΟΥΣΑ ΘΕΡΜΟΤΗΤΑ"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("ΘΕΡΜΙΚΗ ΔΙΑΦΥΓΗ"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("ΘΕΡΜΙΚΗ ΔΥΣΛΕΙΤΟΥΡΓΙΑ"); LSTR MSG_ERR_MAXTEMP = _UxGT("ΠΕΡΙΤΤΗ ΘΕΡΜΟΚΡΑΣΙΑ"); LSTR MSG_ERR_MINTEMP = _UxGT("ΑΝΕΠΑΡΚΗΣ ΘΕΡΜΟΚΡΑΣΙΑ"); LSTR MSG_HALTED = _UxGT("Εκτυπωτής διεκόπη"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index 53e3ee3b948b..d8c7cae38d68 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -107,41 +107,41 @@ namespace Language_el_gr { LSTR MSG_LCD_OFF = _UxGT("Απενεργοποιημένο"); LSTR MSG_ACC = _UxGT("Επιτάχυνση"); LSTR MSG_JERK = _UxGT("Vαντίδραση"); - LSTR MSG_VA_JERK = _UxGT("Vαντίδραση ") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("Vαντίδραση ") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("Vαντίδραση ") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("Vαντίδραση ") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("Vαντίδραση ") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("Vαντίδραση ") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("Vαντίδραση ") STR_A; + LSTR MSG_VB_JERK = _UxGT("Vαντίδραση ") STR_B; + LSTR MSG_VC_JERK = _UxGT("Vαντίδραση ") STR_C; + LSTR MSG_VI_JERK = _UxGT("Vαντίδραση ") STR_I; + LSTR MSG_VJ_JERK = _UxGT("Vαντίδραση ") STR_J; + LSTR MSG_VK_JERK = _UxGT("Vαντίδραση ") STR_K; LSTR MSG_VE_JERK = _UxGT("Vαντίδραση E"); - LSTR MSG_VMAX_A = _UxGT("Vμεγ ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vμεγ ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vμεγ ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vμεγ ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vμεγ ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vμεγ ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vμεγ ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Vμεγ ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vμεγ ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vμεγ ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Vμεγ ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Vμεγ ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Vμεγ ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Vμεγ ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Vμεγ *"); LSTR MSG_VMIN = _UxGT("Vελαχ"); LSTR MSG_VTRAV_MIN = _UxGT("Vελάχ. μετατόπιση"); LSTR MSG_ACCELERATION = _UxGT("Accel"); - LSTR MSG_AMAX_A = _UxGT("Aμεγ ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Aμεγ ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Aμεγ ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Aμεγ ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Aμεγ ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Aμεγ ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Aμεγ ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Aμεγ ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Aμεγ ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Aμεγ ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Aμεγ ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Aμεγ ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Aμεγ ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Aμεγ ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Aμεγ *"); LSTR MSG_A_RETRACT = _UxGT("Α-ανάσυρση"); LSTR MSG_A_TRAVEL = _UxGT("Α-μετατόπιση"); LSTR MSG_STEPS_PER_MM = _UxGT("Bήματα ανά μμ"); - LSTR MSG_A_STEPS = _UxGT("Bήματα ") LCD_STR_A _UxGT(" ανά μμ"); - LSTR MSG_B_STEPS = _UxGT("Bήματα ") LCD_STR_B _UxGT(" ανά μμ"); - LSTR MSG_C_STEPS = _UxGT("Bήματα ") LCD_STR_C _UxGT(" ανά μμ"); - LSTR MSG_I_STEPS = _UxGT("Bήματα ") LCD_STR_I _UxGT(" ανά μμ"); - LSTR MSG_J_STEPS = _UxGT("Bήματα ") LCD_STR_J _UxGT(" ανά μμ"); - LSTR MSG_K_STEPS = _UxGT("Bήματα ") LCD_STR_K _UxGT(" ανά μμ"); + LSTR MSG_A_STEPS = _UxGT("Bήματα ") STR_A _UxGT(" ανά μμ"); + LSTR MSG_B_STEPS = _UxGT("Bήματα ") STR_B _UxGT(" ανά μμ"); + LSTR MSG_C_STEPS = _UxGT("Bήματα ") STR_C _UxGT(" ανά μμ"); + LSTR MSG_I_STEPS = _UxGT("Bήματα ") STR_I _UxGT(" ανά μμ"); + LSTR MSG_J_STEPS = _UxGT("Bήματα ") STR_J _UxGT(" ανά μμ"); + LSTR MSG_K_STEPS = _UxGT("Bήματα ") STR_K _UxGT(" ανά μμ"); LSTR MSG_E_STEPS = _UxGT("Bήματα Ε ανά μμ"); LSTR MSG_EN_STEPS = _UxGT("Bήματα * ανά μμ"); LSTR MSG_TEMPERATURE = _UxGT("Θερμοκρασία"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index ecd5ef56601a..43bbd90210fd 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -57,8 +57,8 @@ namespace Language_en { LSTR MSG_MEDIA_ABORTING = _UxGT("Aborting..."); LSTR MSG_MEDIA_INSERTED = MEDIA_TYPE_EN _UxGT(" Inserted"); LSTR MSG_MEDIA_REMOVED = MEDIA_TYPE_EN _UxGT(" Removed"); - LSTR MSG_MEDIA_WAITING = _UxGT("Waiting for card"); - LSTR MSG_SD_INIT_FAIL = _UxGT("SD Init Fail"); + LSTR MSG_MEDIA_WAITING = _UxGT("Waiting for ") MEDIA_TYPE_EN; + LSTR MSG_MEDIA_INIT_FAIL = MEDIA_TYPE_EN _UxGT(" Init Fail"); LSTR MSG_MEDIA_READ_ERROR = MEDIA_TYPE_EN _UxGT(" read error"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB device removed"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("USB start failed"); @@ -75,6 +75,9 @@ namespace Language_en { LSTR MSG_HOMING = _UxGT("Homing"); LSTR MSG_AUTO_HOME = _UxGT("Auto Home"); LSTR MSG_AUTO_HOME_A = _UxGT("Home @"); + LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); + LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); + LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); LSTR MSG_FILAMENT_SET = _UxGT("Filament Settings"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); LSTR MSG_LEVBED_FL = _UxGT("Front Left"); @@ -83,6 +86,7 @@ namespace Language_en { LSTR MSG_LEVBED_BL = _UxGT("Back Left"); LSTR MSG_LEVBED_BR = _UxGT("Back Right"); LSTR MSG_MANUAL_MESH = _UxGT("Manual Mesh"); + LSTR MSG_AUTO_MESH = _UxGT("Auto Build Mesh"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-Align"); LSTR MSG_ITERATION = _UxGT("G34 Iteration: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Accuracy Decreasing!"); @@ -96,9 +100,9 @@ namespace Language_en { LSTR MSG_HOME_OFFSET_X = _UxGT("Home Offset X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Home Offset Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Home Offset Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Home Offset ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Home Offset ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Home Offset ") LCD_STR_K; + LSTR MSG_HOME_OFFSET_I = _UxGT("Home Offset ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Home Offset ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Home Offset ") STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsets Applied"); LSTR MSG_SET_ORIGIN = _UxGT("Set Origin"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Tramming Wizard"); @@ -147,15 +151,18 @@ namespace Language_en { LSTR MSG_BED_LEVELING = _UxGT("Bed Leveling"); LSTR MSG_LEVEL_BED = _UxGT("Level Bed"); LSTR MSG_BED_TRAMMING = _UxGT("Bed Tramming"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Manual Tramming"); LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Adjust bed until the probe triggers."); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Corners within tolerance. Bed trammed."); LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Good Points: "); LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Last Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Next Corner"); LSTR MSG_MESH_EDITOR = _UxGT("Mesh Editor"); + LSTR MSG_MESH_VIEWER = _UxGT("Mesh Viewer"); LSTR MSG_EDIT_MESH = _UxGT("Edit Mesh"); LSTR MSG_MESH_VIEW = _UxGT("View Mesh"); LSTR MSG_EDITING_STOPPED = _UxGT("Mesh Editing Stopped"); + LSTR MSG_NO_VALID_MESH = _UxGT("No valid mesh"); LSTR MSG_PROBING_POINT = _UxGT("Probing Point"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); @@ -278,9 +285,9 @@ namespace Language_en { LSTR MSG_MOVE_X = _UxGT("Move X"); // Used by draw_edit_screen LSTR MSG_MOVE_Y = _UxGT("Move Y"); LSTR MSG_MOVE_Z = _UxGT("Move Z"); - LSTR MSG_MOVE_I = _UxGT("Move ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Move ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Move ") LCD_STR_K; + LSTR MSG_MOVE_I = _UxGT("Move ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Move ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Move ") STR_K; LSTR MSG_MOVE_E = _UxGT("Move Extruder"); LSTR MSG_MOVE_EN = _UxGT("Move E*"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend too cold"); @@ -295,10 +302,10 @@ namespace Language_en { LSTR MSG_MOVE_1IN = _UxGT("Move 1.0in"); LSTR MSG_SPEED = _UxGT("Speed"); LSTR MSG_MAXSPEED = _UxGT("Max Speed (mm/s)"); - LSTR MSG_MAXSPEED_X = _UxGT("Max ") LCD_STR_A _UxGT(" Speed"); - LSTR MSG_MAXSPEED_Y = _UxGT("Max ") LCD_STR_B _UxGT(" Speed"); - LSTR MSG_MAXSPEED_Z = _UxGT("Max ") LCD_STR_C _UxGT(" Speed"); - LSTR MSG_MAXSPEED_E = _UxGT("Max ") LCD_STR_E _UxGT(" Speed"); + LSTR MSG_MAXSPEED_X = _UxGT("Max ") STR_A _UxGT(" Speed"); + LSTR MSG_MAXSPEED_Y = _UxGT("Max ") STR_B _UxGT(" Speed"); + LSTR MSG_MAXSPEED_Z = _UxGT("Max ") STR_C _UxGT(" Speed"); + LSTR MSG_MAXSPEED_E = _UxGT("Max ") STR_E _UxGT(" Speed"); LSTR MSG_MAXSPEED_A = _UxGT("Max @ Speed"); LSTR MSG_BED_Z = _UxGT("Bed Z"); LSTR MSG_NOZZLE = _UxGT("Nozzle"); @@ -341,45 +348,45 @@ namespace Language_en { LSTR MSG_SELECT_E = _UxGT("Select *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + LSTR MSG_VB_JERK = _UxGT("Max ") STR_B _UxGT(" Jerk"); + LSTR MSG_VC_JERK = _UxGT("Max ") STR_C _UxGT(" Jerk"); + LSTR MSG_VI_JERK = _UxGT("Max ") STR_I _UxGT(" Jerk"); + LSTR MSG_VJ_JERK = _UxGT("Max ") STR_J _UxGT(" Jerk"); + LSTR MSG_VK_JERK = _UxGT("Max ") STR_K _UxGT(" Jerk"); LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); LSTR MSG_VELOCITY = _UxGT("Velocity"); - LSTR MSG_VMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Vel"); - LSTR MSG_VMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Vel"); - LSTR MSG_VMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Vel"); - LSTR MSG_VMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Vel"); - LSTR MSG_VMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Vel"); - LSTR MSG_VMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Vel"); - LSTR MSG_VMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Vel"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Vel"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Vel"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Vel"); + LSTR MSG_VMAX_I = _UxGT("Max ") STR_I _UxGT(" Vel"); + LSTR MSG_VMAX_J = _UxGT("Max ") STR_J _UxGT(" Vel"); + LSTR MSG_VMAX_K = _UxGT("Max ") STR_K _UxGT(" Vel"); + LSTR MSG_VMAX_E = _UxGT("Max ") STR_E _UxGT(" Vel"); LSTR MSG_VMAX_EN = _UxGT("Max * Vel"); LSTR MSG_VMIN = _UxGT("Min Velocity"); LSTR MSG_VTRAV_MIN = _UxGT("Min Travel Vel"); LSTR MSG_ACCELERATION = _UxGT("Acceleration"); - LSTR MSG_AMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Accel"); - LSTR MSG_AMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Accel"); - LSTR MSG_AMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Accel"); - LSTR MSG_AMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Accel"); - LSTR MSG_AMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Accel"); - LSTR MSG_AMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Accel"); - LSTR MSG_AMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Accel"); + LSTR MSG_AMAX_A = _UxGT("Max ") STR_A _UxGT(" Accel"); + LSTR MSG_AMAX_B = _UxGT("Max ") STR_B _UxGT(" Accel"); + LSTR MSG_AMAX_C = _UxGT("Max ") STR_C _UxGT(" Accel"); + LSTR MSG_AMAX_I = _UxGT("Max ") STR_I _UxGT(" Accel"); + LSTR MSG_AMAX_J = _UxGT("Max ") STR_J _UxGT(" Accel"); + LSTR MSG_AMAX_K = _UxGT("Max ") STR_K _UxGT(" Accel"); + LSTR MSG_AMAX_E = _UxGT("Max ") STR_E _UxGT(" Accel"); LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); LSTR MSG_A_RETRACT = _UxGT("Retract Accel"); LSTR MSG_A_TRAVEL = _UxGT("Travel Accel"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("XY Freq Limit"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min FR Factor"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" Steps/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" Steps/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" Steps/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" Steps/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" Steps/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" Steps/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" Steps/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" Steps/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" Steps/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" Steps/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" Steps/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" Steps/mm"); LSTR MSG_E_STEPS = _UxGT("E steps/mm"); LSTR MSG_EN_STEPS = _UxGT("* Steps/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperature"); @@ -396,6 +403,8 @@ namespace Language_en { LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness"); + LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD Timeout (s)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Backlight Off"); LSTR MSG_STORE_EEPROM = _UxGT("Store Settings"); LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults"); @@ -422,12 +431,21 @@ namespace Language_en { LSTR MSG_BUTTON_RESET = _UxGT("Reset"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ignore"); LSTR MSG_BUTTON_CANCEL = _UxGT("Cancel"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Confirm"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Continue"); LSTR MSG_BUTTON_DONE = _UxGT("Done"); LSTR MSG_BUTTON_BACK = _UxGT("Back"); LSTR MSG_BUTTON_PROCEED = _UxGT("Proceed"); LSTR MSG_BUTTON_SKIP = _UxGT("Skip"); + LSTR MSG_BUTTON_INFO = _UxGT("Info"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Level"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Pause"); + LSTR MSG_BUTTON_RESUME = _UxGT("Resume"); + LSTR MSG_BUTTON_ADVANCED = _UxGT("Advanced"); + LSTR MSG_BUTTON_SAVE = _UxGT("Save"); LSTR MSG_PAUSING = _UxGT("Pausing..."); LSTR MSG_PAUSE_PRINT = _UxGT("Pause Print"); + LSTR MSG_ADVANCED_PAUSE = _UxGT("Advanced Pause"); LSTR MSG_RESUME_PRINT = _UxGT("Resume Print"); LSTR MSG_HOST_START_PRINT = _UxGT("Start Host Print"); LSTR MSG_STOP_PRINT = _UxGT("Stop Print"); @@ -436,12 +454,15 @@ namespace Language_en { LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Object"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Object ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Power Outage"); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Print Job"); LSTR MSG_MEDIA_MENU = _UxGT("Print from ") MEDIA_TYPE_EN; LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN; LSTR MSG_DWELL = _UxGT("Sleep..."); LSTR MSG_USERWAIT = _UxGT("Click to Resume..."); LSTR MSG_PRINT_PAUSED = _UxGT("Print Paused"); LSTR MSG_PRINTING = _UxGT("Printing..."); + LSTR MSG_STOPPING = _UxGT("Stopping..."); + LSTR MSG_REMAINING_TIME = _UxGT("Remaining"); LSTR MSG_PRINT_ABORTED = _UxGT("Print Aborted"); LSTR MSG_PRINT_DONE = _UxGT("Print Done"); LSTR MSG_NO_MOVE = _UxGT("No Move."); @@ -491,6 +512,7 @@ namespace Language_en { LSTR MSG_BLTOUCH_STOW = _UxGT("Stow"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Deploy"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Mode"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("High Speed"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Mode"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Mode"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); @@ -515,14 +537,15 @@ namespace Language_en { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; + LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop Abort"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Heating Failed"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: REDUNDANT TEMP"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("THERMAL RUNAWAY"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("TEMP MALFUNCTION"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("BED THERMAL RUNAWAY"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("CHAMBER T. RUNAWAY"); LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Cooler Runaway"); @@ -530,6 +553,7 @@ namespace Language_en { LSTR MSG_ERR_MAXTEMP = _UxGT("Err: MAXTEMP"); LSTR MSG_ERR_MINTEMP = _UxGT("Err: MINTEMP"); LSTR MSG_HALTED = _UxGT("PRINTER HALTED"); + LSTR MSG_PLEASE_WAIT = _UxGT("Please wait..."); LSTR MSG_PLEASE_RESET = _UxGT("Please Reset"); LSTR MSG_PREHEATING = _UxGT("Preheating..."); LSTR MSG_HEATING = _UxGT("Heating..."); @@ -570,35 +594,51 @@ namespace Language_en { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: OFF"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: ON"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); + LSTR MSG_FAN_SPEED_FAULT = _UxGT("Fan speed fault"); LSTR MSG_CASE_LIGHT = _UxGT("Case Light"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Light Brightness"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("INCORRECT PRINTER"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("No media inserted."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Please wait until reboot. "); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Please preheat the hot end."); + LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Reset Print Count"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Print Count"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completed"); - LSTR MSG_INFO_PRINT_TIME = _UxGT("Total Print Time"); + LSTR MSG_INFO_PRINT_TIME = _UxGT("Print Time"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Longest Job Time"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extruded Total"); + LSTR MSG_COLORS_GET = _UxGT("Get Color"); + LSTR MSG_COLORS_SELECT = _UxGT("Select Colors"); + LSTR MSG_COLORS_APPLIED = _UxGT("Colors applied"); + LSTR MSG_COLORS_RED = _UxGT("Red"); + LSTR MSG_COLORS_GREEN = _UxGT("Green"); + LSTR MSG_COLORS_BLUE = _UxGT("Blue"); + LSTR MSG_COLORS_WHITE = _UxGT("White"); + LSTR MSG_UI_LANGUAGE = _UxGT("UI Language"); + LSTR MSG_SOUND_ENABLE = _UxGT("Enable sound"); + LSTR MSG_LOCKSCREEN = _UxGT("Lock Screen"); #else + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("No Media"); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Please Preheat"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Prints"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completed"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Total"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Longest"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extruded"); #endif + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completed"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); LSTR MSG_INFO_PSU = _UxGT("PSU"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Drive Strength"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); LSTR MSG_ERROR_TMC = _UxGT("TMC CONNECTION ERROR"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Write"); @@ -613,6 +653,7 @@ namespace Language_en { LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout Sensor"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Runout Dist mm"); LSTR MSG_RUNOUT_ENABLE = _UxGT("Enable Runout"); + LSTR MSG_FANCHECK = _UxGT("Fan Tacho Check"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing Failed"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Probing Failed"); @@ -732,6 +773,10 @@ namespace Language_en { LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Probing Z Reference"); LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Moving to Probing Pos"); + LSTR MSG_XATC = _UxGT("X-Twist Wizard"); + LSTR MSG_XATC_DONE = _UxGT("X-Twist Wizard Done!"); + LSTR MSG_XATC_UPDATE_Z_OFFSET = _UxGT("Update Probe Z-Offset to "); + LSTR MSG_SOUND = _UxGT("Sound"); LSTR MSG_TOP_LEFT = _UxGT("Top Left"); @@ -763,12 +808,12 @@ namespace Language_en { LSTR MSG_PID_C_E = _UxGT("PID-C *"); LSTR MSG_PID_F = _UxGT("PID-F"); LSTR MSG_PID_F_E = _UxGT("PID-F *"); - LSTR MSG_BACKLASH_A = LCD_STR_A; - LSTR MSG_BACKLASH_B = LCD_STR_B; - LSTR MSG_BACKLASH_C = LCD_STR_C; - LSTR MSG_BACKLASH_I = LCD_STR_I; - LSTR MSG_BACKLASH_J = LCD_STR_J; - LSTR MSG_BACKLASH_K = LCD_STR_K; + LSTR MSG_BACKLASH_A = STR_A; + LSTR MSG_BACKLASH_B = STR_B; + LSTR MSG_BACKLASH_C = STR_C; + LSTR MSG_BACKLASH_I = STR_I; + LSTR MSG_BACKLASH_J = STR_J; + LSTR MSG_BACKLASH_K = STR_K; } #if FAN_COUNT == 1 diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 38f21985ecc8..6e2c82533e6f 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -39,11 +39,11 @@ namespace Language_es { LSTR MSG_NO = _UxGT("NO"); LSTR MSG_BACK = _UxGT("Atrás"); LSTR MSG_MEDIA_ABORTING = _UxGT("Cancelando..."); - LSTR MSG_MEDIA_INSERTED = _UxGT("SD/USB insertado"); - LSTR MSG_MEDIA_REMOVED = _UxGT("SD/USB retirado"); - LSTR MSG_MEDIA_WAITING = _UxGT("Esperando al SD/USB"); - LSTR MSG_SD_INIT_FAIL = _UxGT("Fallo al iniciar SD"); - LSTR MSG_MEDIA_READ_ERROR = _UxGT("Error lectura SD/USB"); + LSTR MSG_MEDIA_INSERTED = _UxGT("SD/FD insertado"); + LSTR MSG_MEDIA_REMOVED = _UxGT("SD/FD retirado"); + LSTR MSG_MEDIA_WAITING = _UxGT("Esperando al SD/FD"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Fallo al iniciar SD/FD"); + LSTR MSG_MEDIA_READ_ERROR = _UxGT("Error lectura SD/FD"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("Disp. USB retirado"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Inicio USB fallido"); LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Desbordamiento de subllamada"); @@ -268,43 +268,43 @@ namespace Language_es { LSTR MSG_SELECT_E = _UxGT("Seleccionar *"); LSTR MSG_ACC = _UxGT("Aceleración"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + LSTR MSG_VB_JERK = _UxGT("Max ") STR_B _UxGT(" Jerk"); + LSTR MSG_VC_JERK = _UxGT("Max ") STR_C _UxGT(" Jerk"); + LSTR MSG_VI_JERK = _UxGT("Max ") STR_I _UxGT(" Jerk"); + LSTR MSG_VJ_JERK = _UxGT("Max ") STR_J _UxGT(" Jerk"); + LSTR MSG_VK_JERK = _UxGT("Max ") STR_K _UxGT(" Jerk"); LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Desvi. Unión"); LSTR MSG_VELOCITY = _UxGT("Velocidad"); - LSTR MSG_VMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Vel"); - LSTR MSG_VMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Vel"); - LSTR MSG_VMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Vel"); - LSTR MSG_VMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Vel"); - LSTR MSG_VMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Vel"); - LSTR MSG_VMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Vel"); - LSTR MSG_VMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Vel"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Vel"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Vel"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Vel"); + LSTR MSG_VMAX_I = _UxGT("Max ") STR_I _UxGT(" Vel"); + LSTR MSG_VMAX_J = _UxGT("Max ") STR_J _UxGT(" Vel"); + LSTR MSG_VMAX_K = _UxGT("Max ") STR_K _UxGT(" Vel"); + LSTR MSG_VMAX_E = _UxGT("Max ") STR_E _UxGT(" Vel"); LSTR MSG_VMAX_EN = _UxGT("Max * Vel"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("Vel. viaje min"); LSTR MSG_ACCELERATION = _UxGT("Acceleración"); - LSTR MSG_AMAX_A = _UxGT("Acel. max") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Acel. max") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Acel. max") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Acel. max") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Acel. max") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Acel. max") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Acel. max") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Acel. max") STR_A; + LSTR MSG_AMAX_B = _UxGT("Acel. max") STR_B; + LSTR MSG_AMAX_C = _UxGT("Acel. max") STR_C; + LSTR MSG_AMAX_I = _UxGT("Acel. max") STR_I; + LSTR MSG_AMAX_J = _UxGT("Acel. max") STR_J; + LSTR MSG_AMAX_K = _UxGT("Acel. max") STR_K; + LSTR MSG_AMAX_E = _UxGT("Acel. max") STR_E; LSTR MSG_AMAX_EN = _UxGT("Acel. max *"); LSTR MSG_A_RETRACT = _UxGT("Acel. retrac."); LSTR MSG_A_TRAVEL = _UxGT("Acel. Viaje"); LSTR MSG_STEPS_PER_MM = _UxGT("Pasos/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" pasos/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" pasos/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" pasos/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" pasos/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" pasos/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" pasos/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" pasos/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" pasos/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" pasos/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" pasos/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" pasos/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" pasos/mm"); LSTR MSG_E_STEPS = _UxGT("E pasos/mm"); LSTR MSG_EN_STEPS = _UxGT("* pasos/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -325,7 +325,7 @@ namespace Language_es { LSTR MSG_ERR_EEPROM_CRC = _UxGT("Err: EEPROM CRC"); LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Err: Índice EEPROM"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Err: Versión EEPROM"); - LSTR MSG_MEDIA_UPDATE = _UxGT("Actualizar SD/USB"); + LSTR MSG_MEDIA_UPDATE = _UxGT("Actualizar SD/FD"); LSTR MSG_RESET_PRINTER = _UxGT("Resetear Impresora"); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Recargar"); LSTR MSG_INFO_SCREEN = _UxGT("Pantalla de Inf."); @@ -348,8 +348,8 @@ namespace Language_es { LSTR MSG_CANCEL_OBJECT = _UxGT("Cancelar Objeto"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancelar Objeto ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Rec. Fallo electrico"); - LSTR MSG_MEDIA_MENU = _UxGT("Imprim. desde SD/USB"); - LSTR MSG_NO_MEDIA = _UxGT("SD/USB no presente"); + LSTR MSG_MEDIA_MENU = _UxGT("Imprim. desde SD/FD"); + LSTR MSG_NO_MEDIA = _UxGT("SD/FD no presente"); LSTR MSG_DWELL = _UxGT("Reposo..."); LSTR MSG_USERWAIT = _UxGT("Pulsar para Reanudar"); LSTR MSG_PRINT_PAUSED = _UxGT("Impresión Pausada"); @@ -381,9 +381,9 @@ namespace Language_es { LSTR MSG_FILAMENTUNLOAD = _UxGT("Descargar filamento"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Descargar fil. *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Descargar todo"); - LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar SD/USB"); - LSTR MSG_CHANGE_MEDIA = _UxGT("Cambiar SD/USB"); - LSTR MSG_RELEASE_MEDIA = _UxGT("Lanzar SD/USB"); + LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar SD/FD"); + LSTR MSG_CHANGE_MEDIA = _UxGT("Cambiar SD/FD"); + LSTR MSG_RELEASE_MEDIA = _UxGT("Lanzar SD/FD"); LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z fuera cama"); LSTR MSG_SKEW_FACTOR = _UxGT("Factor de desviación"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); @@ -463,7 +463,7 @@ namespace Language_es { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Brillo cabina"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Impresora incorrecta"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Cont. de impresión"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completadas"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tiempo total de imp."); @@ -481,12 +481,12 @@ namespace Language_es { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp. Máxima"); LSTR MSG_INFO_PSU = _UxGT("F. Aliment."); LSTR MSG_DRIVE_STRENGTH = _UxGT("Fuerza de empuje"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); LSTR MSG_ERROR_TMC = _UxGT("ERROR CONEX. TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Escribe DAC EEPROM"); diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index adc812f6ffee..5742fa8f6f97 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -164,23 +164,23 @@ namespace Language_eu { LSTR MSG_SELECT_E = _UxGT("Aukeratu *"); LSTR MSG_ACC = _UxGT("Azelerazioa"); LSTR MSG_JERK = _UxGT("Astindua"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-astindua"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-astindua"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-astindua"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-astindua"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-astindua"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-astindua"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-astindua"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-astindua"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-astindua"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT("-astindua"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT("-astindua"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT("-astindua"); LSTR MSG_VE_JERK = _UxGT("Ve-astindua"); LSTR MSG_VTRAV_MIN = _UxGT("VBidaia min"); LSTR MSG_A_RETRACT = _UxGT("A-retrakt"); LSTR MSG_A_TRAVEL = _UxGT("A-bidaia"); LSTR MSG_STEPS_PER_MM = _UxGT("Pausoak/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" pausoak/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" pausoak/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" pausoak/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" pausoak/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" pausoak/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" pausoak/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" pausoak/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" pausoak/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" pausoak/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" pausoak/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" pausoak/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" pausoak/mm"); LSTR MSG_E_STEPS = _UxGT("E pausoak/mm"); LSTR MSG_EN_STEPS = _UxGT("* pausoak/mm"); LSTR MSG_TEMPERATURE = _UxGT("Tenperatura"); @@ -280,7 +280,7 @@ namespace Language_eu { LSTR MSG_INFO_PROTOCOL = _UxGT("Protokoloa"); LSTR MSG_CASE_LIGHT = _UxGT("Kabina Argia"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Argiaren Distira"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Inprim. Zenbaketa"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Burututa"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Inprim. denbora"); @@ -297,12 +297,12 @@ namespace Language_eu { LSTR MSG_INFO_MAX_TEMP = _UxGT("Tenp. Maximoa"); LSTR MSG_INFO_PSU = _UxGT("Elikadura-iturria"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Driver-aren potentzia"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Idatzi DAC EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("HARIZPIA ALDATU"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index e9c55ed4018d..ca3757f704d6 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -58,12 +58,10 @@ namespace Language_fr { LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barre progress."); LSTR MSG_HOMING = _UxGT("Origine"); LSTR MSG_AUTO_HOME = _UxGT("Origine auto"); + LSTR MSG_AUTO_HOME_A = _UxGT("Origine @ auto"); LSTR MSG_AUTO_HOME_X = _UxGT("Origine X auto"); LSTR MSG_AUTO_HOME_Y = _UxGT("Origine Y auto"); LSTR MSG_AUTO_HOME_Z = _UxGT("Origine Z auto"); - LSTR MSG_AUTO_HOME_I = _UxGT("Origine ") LCD_STR_I _UxGT(" auto"); - LSTR MSG_AUTO_HOME_J = _UxGT("Origine ") LCD_STR_J _UxGT(" auto"); - LSTR MSG_AUTO_HOME_K = _UxGT("Origine ") LCD_STR_K _UxGT(" auto"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Align. Z auto"); LSTR MSG_LEVEL_BED_HOMING = _UxGT("Origine XYZ..."); LSTR MSG_LEVEL_BED_WAITING = _UxGT("Clic pour commencer"); @@ -74,9 +72,9 @@ namespace Language_fr { LSTR MSG_HOME_OFFSET_X = _UxGT("Décal. origine X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Décal. origine Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Décal. origine Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Décal. origine ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Décal. origine ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Décal. origine ") LCD_STR_K; + LSTR MSG_HOME_OFFSET_I = _UxGT("Décal. origine ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Décal. origine ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Décal. origine ") STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Décalages appliqués"); LSTR MSG_SET_ORIGIN = _UxGT("Régler origine"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Assistant Molettes"); @@ -113,7 +111,7 @@ namespace Language_fr { LSTR MSG_LEVEL_BED = _UxGT("Niveau du lit"); LSTR MSG_BED_TRAMMING = _UxGT("Niveau des coins"); LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Relever le coin jusqu'à la sonde"); - LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Coins dans la tolérance. Niveau lit "); + LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Coins dans la tolérance. Niveau lit."); LSTR MSG_NEXT_CORNER = _UxGT("Coin suivant"); LSTR MSG_MESH_EDITOR = _UxGT("Modif. maille"); // 13 car. max LSTR MSG_EDIT_MESH = _UxGT("Modifier grille"); @@ -236,9 +234,9 @@ namespace Language_fr { LSTR MSG_MOVE_X = _UxGT("Déplacer X"); LSTR MSG_MOVE_Y = _UxGT("Déplacer Y"); LSTR MSG_MOVE_Z = _UxGT("Déplacer Z"); - LSTR MSG_MOVE_I = _UxGT("Déplacer ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Déplacer ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Déplacer ") LCD_STR_K; + LSTR MSG_MOVE_I = _UxGT("Déplacer ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Déplacer ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Déplacer ") STR_K; LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Buse trop froide"); @@ -282,45 +280,45 @@ namespace Language_fr { LSTR MSG_SELECT_E = _UxGT("Sélectionner *"); LSTR MSG_ACC = _UxGT("Accélération"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT(" jerk"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT(" jerk"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT(" jerk"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT(" jerk"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT(" jerk"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT(" jerk"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT(" jerk"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT(" jerk"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT(" jerk"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT(" jerk"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT(" jerk"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT(" jerk"); LSTR MSG_VE_JERK = _UxGT("Ve jerk"); LSTR MSG_VELOCITY = _UxGT("Vélocité"); - LSTR MSG_VMAX_A = _UxGT("Vit. Max ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vit. Max ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vit. Max ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vit. Max ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vit. Max ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vit. Max ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vit. Max ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Vit. Max ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vit. Max ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vit. Max ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Vit. Max ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Vit. Max ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Vit. Max ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Vit. Max ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Vit. Max *"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Déviat. jonct."); LSTR MSG_VMIN = _UxGT("Vit. Min"); LSTR MSG_VTRAV_MIN = _UxGT("Vmin course"); LSTR MSG_ACCELERATION = _UxGT("Accélération"); - LSTR MSG_AMAX_A = _UxGT("Max Accél. ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Max Accél. ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Max Accél. ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Max Accél. ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Max Accél. ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Max Accél. ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Max Accél. ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Max Accél. ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Max Accél. ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Max Accél. ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Max Accél. ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Max Accél. ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Max Accél. ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Max Accél. ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Max Accél. *"); LSTR MSG_A_RETRACT = _UxGT("Acc.rétraction"); LSTR MSG_A_TRAVEL = _UxGT("Acc.course"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Fréquence max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Vitesse min"); LSTR MSG_STEPS_PER_MM = _UxGT("Pas/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" pas/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" pas/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" pas/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" pas/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" pas/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" pas/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" pas/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" pas/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" pas/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" pas/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" pas/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" pas/mm"); LSTR MSG_E_STEPS = _UxGT("E pas/mm"); LSTR MSG_EN_STEPS = _UxGT("* pas/mm"); LSTR MSG_TEMPERATURE = _UxGT("Température"); @@ -337,6 +335,8 @@ namespace Language_fr { LSTR MSG_ADVANCE_K_E = _UxGT("Avance K *"); LSTR MSG_BRIGHTNESS = _UxGT("Luminosité LCD"); LSTR MSG_CONTRAST = _UxGT("Contraste LCD"); + LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("Veille LCD (s)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Éteindre l'écran LCD"); LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config."); LSTR MSG_LOAD_EEPROM = _UxGT("Charger config."); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restaurer défauts"); @@ -444,9 +444,9 @@ namespace Language_fr { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; + LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Butée abandon"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Err de chauffe"); @@ -504,7 +504,7 @@ namespace Language_fr { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Luminosité"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Imprimante incorrecte"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Nbre impressions"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Terminées"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tps impr. total"); @@ -522,12 +522,12 @@ namespace Language_fr { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp Max"); LSTR MSG_INFO_PSU = _UxGT("Alim."); LSTR MSG_DRIVE_STRENGTH = _UxGT("Puiss. moteur "); - LSTR MSG_DAC_PERCENT_A = _UxGT("Driver ") LCD_STR_A _UxGT(" %"); - LSTR MSG_DAC_PERCENT_B = _UxGT("Driver ") LCD_STR_B _UxGT(" %"); - LSTR MSG_DAC_PERCENT_C = _UxGT("Driver ") LCD_STR_C _UxGT(" %"); - LSTR MSG_DAC_PERCENT_I = _UxGT("Driver ") LCD_STR_I _UxGT(" %"); - LSTR MSG_DAC_PERCENT_J = _UxGT("Driver ") LCD_STR_J _UxGT(" %"); - LSTR MSG_DAC_PERCENT_K = _UxGT("Driver ") LCD_STR_K _UxGT(" %"); + LSTR MSG_DAC_PERCENT_A = _UxGT("Driver ") STR_A _UxGT(" %"); + LSTR MSG_DAC_PERCENT_B = _UxGT("Driver ") STR_B _UxGT(" %"); + LSTR MSG_DAC_PERCENT_C = _UxGT("Driver ") STR_C _UxGT(" %"); + LSTR MSG_DAC_PERCENT_I = _UxGT("Driver ") STR_I _UxGT(" %"); + LSTR MSG_DAC_PERCENT_J = _UxGT("Driver ") STR_J _UxGT(" %"); + LSTR MSG_DAC_PERCENT_K = _UxGT("Driver ") STR_K _UxGT(" %"); LSTR MSG_DAC_PERCENT_E = _UxGT("Driver E %"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM sauv."); LSTR MSG_ERROR_TMC = _UxGT("ERREUR CONNEXION TMC"); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index c17faa701460..731f89cad4dd 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -43,8 +43,8 @@ namespace Language_gl { LSTR MSG_MEDIA_ABORTING = _UxGT("Cancelando..."); LSTR MSG_MEDIA_INSERTED = _UxGT("Tarxeta inserida"); LSTR MSG_MEDIA_REMOVED = _UxGT("Tarxeta retirada"); - LSTR MSG_MEDIA_WAITING = _UxGT("Agardando ao SD/USB"); - LSTR MSG_MEDIA_READ_ERROR = _UxGT("Erro lectura SD/USB"); + LSTR MSG_MEDIA_WAITING = _UxGT("Agardando ao SD/FD"); + LSTR MSG_MEDIA_READ_ERROR = _UxGT("Erro lectura SD/FD"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("Disp. USB retirado"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Inicio USB fallido"); LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Desbord. Subch."); @@ -269,45 +269,45 @@ namespace Language_gl { LSTR MSG_SELECT_E = _UxGT("Escolla *"); LSTR MSG_ACC = _UxGT("Acel"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + LSTR MSG_VB_JERK = _UxGT("Max ") STR_B _UxGT(" Jerk"); + LSTR MSG_VC_JERK = _UxGT("Max ") STR_C _UxGT(" Jerk"); + LSTR MSG_VI_JERK = _UxGT("Max ") STR_I _UxGT(" Jerk"); + LSTR MSG_VJ_JERK = _UxGT("Max ") STR_J _UxGT(" Jerk"); + LSTR MSG_VK_JERK = _UxGT("Max ") STR_K _UxGT(" Jerk"); LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Desvío Unión"); LSTR MSG_VELOCITY = _UxGT("Velocidade"); - LSTR MSG_VMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Vel"); - LSTR MSG_VMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Vel"); - LSTR MSG_VMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Vel"); - LSTR MSG_VMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Vel"); - LSTR MSG_VMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Vel"); - LSTR MSG_VMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Vel"); - LSTR MSG_VMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Vel"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Vel"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Vel"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Vel"); + LSTR MSG_VMAX_I = _UxGT("Max ") STR_I _UxGT(" Vel"); + LSTR MSG_VMAX_J = _UxGT("Max ") STR_J _UxGT(" Vel"); + LSTR MSG_VMAX_K = _UxGT("Max ") STR_K _UxGT(" Vel"); + LSTR MSG_VMAX_E = _UxGT("Max ") STR_E _UxGT(" Vel"); LSTR MSG_VMAX_EN = _UxGT("Max * Vel"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("V-viaxe min"); LSTR MSG_ACCELERATION = _UxGT("Aceleración"); - LSTR MSG_AMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Accel"); - LSTR MSG_AMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Accel"); - LSTR MSG_AMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Accel"); - LSTR MSG_AMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Accel"); - LSTR MSG_AMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Accel"); - LSTR MSG_AMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Accel"); - LSTR MSG_AMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Accel"); + LSTR MSG_AMAX_A = _UxGT("Max ") STR_A _UxGT(" Accel"); + LSTR MSG_AMAX_B = _UxGT("Max ") STR_B _UxGT(" Accel"); + LSTR MSG_AMAX_C = _UxGT("Max ") STR_C _UxGT(" Accel"); + LSTR MSG_AMAX_I = _UxGT("Max ") STR_I _UxGT(" Accel"); + LSTR MSG_AMAX_J = _UxGT("Max ") STR_J _UxGT(" Accel"); + LSTR MSG_AMAX_K = _UxGT("Max ") STR_K _UxGT(" Accel"); + LSTR MSG_AMAX_E = _UxGT("Max ") STR_E _UxGT(" Accel"); LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); LSTR MSG_A_RETRACT = _UxGT("A-retrac."); LSTR MSG_A_TRAVEL = _UxGT("A-viaxe"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frecuencia max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Avance min"); LSTR MSG_STEPS_PER_MM = _UxGT("Pasos/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" pasos/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" pasos/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" pasos/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" pasos/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" pasos/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" pasos/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" pasos/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" pasos/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" pasos/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" pasos/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" pasos/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" pasos/mm"); LSTR MSG_E_STEPS = _UxGT("E pasos/mm"); LSTR MSG_EN_STEPS = _UxGT("* pasos/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -329,7 +329,7 @@ namespace Language_gl { LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Erro: Índice EEPROM"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Erro: Versión EEPROM"); LSTR MSG_SETTINGS_STORED = _UxGT("Config Gardada"); - LSTR MSG_MEDIA_UPDATE = _UxGT("Actualizar SD/USB"); + LSTR MSG_MEDIA_UPDATE = _UxGT("Actualizar SD/FD"); LSTR MSG_RESET_PRINTER = _UxGT("Reiniciar Impresora"); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Recargar"); LSTR MSG_INFO_SCREEN = _UxGT("Información"); @@ -397,9 +397,9 @@ namespace Language_gl { LSTR MSG_FILAMENTUNLOAD = _UxGT("Descargar Filamento"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Descargar Filamento *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Descargar Todo"); - LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar SD/USB"); - LSTR MSG_CHANGE_MEDIA = _UxGT("Cambiar SD/USB"); - LSTR MSG_RELEASE_MEDIA = _UxGT("Lanzar SD/USB"); + LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar SD/FD"); + LSTR MSG_CHANGE_MEDIA = _UxGT("Cambiar SD/FD"); + LSTR MSG_RELEASE_MEDIA = _UxGT("Lanzar SD/FD"); LSTR MSG_ZPROBE_OUT = _UxGT("Sonda-Z fóra Cama"); LSTR MSG_SKEW_FACTOR = _UxGT("Factor de Desviación"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); @@ -479,7 +479,7 @@ namespace Language_gl { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Brillo Luces"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("IMPRESORA INCORRECTA"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Total Impresións"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completadas"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tempo Total Imp."); @@ -497,12 +497,12 @@ namespace Language_gl { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp Máx"); LSTR MSG_INFO_PSU = _UxGT("Fonte Alimentación"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Forza do Motor"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); LSTR MSG_ERROR_TMC = _UxGT("ERRO CONEX. TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Escribe DAC EEPROM"); diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index 23be8abbb185..78db2ad66029 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -137,7 +137,7 @@ namespace Language_hr { LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Neispravan pisač"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Broj printova"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Završeni"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Ukupno printanja"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index faa313e48af3..341d1b467ddb 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -47,7 +47,7 @@ namespace Language_hu { LSTR MSG_MEDIA_INSERTED = _UxGT("Tároló behelyezve"); LSTR MSG_MEDIA_REMOVED = _UxGT("Tároló eltávolítva"); LSTR MSG_MEDIA_WAITING = _UxGT("Várakozás a tárolóra"); - LSTR MSG_SD_INIT_FAIL = _UxGT("SD-kártya hiba"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Tároló-kártya hiba"); LSTR MSG_MEDIA_READ_ERROR = _UxGT("Tároló olvasási hiba"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB eltávolítva"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("USB eszköz hiba"); @@ -62,12 +62,10 @@ namespace Language_hu { LSTR MSG_DEBUG_MENU = _UxGT("Hiba Menü"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Haladás sáv teszt"); LSTR MSG_AUTO_HOME = _UxGT("X-Y-Z auto kezdöpont"); + LSTR MSG_AUTO_HOME_A = _UxGT("Kezdö @"); LSTR MSG_AUTO_HOME_X = _UxGT("X kezdöpont"); LSTR MSG_AUTO_HOME_Y = _UxGT("Y kezdöpont"); LSTR MSG_AUTO_HOME_Z = _UxGT("Z kezdöpont"); - LSTR MSG_AUTO_HOME_I = _UxGT("Kezdö ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Kezdö ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Kezdö ") LCD_STR_K; LSTR MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-igazítás"); LSTR MSG_ITERATION = _UxGT("G34 Ismétlés: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Pontosság csökken!"); @@ -81,9 +79,9 @@ namespace Language_hu { LSTR MSG_HOME_OFFSET_X = _UxGT("X Kezdö eltol."); LSTR MSG_HOME_OFFSET_Y = _UxGT("Y Kezdö eltol."); LSTR MSG_HOME_OFFSET_Z = _UxGT("Z Kezdö eltol."); - LSTR MSG_HOME_OFFSET_I = _UxGT("Kezdö eltol. ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Kezdö eltol. ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Kezdö eltol. ") LCD_STR_K; + LSTR MSG_HOME_OFFSET_I = _UxGT("Kezdö eltol. ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Kezdö eltol. ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Kezdö eltol. ") STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Eltolás beállítva."); LSTR MSG_SET_ORIGIN = _UxGT("Eredeti Be"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Elektromos varázsló"); @@ -262,9 +260,9 @@ namespace Language_hu { LSTR MSG_MOVE_X = _UxGT("X mozgás"); LSTR MSG_MOVE_Y = _UxGT("Y mozgás"); LSTR MSG_MOVE_Z = _UxGT("Z mozgás"); - LSTR MSG_MOVE_I = _UxGT("Mozgás ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Mozgás ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Mozgás ") LCD_STR_K; + LSTR MSG_MOVE_I = _UxGT("Mozgás ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Mozgás ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Mozgás ") STR_K; LSTR MSG_MOVE_E = _UxGT("Adagoló"); LSTR MSG_MOVE_EN = _UxGT("Adagoló *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("A fej túl hideg"); @@ -319,45 +317,45 @@ namespace Language_hu { LSTR MSG_SELECT_E = _UxGT("Kiválaszt *"); LSTR MSG_ACC = _UxGT("Gyorsítás"); LSTR MSG_JERK = _UxGT("Rántás"); - LSTR MSG_VA_JERK = _UxGT("Seb.") LCD_STR_A _UxGT("-Rántás"); - LSTR MSG_VB_JERK = _UxGT("Seb.") LCD_STR_B _UxGT("-Rántás"); - LSTR MSG_VC_JERK = _UxGT("Seb.") LCD_STR_C _UxGT("-Rántás"); - LSTR MSG_VI_JERK = _UxGT("Seb.") LCD_STR_I _UxGT("-Rántás"); - LSTR MSG_VJ_JERK = _UxGT("Seb.") LCD_STR_J _UxGT("-Rántás"); - LSTR MSG_VK_JERK = _UxGT("Seb.") LCD_STR_K _UxGT("-Rántás"); + LSTR MSG_VA_JERK = _UxGT("Seb.") STR_A _UxGT("-Rántás"); + LSTR MSG_VB_JERK = _UxGT("Seb.") STR_B _UxGT("-Rántás"); + LSTR MSG_VC_JERK = _UxGT("Seb.") STR_C _UxGT("-Rántás"); + LSTR MSG_VI_JERK = _UxGT("Seb.") STR_I _UxGT("-Rántás"); + LSTR MSG_VJ_JERK = _UxGT("Seb.") STR_J _UxGT("-Rántás"); + LSTR MSG_VK_JERK = _UxGT("Seb.") STR_K _UxGT("-Rántás"); LSTR MSG_VE_JERK = _UxGT("E ránt. seb."); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Csomopont eltérés"); LSTR MSG_VELOCITY = _UxGT("Sebesség"); - LSTR MSG_VMAX_A = _UxGT("Max Seb. ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Max Seb. ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Max Seb. ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Max Seb. ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Max Seb. ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Max Seb. ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Max Seb. ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Max Seb. ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Max Seb. ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Max Seb. ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Max Seb. ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Max Seb. ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Max Seb. ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Max Seb. ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Max sebesség *"); LSTR MSG_VMIN = _UxGT("Min sebesség"); LSTR MSG_VTRAV_MIN = _UxGT("Min utazó.seb."); LSTR MSG_ACCELERATION = _UxGT("Gyorsulás"); - LSTR MSG_AMAX_A = _UxGT("Max gyors. ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Max gyors. ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Max gyors. ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Max gyors. ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Max gyors. ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Max gyors. ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Max gyors. ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Max gyors. ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Max gyors. ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Max gyors. ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Max gyors. ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Max gyors. ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Max gyors. ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Max gyors. ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Max gyorsulás *"); LSTR MSG_A_RETRACT = _UxGT("Visszahúzás"); LSTR MSG_A_TRAVEL = _UxGT("Utazás"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Max frekvencia"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min elötolás"); LSTR MSG_STEPS_PER_MM = _UxGT("Lépés/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" Lépés/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" Lépés/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" Lépés/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" Lépés/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" Lépés/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" Lépés/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" Lépés/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" Lépés/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" Lépés/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" Lépés/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" Lépés/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" Lépés/mm"); LSTR MSG_E_STEPS = _UxGT("E lépés/mm"); LSTR MSG_EN_STEPS = _UxGT("*Lépés/mm"); LSTR MSG_TEMPERATURE = _UxGT("Höfok"); @@ -491,9 +489,9 @@ namespace Language_hu { LSTR MSG_BABYSTEP_X = _UxGT("Mikrolépés X"); LSTR MSG_BABYSTEP_Y = _UxGT("Mikrolépés Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Mikrolépés Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Mikrolépés ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Mikrolépés ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Mikrolépés ") LCD_STR_K; + LSTR MSG_BABYSTEP_I = _UxGT("Mikrolépés ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Mikrolépés ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Mikrolépés ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Teljes"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Végállás megszakítva!"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Fütés hiba!"); @@ -553,7 +551,7 @@ namespace Language_hu { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Fényerösség"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("HELYTELEN NYOMTATÓ"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Nyomtatás számláló"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Befejezett"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Összes nyomtatási idö"); @@ -571,12 +569,12 @@ namespace Language_hu { LSTR MSG_INFO_MAX_TEMP = _UxGT("Max höfok"); LSTR MSG_INFO_PSU = _UxGT("PSU"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Meghajtási erö"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Meghajtó %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Meghajtó %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Meghajtó %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Meghajtó %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Meghajtó %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Meghajtó %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Meghajtó %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E meghajtó %"); LSTR MSG_ERROR_TMC = _UxGT("TMC CSATLAKOZÁSI HIBA"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM írása"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 44ae49b519af..431b1d01b7be 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -53,7 +53,7 @@ namespace Language_it { LSTR MSG_MEDIA_INSERTED = _UxGT("Media inserito"); LSTR MSG_MEDIA_REMOVED = _UxGT("Media rimosso"); LSTR MSG_MEDIA_WAITING = _UxGT("Aspettando media"); - LSTR MSG_SD_INIT_FAIL = _UxGT("Inizial.SD fallita"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Iniz.Media fallita"); LSTR MSG_MEDIA_READ_ERROR = _UxGT("Err.leggendo media"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("Dispos.USB rimosso"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Avvio USB fallito"); @@ -68,12 +68,10 @@ namespace Language_it { LSTR MSG_DEBUG_MENU = _UxGT("Menu di debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barra avanzam."); LSTR MSG_AUTO_HOME = _UxGT("Auto Home"); + LSTR MSG_AUTO_HOME_A = _UxGT("Home @"); LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); - LSTR MSG_AUTO_HOME_I = _UxGT("Home ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Home ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Home ") LCD_STR_K; LSTR MSG_AUTO_Z_ALIGN = _UxGT("Allineam.automat. Z"); LSTR MSG_ITERATION = _UxGT("Iterazione G34: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Precisione in calo!"); @@ -87,9 +85,9 @@ namespace Language_it { LSTR MSG_HOME_OFFSET_X = _UxGT("Offset home X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Offset home Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Offset home Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Offset home ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Offset home ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Offset home ") LCD_STR_K; + LSTR MSG_HOME_OFFSET_I = _UxGT("Offset home ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Offset home ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Offset home ") STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offset applicato"); LSTR MSG_SET_ORIGIN = _UxGT("Imposta Origine"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Wizard Tramming"); @@ -270,9 +268,9 @@ namespace Language_it { LSTR MSG_MOVE_X = _UxGT("Muovi X"); LSTR MSG_MOVE_Y = _UxGT("Muovi Y"); LSTR MSG_MOVE_Z = _UxGT("Muovi Z"); - LSTR MSG_MOVE_I = _UxGT("Muovi ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Muovi ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Muovi ") LCD_STR_K; + LSTR MSG_MOVE_I = _UxGT("Muovi ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Muovi ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Muovi ") STR_K; LSTR MSG_MOVE_E = _UxGT("Estrusore"); LSTR MSG_MOVE_EN = _UxGT("Estrusore *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Ugello freddo"); @@ -327,45 +325,45 @@ namespace Language_it { LSTR MSG_SELECT_E = _UxGT("Seleziona *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-jerk"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-jerk"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-jerk"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-jerk"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-jerk"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-jerk"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-jerk"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-jerk"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-jerk"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT("-jerk"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT("-jerk"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT("-jerk"); LSTR MSG_VE_JERK = _UxGT("Ve-jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Deviaz. giunzioni"); LSTR MSG_VELOCITY = _UxGT("Velocità"); - LSTR MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Vmax ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vmax ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vmax ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Vmax ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Vmax ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Vmax ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Vmax ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Vmax *"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VTrav min"); LSTR MSG_ACCELERATION = _UxGT("Accelerazione"); - LSTR MSG_AMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Accel"); - LSTR MSG_AMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Accel"); - LSTR MSG_AMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Accel"); - LSTR MSG_AMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Accel"); - LSTR MSG_AMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Accel"); - LSTR MSG_AMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Accel"); - LSTR MSG_AMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Accel"); + LSTR MSG_AMAX_A = _UxGT("Max ") STR_A _UxGT(" Accel"); + LSTR MSG_AMAX_B = _UxGT("Max ") STR_B _UxGT(" Accel"); + LSTR MSG_AMAX_C = _UxGT("Max ") STR_C _UxGT(" Accel"); + LSTR MSG_AMAX_I = _UxGT("Max ") STR_I _UxGT(" Accel"); + LSTR MSG_AMAX_J = _UxGT("Max ") STR_J _UxGT(" Accel"); + LSTR MSG_AMAX_K = _UxGT("Max ") STR_K _UxGT(" Accel"); + LSTR MSG_AMAX_E = _UxGT("Max ") STR_E _UxGT(" Accel"); LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); LSTR MSG_A_RETRACT = _UxGT("A-Ritrazione"); LSTR MSG_A_TRAVEL = _UxGT("A-Spostamento"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequenza max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); LSTR MSG_STEPS_PER_MM = _UxGT("Passi/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" passi/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" passi/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" passi/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" passi/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" passi/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" passi/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" passi/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" passi/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" passi/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" passi/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" passi/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" passi/mm"); LSTR MSG_E_STEPS = _UxGT("E passi/mm"); LSTR MSG_EN_STEPS = _UxGT("* passi/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -499,9 +497,9 @@ namespace Language_it { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; + LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Totali"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Interrompi se FC"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Risc.Fallito"); // Max 12 characters @@ -556,12 +554,13 @@ namespace Language_it { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Controllo fuga: OFF"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Controllo fuga: ON"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Timeout inatt.ugello"); + LSTR MSG_FAN_SPEED_FAULT = _UxGT("Err.vel.della ventola"); LSTR MSG_CASE_LIGHT = _UxGT("Luci Case"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Luminosità Luci"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("STAMPANTE ERRATA"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Contat. stampa"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completati"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tempo totale"); @@ -578,12 +577,12 @@ namespace Language_it { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp max"); LSTR MSG_INFO_PSU = _UxGT("Alimentatore"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Potenza Drive"); - LSTR MSG_DAC_PERCENT_A = _UxGT("Driver ") LCD_STR_A _UxGT(" %"); - LSTR MSG_DAC_PERCENT_B = _UxGT("Driver ") LCD_STR_B _UxGT(" %"); - LSTR MSG_DAC_PERCENT_C = _UxGT("Driver ") LCD_STR_C _UxGT(" %"); - LSTR MSG_DAC_PERCENT_I = _UxGT("Driver ") LCD_STR_I _UxGT(" %"); - LSTR MSG_DAC_PERCENT_J = _UxGT("Driver ") LCD_STR_J _UxGT(" %"); - LSTR MSG_DAC_PERCENT_K = _UxGT("Driver ") LCD_STR_K _UxGT(" %"); + LSTR MSG_DAC_PERCENT_A = _UxGT("Driver ") STR_A _UxGT(" %"); + LSTR MSG_DAC_PERCENT_B = _UxGT("Driver ") STR_B _UxGT(" %"); + LSTR MSG_DAC_PERCENT_C = _UxGT("Driver ") STR_C _UxGT(" %"); + LSTR MSG_DAC_PERCENT_I = _UxGT("Driver ") STR_I _UxGT(" %"); + LSTR MSG_DAC_PERCENT_J = _UxGT("Driver ") STR_J _UxGT(" %"); + LSTR MSG_DAC_PERCENT_K = _UxGT("Driver ") STR_K _UxGT(" %"); LSTR MSG_DAC_PERCENT_E = _UxGT("Driver E %"); LSTR MSG_ERROR_TMC = _UxGT("ERR.CONNESSIONE TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Scrivi DAC EEPROM"); @@ -597,6 +596,8 @@ namespace Language_it { LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Ugello: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Sens.filo termin."); // Max 17 characters LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Dist mm filo term."); + LSTR MSG_RUNOUT_ENABLE = _UxGT("Abil.filo termin."); + LSTR MSG_FANCHECK = _UxGT("Verif.tacho vent."); // Max 17 characters LSTR MSG_KILL_HOMING_FAILED = _UxGT("Home fallito"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Sondaggio fallito"); diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index 16e605cc25c9..164dca8fcfe2 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -116,28 +116,27 @@ namespace Language_jp_kana { LSTR MSG_SELECT_E = _UxGT("センタク *"); LSTR MSG_ACC = _UxGT("カソクド mm/s") SUPERSCRIPT_TWO; // "Accel" LSTR MSG_JERK = _UxGT("ヤクドウ mm/s"); // "Jerk" - LSTR MSG_VA_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_A; // "Va-jerk" - LSTR MSG_VB_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_B; // "Vb-jerk" - LSTR MSG_VC_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_C; // "Vc-jerk" - LSTR MSG_VI_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_I; // "Va-jerk" - LSTR MSG_VJ_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_J; // "Vb-jerk" - LSTR MSG_VK_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_K; // "Vc-jerk" - LSTR MSG_A_STEPS = LCD_STR_A _UxGT("ステップ/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT("ステップ/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT("ステップ/mm"); + LSTR MSG_VA_JERK = _UxGT("ジク ヤクドウ mm/s") STR_A; // "Va-jerk" + LSTR MSG_VB_JERK = _UxGT("ジク ヤクドウ mm/s") STR_B; // "Vb-jerk" + LSTR MSG_VC_JERK = _UxGT("ジク ヤクドウ mm/s") STR_C; // "Vc-jerk" + LSTR MSG_VI_JERK = _UxGT("ジク ヤクドウ mm/s") STR_I; // "Va-jerk" + LSTR MSG_VJ_JERK = _UxGT("ジク ヤクドウ mm/s") STR_J; // "Vb-jerk" + LSTR MSG_VK_JERK = _UxGT("ジク ヤクドウ mm/s") STR_K; // "Vc-jerk" + LSTR MSG_A_STEPS = STR_A _UxGT("ステップ/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT("ステップ/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT("ステップ/mm"); LSTR MSG_VE_JERK = _UxGT("エクストルーダー ヤクド"); // "Ve-jerk" - LSTR MSG_VMAX_A = _UxGT("サイダイオクリソクド ") LCD_STR_A; // "Vmax A" - LSTR MSG_VMAX_B = _UxGT("サイダイオクリソクド ") LCD_STR_B; // "Vmax B" - LSTR MSG_VMAX_C = _UxGT("サイダイオクリソクド ") LCD_STR_C; // "Vmax C" - LSTR MSG_VMAX_I = _UxGT("サイダイオクリソクド ") LCD_STR_I; // "Vmax I" - LSTR MSG_VMAX_J = _UxGT("サイダイオクリソクド ") LCD_STR_J; // "Vmax J" - LSTR MSG_VMAX_K = _UxGT("サイダイオクリソクド ") LCD_STR_K; // "Vmax K" - LSTR MSG_VMAX_E = _UxGT("サイダイオクリソクド ") LCD_STR_E; // "Vmax E" + LSTR MSG_VMAX_A = _UxGT("サイダイオクリソクド ") STR_A; // "Vmax A" + LSTR MSG_VMAX_B = _UxGT("サイダイオクリソクド ") STR_B; // "Vmax B" + LSTR MSG_VMAX_C = _UxGT("サイダイオクリソクド ") STR_C; // "Vmax C" + LSTR MSG_VMAX_I = _UxGT("サイダイオクリソクド ") STR_I; // "Vmax I" + LSTR MSG_VMAX_J = _UxGT("サイダイオクリソクド ") STR_J; // "Vmax J" + LSTR MSG_VMAX_K = _UxGT("サイダイオクリソクド ") STR_K; // "Vmax K" + LSTR MSG_VMAX_E = _UxGT("サイダイオクリソクド ") STR_E; // "Vmax E" LSTR MSG_VMAX_EN = _UxGT("サイダイオクリソクド *"); // "Vmax E1" LSTR MSG_VMIN = _UxGT("サイショウオクリソクド"); // "Vmin" LSTR MSG_VTRAV_MIN = _UxGT("サイショウイドウソクド"); // "VTrav min" LSTR MSG_ACCELERATION = _UxGT("カソクド mm/s") SUPERSCRIPT_TWO; // "Accel" - LSTR MSG_AMAX = _UxGT("サイダイカソクド "); // "Amax " LSTR MSG_A_RETRACT = _UxGT("ヒキコミカソクド"); // "A-retract" LSTR MSG_A_TRAVEL = _UxGT("イドウカソクド"); // "A-travel" LSTR MSG_TEMPERATURE = _UxGT("オンド"); // "Temperature" @@ -217,12 +216,12 @@ namespace Language_jp_kana { LSTR MSG_INFO_MAX_TEMP = _UxGT("セッテイサイコウオン"); // "Max Temp" LSTR MSG_INFO_PSU = _UxGT("デンゲンシュベツ"); // "Power Supply" LSTR MSG_DRIVE_STRENGTH = _UxGT("モータークドウリョク"); // "Drive Strength" - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" DACシュツリョク %"); // "X Driver %" - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" DACシュツリョク %"); // "Y Driver %" - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" DACシュツリョク %"); // "Z Driver %" - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" DACシュツリョク %"); // "I Driver %" - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" DACシュツリョク %"); // "J Driver %" - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" DACシュツリョク %"); // "K Driver %" + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" DACシュツリョク %"); // "X Driver %" + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" DACシュツリョク %"); // "Y Driver %" + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" DACシュツリョク %"); // "Z Driver %" + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" DACシュツリョク %"); // "I Driver %" + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" DACシュツリョク %"); // "J Driver %" + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" DACシュツリョク %"); // "K Driver %" LSTR MSG_DAC_PERCENT_E = _UxGT("E DACシュツリョク %"); // "E Driver %" LSTR MSG_DAC_EEPROM_WRITE = _UxGT("EEPROMヘホゾン"); // "Store memory" LSTR MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("イチジテイシ"); diff --git a/Marlin/src/lcd/language/language_nl.h b/Marlin/src/lcd/language/language_nl.h index 42df92b88039..e55ed9fea78f 100644 --- a/Marlin/src/lcd/language/language_nl.h +++ b/Marlin/src/lcd/language/language_nl.h @@ -180,7 +180,7 @@ namespace Language_nl { LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Onjuiste printer"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Printed Aantal"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Totaal Voltooid"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Totale Printtijd"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 9105f58bdbb0..47c89e9e3291 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -53,7 +53,7 @@ namespace Language_pl { LSTR MSG_MEDIA_INSERTED = _UxGT("Karta włożona"); LSTR MSG_MEDIA_REMOVED = _UxGT("Karta usunięta"); LSTR MSG_MEDIA_WAITING = _UxGT("Oczekiwanie na kartę"); - LSTR MSG_SD_INIT_FAIL = _UxGT("Błąd inicializacji karty"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Błąd inicializacji karty"); LSTR MSG_MEDIA_READ_ERROR = _UxGT("Bład odczytu karty"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("Urządzenie USB usunięte"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Błąd uruchomienia USB"); @@ -274,12 +274,12 @@ namespace Language_pl { LSTR MSG_SELECT_E = _UxGT("Wybierz *"); LSTR MSG_ACC = _UxGT("Przyspieszenie"); LSTR MSG_JERK = _UxGT("Zryw"); - LSTR MSG_VA_JERK = _UxGT("Zryw V") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("Zryw V") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("Zryw V") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("Zryw V") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("Zryw V") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("Zryw V") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("Zryw V") STR_A; + LSTR MSG_VB_JERK = _UxGT("Zryw V") STR_B; + LSTR MSG_VC_JERK = _UxGT("Zryw V") STR_C; + LSTR MSG_VI_JERK = _UxGT("Zryw V") STR_I; + LSTR MSG_VJ_JERK = _UxGT("Zryw V") STR_J; + LSTR MSG_VK_JERK = _UxGT("Zryw V") STR_K; LSTR MSG_VE_JERK = _UxGT("Zryw Ve"); LSTR MSG_VELOCITY = _UxGT("Prędkość (V)"); @@ -290,12 +290,12 @@ namespace Language_pl { LSTR MSG_A_TRAVEL = _UxGT("A-przesuń."); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Częstotliwość max"); LSTR MSG_STEPS_PER_MM = _UxGT("kroki/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" kroki/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" kroki/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" kroki/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" kroki/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" kroki/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" kroki/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" kroki/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" kroki/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" kroki/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" kroki/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" kroki/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" kroki/mm"); LSTR MSG_E_STEPS = _UxGT("E kroki/mm"); LSTR MSG_EN_STEPS = _UxGT("* kroki/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -430,7 +430,7 @@ namespace Language_pl { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Jasność oświetlenia"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Niepoprawna drukarka"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Wydrukowano"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Ukończono"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Czas druku"); @@ -446,12 +446,12 @@ namespace Language_pl { LSTR MSG_INFO_PSU = _UxGT("Zasilacz"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Siła silnika"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Siła %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Siła %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Siła %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Siła %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Siła %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Siła %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Siła %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Siła %"); LSTR MSG_ERROR_TMC = _UxGT("TMC BŁĄD POŁĄCZENIA"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Zapisz DAC EEPROM"); diff --git a/Marlin/src/lcd/language/language_pt.h b/Marlin/src/lcd/language/language_pt.h index 524c2c97d859..f73fe1f1b481 100644 --- a/Marlin/src/lcd/language/language_pt.h +++ b/Marlin/src/lcd/language/language_pt.h @@ -102,12 +102,12 @@ namespace Language_pt { LSTR MSG_A_RETRACT = _UxGT("A-retracção"); LSTR MSG_A_TRAVEL = _UxGT("A-movimento"); LSTR MSG_STEPS_PER_MM = _UxGT("Passo/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" passo/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" passo/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" passo/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" passo/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" passo/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" passo/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" passo/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" passo/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" passo/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" passo/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" passo/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" passo/mm"); LSTR MSG_E_STEPS = _UxGT("E passo/mm"); LSTR MSG_EN_STEPS = _UxGT("* passo/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index c66f717f9d28..8d8c65f63d4e 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -240,12 +240,12 @@ namespace Language_pt_br { LSTR MSG_SELECT_E = _UxGT("Selecionar *"); LSTR MSG_ACC = _UxGT("Acel."); LSTR MSG_JERK = _UxGT("Arrancada"); - LSTR MSG_VA_JERK = _UxGT("arrancada V") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("arrancada V") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("arrancada V") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("arrancada V") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("arrancada V") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("arrancada V") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("arrancada V") STR_A; + LSTR MSG_VB_JERK = _UxGT("arrancada V") STR_B; + LSTR MSG_VC_JERK = _UxGT("arrancada V") STR_C; + LSTR MSG_VI_JERK = _UxGT("arrancada V") STR_I; + LSTR MSG_VJ_JERK = _UxGT("arrancada V") STR_J; + LSTR MSG_VK_JERK = _UxGT("arrancada V") STR_K; LSTR MSG_VE_JERK = _UxGT("arrancada VE"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Desv. Junção"); LSTR MSG_VELOCITY = _UxGT("Velocidade"); @@ -254,12 +254,12 @@ namespace Language_pt_br { LSTR MSG_A_RETRACT = _UxGT("Retrair A"); LSTR MSG_A_TRAVEL = _UxGT("Movimento A"); LSTR MSG_STEPS_PER_MM = _UxGT("Passo/mm"); - LSTR MSG_A_STEPS = _UxGT("Passo ") LCD_STR_A _UxGT("/mm"); - LSTR MSG_B_STEPS = _UxGT("Passo ") LCD_STR_B _UxGT("/mm"); - LSTR MSG_C_STEPS = _UxGT("Passo ") LCD_STR_C _UxGT("/mm"); - LSTR MSG_I_STEPS = _UxGT("Passo ") LCD_STR_I _UxGT("/mm"); - LSTR MSG_J_STEPS = _UxGT("Passo ") LCD_STR_J _UxGT("/mm"); - LSTR MSG_K_STEPS = _UxGT("Passo ") LCD_STR_K _UxGT("/mm"); + LSTR MSG_A_STEPS = _UxGT("Passo ") STR_A _UxGT("/mm"); + LSTR MSG_B_STEPS = _UxGT("Passo ") STR_B _UxGT("/mm"); + LSTR MSG_C_STEPS = _UxGT("Passo ") STR_C _UxGT("/mm"); + LSTR MSG_I_STEPS = _UxGT("Passo ") STR_I _UxGT("/mm"); + LSTR MSG_J_STEPS = _UxGT("Passo ") STR_J _UxGT("/mm"); + LSTR MSG_K_STEPS = _UxGT("Passo ") STR_K _UxGT("/mm"); LSTR MSG_E_STEPS = _UxGT("E/mm"); LSTR MSG_EN_STEPS = _UxGT("*/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -400,7 +400,7 @@ namespace Language_pt_br { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Intensidade Brilho"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Impressora Incorreta"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Total de Impressões"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Realizadas"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tempo de Impressão"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index fee63dc2ad90..f51179829a8e 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -268,45 +268,45 @@ namespace Language_ro { LSTR MSG_SELECT_E = _UxGT("Select *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-Jerk"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-Jerk"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-Jerk"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-Jerk"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-Jerk"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-Jerk"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-Jerk"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-Jerk"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-Jerk"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT("-Jerk"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT("-Jerk"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT("-Jerk"); LSTR MSG_VE_JERK = _UxGT("Ve-Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); LSTR MSG_VELOCITY = _UxGT("Velocity"); - LSTR MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Vmax ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vmax ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vmax ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Vmax ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Vmax ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Vmax ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Vmax ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Vmax *"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VTrav Min"); LSTR MSG_ACCELERATION = _UxGT("Acceleration"); - LSTR MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Amax ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Amax ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Amax ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Amax ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Amax ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Amax ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Amax ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Amax ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Amax ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Amax ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Amax *"); LSTR MSG_A_RETRACT = _UxGT("A-Retract"); LSTR MSG_A_TRAVEL = _UxGT("A-Travel"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequency max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" steps/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" steps/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" steps/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" steps/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" steps/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" steps/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" steps/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" steps/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" steps/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" steps/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" steps/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" steps/mm"); LSTR MSG_E_STEPS = _UxGT("Esteps/mm"); LSTR MSG_EN_STEPS = _UxGT("*steps/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperature"); @@ -486,7 +486,7 @@ namespace Language_ro { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Light Brightness"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("INCORRECT PRINTER"); -#if LCD_WIDTH >= 20 +#if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Total Printuri"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completat"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Timp Imprimare Total"); @@ -504,12 +504,12 @@ namespace Language_ro { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temperatura Maxima"); LSTR MSG_INFO_PSU = _UxGT("PSU"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Drive Strength"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); LSTR MSG_ERROR_TMC = _UxGT("TMC CONNECTION ERROR"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Write"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index e33018b0341c..d6b5bbfbdf04 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -43,15 +43,15 @@ namespace Language_ru { LSTR MSG_MEDIA_INSERTED = _UxGT("SD карта вставлена"); LSTR MSG_MEDIA_REMOVED = _UxGT("SD карта извлечена"); LSTR MSG_MEDIA_WAITING = _UxGT("Вставьте SD карту"); - #if LCD_WIDTH > 21 - LSTR MSG_SD_INIT_FAIL = _UxGT("Сбой инициализации SD"); + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Сбой инициализации SD"); #else - LSTR MSG_SD_INIT_FAIL = _UxGT("Сбой инициализ. SD"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Сбой инициализ. SD"); #endif LSTR MSG_MEDIA_READ_ERROR = _UxGT("Ошибка считывания"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB диск удалён"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Ошибка USB диска"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Переполнение вызова"); #else LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Переполн. вызова"); @@ -66,12 +66,10 @@ namespace Language_ru { LSTR MSG_DEBUG_MENU = _UxGT("Меню отладки"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Тест индикатора"); LSTR MSG_AUTO_HOME = _UxGT("Парковка XYZ"); + LSTR MSG_AUTO_HOME_A = _UxGT("Парковка @"); LSTR MSG_AUTO_HOME_X = _UxGT("Парковка X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Парковка Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Парковка Z"); - LSTR MSG_AUTO_HOME_I = _UxGT("Парковка ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Парковка ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Парковка ") LCD_STR_K; LSTR MSG_AUTO_Z_ALIGN = _UxGT("Авто Z-выравнивание"); LSTR MSG_ITERATION = _UxGT("G34 Итерация: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Уменьшение точности!"); @@ -81,27 +79,27 @@ namespace Language_ru { LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Следующая точка"); LSTR MSG_LEVEL_BED_DONE = _UxGT("Выравнивание готово!"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Высота спада"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SET_HOME_OFFSETS = _UxGT("Установ. смещения дома"); LSTR MSG_HOME_OFFSET_X = _UxGT("Смещение дома X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Смещение дома Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Смещение дома Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Смещение дома ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Смещение дома ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Смещение дома ") LCD_STR_K; + LSTR MSG_HOME_OFFSET_I = _UxGT("Смещение дома ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Смещение дома ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Смещение дома ") STR_K; #else LSTR MSG_SET_HOME_OFFSETS = _UxGT("Установ.смещ.дома"); LSTR MSG_HOME_OFFSET_X = _UxGT("Смещ. дома X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Смещ. дома Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Смещ. дома Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Смещ. дома ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Смещ. дома ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Смещ. дома ") LCD_STR_K; + LSTR MSG_HOME_OFFSET_I = _UxGT("Смещ. дома ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Смещ. дома ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Смещ. дома ") STR_K; #endif LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Смещения применены"); LSTR MSG_SET_ORIGIN = _UxGT("Установить ноль"); LSTR MSG_SELECT_ORIGIN = _UxGT("Выберите ноль"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_LAST_VALUE_SP = _UxGT("Последнее знач. "); #else LSTR MSG_LAST_VALUE_SP = _UxGT("Послед. знач. "); @@ -127,7 +125,7 @@ namespace Language_ru { LSTR MSG_COOLDOWN = _UxGT("Охлаждение"); LSTR MSG_CUTTER_FREQUENCY = _UxGT("Частота"); LSTR MSG_LASER_MENU = _UxGT("Управление лазером"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SPINDLE_MENU = _UxGT("Управление шпинделем"); LSTR MSG_LASER_TOGGLE = _UxGT("Переключить лазер"); LSTR MSG_SPINDLE_TOGGLE = _UxGT("Переключ.шпиндель"); @@ -161,7 +159,7 @@ namespace Language_ru { LSTR MSG_LEVEL_BED = _UxGT("Выровнять стол"); LSTR MSG_BED_TRAMMING = _UxGT("Выровнять углы"); LSTR MSG_NEXT_CORNER = _UxGT("Следующий угол"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Вверх до срабатыв. зонда"); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Углы в норме. Вырав.стола"); #else @@ -170,7 +168,7 @@ namespace Language_ru { #endif LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Хорошие точки: "); LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Последняя Z: "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MESH_EDITOR = _UxGT("Смещение по Z"); LSTR MSG_EDITING_STOPPED = _UxGT("Правка сетки окончена"); #else @@ -205,7 +203,7 @@ namespace Language_ru { LSTR MSG_UBL_LEVEL_BED = _UxGT("Настройка UBL"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Точка разворота"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Ручной ввод сетки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_BC_INSERT = _UxGT("Разместить шайбу,измерить"); LSTR MSG_UBL_BC_REMOVE = _UxGT("Убрать и замерить стол"); #else @@ -219,7 +217,7 @@ namespace Language_ru { LSTR MSG_UBL_DEACTIVATE_MESH = _UxGT("Деактивировать UBL"); LSTR MSG_UBL_MESH_EDIT = _UxGT("Редактор сеток"); LSTR MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Править свою сетку"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_SET_TEMP_BED = _UxGT("Температура стола"); LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Температура стола"); LSTR MSG_UBL_SET_TEMP_HOTEND = _UxGT("Температура сопла"); @@ -237,7 +235,7 @@ namespace Language_ru { LSTR MSG_UBL_FINE_TUNE_MESH = _UxGT("Точная правка сетки"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Построить сетку"); LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Построить сетку $"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_BUILD_COLD_MESH = _UxGT("Построить холодную сетку"); #else LSTR MSG_UBL_BUILD_COLD_MESH = _UxGT("Строить холод.сетку"); @@ -245,7 +243,7 @@ namespace Language_ru { LSTR MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Правка высоты сетки"); LSTR MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Высота"); LSTR MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Проверить сетку"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Проверить сетку $"); LSTR MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Проверить свою сетку"); #else @@ -261,7 +259,7 @@ namespace Language_ru { LSTR MSG_G26_LEAVING = _UxGT("Выйти из G26"); LSTR MSG_UBL_CONTINUE_MESH = _UxGT("Продолжить сетку"); LSTR MSG_UBL_MESH_LEVELING = _UxGT("Выравнивание сетки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-х точечное выравнивание"); #else LSTR MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-точечное выравн."); @@ -273,7 +271,7 @@ namespace Language_ru { LSTR MSG_UBL_OUTPUT_MAP = _UxGT("Вывести карту сетки"); LSTR MSG_UBL_OUTPUT_MAP_HOST = _UxGT("Вывести на хост"); LSTR MSG_UBL_OUTPUT_MAP_CSV = _UxGT("Вывести в CSV"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Сохранить сетку снаружи"); LSTR MSG_UBL_INFO_UBL = _UxGT("Вывод информации UBL"); LSTR MSG_UBL_FILLIN_AMOUNT = _UxGT("Кол-во заполнителя"); @@ -323,7 +321,7 @@ namespace Language_ru { LSTR MSG_SET_LEDS_DEFAULT = _UxGT("Свет по умолчанию"); LSTR MSG_LED_CHANNEL_N = _UxGT("Канал ="); LSTR MSG_LEDS2 = _UxGT("Свет #2"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_NEO2_PRESETS = _UxGT("Свет #2 предустановки"); #else LSTR MSG_NEO2_PRESETS = _UxGT("Свет #2 предустан."); @@ -341,9 +339,9 @@ namespace Language_ru { LSTR MSG_MOVE_X = _UxGT("Движение по X"); LSTR MSG_MOVE_Y = _UxGT("Движение по Y"); LSTR MSG_MOVE_Z = _UxGT("Движение по Z"); - LSTR MSG_MOVE_I = _UxGT("Движение по ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Движение по ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Движение по ") LCD_STR_K; + LSTR MSG_MOVE_I = _UxGT("Движение по ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Движение по ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Движение по ") STR_K; LSTR MSG_MOVE_E = _UxGT("Экструдер"); LSTR MSG_MOVE_EN = _UxGT("Экструдер *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Сопло не нагрето"); @@ -360,7 +358,7 @@ namespace Language_ru { LSTR MSG_NOZZLE_STANDBY = _UxGT("Сопло ожидает"); LSTR MSG_BED = _UxGT("Стол, ") LCD_STR_DEGREE "C"; LSTR MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_COOLER = _UxGT("Охлаждение лазера"); LSTR MSG_COOLER_TOGGLE = _UxGT("Переключ. охлажд."); LSTR MSG_FLOWMETER_SAFETY = _UxGT("Безопасн. потока"); @@ -401,49 +399,49 @@ namespace Language_ru { LSTR MSG_SELECT_E = _UxGT("Выбор *"); LSTR MSG_ACC = _UxGT("Ускорение"); LSTR MSG_JERK = _UxGT("Рывок"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-рывок"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-рывок"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-рывок"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-рывок"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-рывок"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-рывок"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-рывок"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-рывок"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-рывок"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT("-рывок"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT("-рывок"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT("-рывок"); LSTR MSG_VE_JERK = _UxGT("Ve-рывок"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_JUNCTION_DEVIATION = _UxGT("Отклонение узла"); #else LSTR MSG_JUNCTION_DEVIATION = _UxGT("Отклон. узла"); #endif LSTR MSG_VELOCITY = _UxGT("Скорость, мм/с"); - LSTR MSG_VMAX_A = _UxGT("Скор.макс ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Скор.макс ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Скор.макс ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Скор.макс ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Скор.макс ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Скор.макс ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Скор.макс ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Скор.макс ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Скор.макс ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Скор.макс ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Скор.макс ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Скор.макс ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Скор.макс ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Скор.макс ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Скор.макс *"); LSTR MSG_VMIN = _UxGT("Скор.мин"); LSTR MSG_VTRAV_MIN = _UxGT("Перемещение мин"); LSTR MSG_ACCELERATION = _UxGT("Ускорение, мм/с2"); - LSTR MSG_AMAX_A = _UxGT("Ускор.макс ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Ускор.макс ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Ускор.макс ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Ускор.макс ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Ускор.макс ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Ускор.макс ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Ускор.макс ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Ускор.макс ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Ускор.макс ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Ускор.макс ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Ускор.макс ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Ускор.макс ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Ускор.макс ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Ускор.макс ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Ускор.макс *"); LSTR MSG_A_RETRACT = _UxGT("Ускор.втягив."); LSTR MSG_A_TRAVEL = _UxGT("Ускор.путеш."); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Частота макс."); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Подача мин."); LSTR MSG_STEPS_PER_MM = _UxGT("Шагов/мм"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" шаг/мм"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" шаг/мм"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" шаг/мм"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" шаг/мм"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" шаг/мм"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" шаг/мм"); + LSTR MSG_A_STEPS = STR_A _UxGT(" шаг/мм"); + LSTR MSG_B_STEPS = STR_B _UxGT(" шаг/мм"); + LSTR MSG_C_STEPS = STR_C _UxGT(" шаг/мм"); + LSTR MSG_I_STEPS = STR_I _UxGT(" шаг/мм"); + LSTR MSG_J_STEPS = STR_J _UxGT(" шаг/мм"); + LSTR MSG_K_STEPS = STR_K _UxGT(" шаг/мм"); LSTR MSG_E_STEPS = _UxGT("E шаг/мм"); LSTR MSG_EN_STEPS = _UxGT("* шаг/мм"); LSTR MSG_TEMPERATURE = _UxGT("Температура"); @@ -452,7 +450,7 @@ namespace Language_ru { LSTR MSG_VOLUMETRIC_ENABLED = _UxGT("E в мм") SUPERSCRIPT_THREE; LSTR MSG_VOLUMETRIC_LIMIT = _UxGT("E огран.,мм") SUPERSCRIPT_THREE; LSTR MSG_VOLUMETRIC_LIMIT_E = _UxGT("E огран. *"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_FILAMENT_DIAM = _UxGT("Диам. филамента"); LSTR MSG_FILAMENT_DIAM_E = _UxGT("Диам. филамента *"); #else @@ -466,7 +464,7 @@ namespace Language_ru { LSTR MSG_CONTRAST = _UxGT("Контраст экрана"); LSTR MSG_STORE_EEPROM = _UxGT("Сохранить настройки"); LSTR MSG_LOAD_EEPROM = _UxGT("Загрузить настройки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_RESTORE_DEFAULTS = _UxGT("На базовые параметры"); LSTR MSG_INIT_EEPROM = _UxGT("Инициализация EEPROM"); #else @@ -520,7 +518,7 @@ namespace Language_ru { LSTR MSG_NO_MOVE = _UxGT("Нет движения."); LSTR MSG_KILLED = _UxGT("УБИТО. "); LSTR MSG_STOPPED = _UxGT("ОСТАНОВЛЕНО. "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_CONTROL_RETRACT = _UxGT("Втягивание, мм"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Смена втягив., мм"); LSTR MSG_CONTROL_RETRACT_RECOVER_SWAP = _UxGT("Возврат смены, мм"); @@ -539,7 +537,7 @@ namespace Language_ru { LSTR MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Возврат V"); LSTR MSG_FILAMENT_SWAP_LENGTH = _UxGT("Поменять длины"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_FILAMENT_SWAP_EXTRA = _UxGT("Поменять дополнительно"); #else LSTR MSG_FILAMENT_SWAP_EXTRA = _UxGT("Поменять дополнит."); @@ -548,7 +546,7 @@ namespace Language_ru { LSTR MSG_TOOL_CHANGE = _UxGT("Смена сопел"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Поднятие по Z"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Начальная скор."); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Скорость втягив."); #else @@ -568,7 +566,7 @@ namespace Language_ru { LSTR MSG_FILAMENTCHANGE = _UxGT("Смена филамента"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Смена филамента *"); LSTR MSG_FILAMENTLOAD = _UxGT("Загрузить филамент"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_FILAMENTLOAD_E = _UxGT("Загрузить филамент *"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Выгрузить филамент *"); #else @@ -606,7 +604,7 @@ namespace Language_ru { LSTR MSG_ZPROBE_XOFFSET = _UxGT("Смещение X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Смещение Y"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Смещение Z"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Двигать сопло к столу"); #else LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Двиг. сопло к столу"); @@ -614,9 +612,9 @@ namespace Language_ru { LSTR MSG_BABYSTEP_X = _UxGT("Микрошаг X"); LSTR MSG_BABYSTEP_Y = _UxGT("Микрошаг Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Микрошаг Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Микрошаг ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Микрошаг ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Микрошаг ") LCD_STR_K; + LSTR MSG_BABYSTEP_I = _UxGT("Микрошаг ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Микрошаг ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Микрошаг ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Сумарно"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Сработал концевик"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Разогрев не удался"); @@ -650,7 +648,7 @@ namespace Language_ru { LSTR MSG_DELTA_SETTINGS = _UxGT("Настройки Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Авто калибровка"); LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Высота Delta"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондировать Z-смещения"); #else LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондир. Z-смещения"); @@ -660,7 +658,7 @@ namespace Language_ru { LSTR MSG_DELTA_RADIUS = _UxGT("Радиус"); LSTR MSG_INFO_MENU = _UxGT("О принтере"); LSTR MSG_INFO_PRINTER_MENU = _UxGT("Данные принтера"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_3POINT_LEVELING = _UxGT("3-точечное выравнивание"); LSTR MSG_LINEAR_LEVELING = _UxGT("Линейное выравнивание"); LSTR MSG_BILINEAR_LEVELING = _UxGT("Билинейное выравнивание"); @@ -671,7 +669,7 @@ namespace Language_ru { #endif LSTR MSG_UBL_LEVELING = _UxGT("Управление UBL"); LSTR MSG_MESH_LEVELING = _UxGT("Выравнивание сетки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MESH_DONE = _UxGT("Зондирование выполнено"); #else LSTR MSG_MESH_DONE = _UxGT("Зондиров. выполнено"); @@ -683,7 +681,7 @@ namespace Language_ru { LSTR MSG_INFO_EXTRUDERS = _UxGT("Экструдеры"); LSTR MSG_INFO_BAUDRATE = _UxGT("Скорость,БОД"); LSTR MSG_INFO_PROTOCOL = _UxGT("Протокол"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Контроль утечки Т: Выкл"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Контроль утечки Т: Вкл"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Время простоя хотенда"); @@ -696,7 +694,7 @@ namespace Language_ru { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Яркость подсветки"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Неверный принтер"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Счётчик печати"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Общее время печати"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Наидольшее задание"); @@ -713,12 +711,12 @@ namespace Language_ru { LSTR MSG_INFO_MAX_TEMP = _UxGT("Макс. ") LCD_STR_THERMOMETER; LSTR MSG_INFO_PSU = _UxGT("БП"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Сила привода"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Привод, %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Привод, %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Привод, %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Привод, %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Привод, %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Привод, %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Привод, %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Привод, %"); LSTR MSG_ERROR_TMC = _UxGT("СБОЙ СВЯЗИ С TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Запись DAC в EEPROM"); @@ -730,7 +728,7 @@ namespace Language_ru { LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Выдавить ещё"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Возобновить печать"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Сопла: "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_RUNOUT_SENSOR = _UxGT("Датчик оконч. филамента"); #else LSTR MSG_RUNOUT_SENSOR = _UxGT("Датчик оконч.филам."); @@ -741,7 +739,7 @@ namespace Language_ru { LSTR MSG_MMU2_CHOOSE_FILAMENT_HEADER = _UxGT("ВЫБИРЕТЕ ФИЛАМЕНТ"); LSTR MSG_MMU2_MENU = _UxGT("Настройки MMU"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_KILL_MMU2_FIRMWARE = _UxGT("Обновить прошивку MMU!"); #else LSTR MSG_KILL_MMU2_FIRMWARE = _UxGT("Обнови прошивку MMU"); @@ -756,7 +754,7 @@ namespace Language_ru { LSTR MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Извлечь филамент ~"); LSTR MSG_MMU2_UNLOAD_FILAMENT = _UxGT("Выгрузить филамент"); LSTR MSG_MMU2_LOADING_FILAMENT = _UxGT("Загрузка %i..."); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MMU2_EJECTING_FILAMENT = _UxGT("Извлечение филамента..."); #else LSTR MSG_MMU2_EJECTING_FILAMENT = _UxGT("Извлеч.филамента..."); @@ -768,7 +766,7 @@ namespace Language_ru { LSTR MSG_MMU2_RESETTING = _UxGT("Перезапуск MMU..."); LSTR MSG_MMU2_EJECT_RECOVER = _UxGT("Удалите и нажмите"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MIX = _UxGT("Смешивание"); #else LSTR MSG_MIX = _UxGT("Смешив."); @@ -780,7 +778,7 @@ namespace Language_ru { LSTR MSG_CYCLE_MIX = _UxGT("Цикличное смешивание"); LSTR MSG_GRADIENT_MIX = _UxGT("Градиент смешивания"); LSTR MSG_REVERSE_GRADIENT = _UxGT("Сменить градиент"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_TOGGLE_MIX = _UxGT("Переключить смешивание"); LSTR MSG_ACTIVE_VTOOL = _UxGT("Активация В-инструм."); LSTR MSG_START_VTOOL = _UxGT("Начало В-инструмента"); @@ -808,7 +806,7 @@ namespace Language_ru { LSTR MSG_SNAKE = _UxGT("Змейка"); LSTR MSG_MAZE = _UxGT("Лабиринт"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_BAD_PAGE = _UxGT("Плохой индекс страницы"); LSTR MSG_BAD_PAGE_SPEED = _UxGT("Плохая скорость страницы"); #else @@ -824,7 +822,7 @@ namespace Language_ru { LSTR MSG_REMOVE_PASSWORD = _UxGT("Удалить пароль"); LSTR MSG_PASSWORD_SET = _UxGT("Пароль это "); LSTR MSG_START_OVER = _UxGT("Старт через"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_REMINDER_SAVE_SETTINGS = _UxGT("Запомни для сохранения!"); #else LSTR MSG_REMINDER_SAVE_SETTINGS = _UxGT("Запомни, сохрани!"); @@ -875,7 +873,7 @@ namespace Language_ru { LSTR MSG_LEVEL_X_AXIS = _UxGT("Уровень оси X"); LSTR MSG_AUTO_CALIBRATE = _UxGT("Авто калибровка"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_HEATER_TIMEOUT = _UxGT("Время нагревателя вышло"); #else LSTR MSG_HEATER_TIMEOUT = _UxGT("Время нагрев. вышло"); @@ -884,7 +882,7 @@ namespace Language_ru { LSTR MSG_REHEATING = _UxGT("Нагрев..."); LSTR MSG_PROBE_WIZARD = _UxGT("Мастер Z-зонда"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Зондиров. контр. точки Z"); LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Движение к точке зондиров."); #else diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index 76e7f7fbd7a6..64e298cb152e 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -56,7 +56,7 @@ namespace Language_sk { LSTR MSG_MEDIA_INSERTED = _UxGT("Karta vložená"); LSTR MSG_MEDIA_REMOVED = _UxGT("Karta vybraná"); LSTR MSG_MEDIA_WAITING = _UxGT("Čakám na kartu"); - LSTR MSG_SD_INIT_FAIL = _UxGT("Inicial. SD zlyhala"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Inicial. SD zlyhala"); LSTR MSG_MEDIA_READ_ERROR = _UxGT("Chyba čítania karty"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB zaria. odstrán."); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Chyba spúšťania USB"); @@ -72,12 +72,10 @@ namespace Language_sk { LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test uk. priebehu"); LSTR MSG_HOMING = _UxGT("Parkovanie"); LSTR MSG_AUTO_HOME = _UxGT("Domovská pozícia"); + LSTR MSG_AUTO_HOME_A = _UxGT("Domov os @"); LSTR MSG_AUTO_HOME_X = _UxGT("Domov os X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Domov os Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Domov os Z"); - LSTR MSG_AUTO_HOME_I = _UxGT("Domov os ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Domov os ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Domov os ") LCD_STR_K; LSTR MSG_FILAMENT_SET = _UxGT("Nastav. filamentu"); LSTR MSG_FILAMENT_MAN = _UxGT("Správa filamentu"); LSTR MSG_LEVBED_FL = _UxGT("Ľavý predný"); @@ -86,6 +84,7 @@ namespace Language_sk { LSTR MSG_LEVBED_BL = _UxGT("Ľavý zadný"); LSTR MSG_LEVBED_BR = _UxGT("Pravý zadný"); LSTR MSG_MANUAL_MESH = _UxGT("Ručná mriežka"); + LSTR MSG_AUTO_MESH = _UxGT("Automat. mriežka"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Auto-zarovn. Z"); LSTR MSG_ITERATION = _UxGT("Iterácia G34: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Klesajúca presnosť!"); @@ -99,9 +98,9 @@ namespace Language_sk { LSTR MSG_HOME_OFFSET_X = _UxGT("X Ofset"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Y Ofset"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Z Ofset"); - LSTR MSG_HOME_OFFSET_I = LCD_STR_I _UxGT(" Ofset"); - LSTR MSG_HOME_OFFSET_J = LCD_STR_J _UxGT(" Ofset"); - LSTR MSG_HOME_OFFSET_K = LCD_STR_K _UxGT(" Ofset"); + LSTR MSG_HOME_OFFSET_I = STR_I _UxGT(" Ofset"); + LSTR MSG_HOME_OFFSET_J = STR_J _UxGT(" Ofset"); + LSTR MSG_HOME_OFFSET_K = STR_K _UxGT(" Ofset"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofsety nastavené"); LSTR MSG_SET_ORIGIN = _UxGT("Nastaviť začiatok"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Spriev. vyrovn."); @@ -156,8 +155,11 @@ namespace Language_sk { LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Posl. Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Ďalší roh"); LSTR MSG_MESH_EDITOR = _UxGT("Editor sieťe bodov"); + LSTR MSG_MESH_VIEWER = _UxGT("Zobraz. sieťe bodov"); LSTR MSG_EDIT_MESH = _UxGT("Upraviť sieť bodov"); + LSTR MSG_MESH_VIEW = _UxGT("Zobraz. sieť bodov"); LSTR MSG_EDITING_STOPPED = _UxGT("Koniec úprav siete"); + LSTR MSG_NO_VALID_MESH = _UxGT("Neplatná sieť bodov"); LSTR MSG_PROBING_POINT = _UxGT("Skúšam bod"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); @@ -280,9 +282,9 @@ namespace Language_sk { LSTR MSG_MOVE_X = _UxGT("Posunúť X"); LSTR MSG_MOVE_Y = _UxGT("Posunúť Y"); LSTR MSG_MOVE_Z = _UxGT("Posunúť Z"); - LSTR MSG_MOVE_I = _UxGT("Posunúť ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Posunúť ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Posunúť ") LCD_STR_K; + LSTR MSG_MOVE_I = _UxGT("Posunúť ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Posunúť ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Posunúť ") STR_K; LSTR MSG_MOVE_E = _UxGT("Extrudér"); LSTR MSG_MOVE_EN = _UxGT("Extrudér *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend je studený"); @@ -297,10 +299,10 @@ namespace Language_sk { LSTR MSG_MOVE_1IN = _UxGT("Posunúť o 1,0in"); LSTR MSG_SPEED = _UxGT("Rýchlosť"); LSTR MSG_MAXSPEED = _UxGT("Max rýchl. (mm/s)"); - LSTR MSG_MAXSPEED_X = _UxGT("Max rýchl. ") LCD_STR_A; - LSTR MSG_MAXSPEED_Y = _UxGT("Max rýchl. ") LCD_STR_B; - LSTR MSG_MAXSPEED_Z = _UxGT("Max rýchl. ") LCD_STR_C; - LSTR MSG_MAXSPEED_E = _UxGT("Max rýchl. ") LCD_STR_E; + LSTR MSG_MAXSPEED_X = _UxGT("Max rýchl. ") STR_A; + LSTR MSG_MAXSPEED_Y = _UxGT("Max rýchl. ") STR_B; + LSTR MSG_MAXSPEED_Z = _UxGT("Max rýchl. ") STR_C; + LSTR MSG_MAXSPEED_E = _UxGT("Max rýchl. ") STR_E; LSTR MSG_MAXSPEED_A = _UxGT("Max rýchl. @"); LSTR MSG_BED_Z = _UxGT("Výška podl."); LSTR MSG_NOZZLE = _UxGT("Tryska"); @@ -343,45 +345,45 @@ namespace Language_sk { LSTR MSG_SELECT_E = _UxGT("Vybrať *"); LSTR MSG_ACC = _UxGT("Zrýchlenie"); LSTR MSG_JERK = _UxGT("Skok"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-skok"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-skok"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-skok"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-skok"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-skok"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-skok"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-skok"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-skok"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-skok"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT("-skok"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT("-skok"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT("-skok"); LSTR MSG_VE_JERK = _UxGT("Ve-skok"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); LSTR MSG_VELOCITY = _UxGT("Rýchlosť"); - LSTR MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Vmax ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vmax ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vmax ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Vmax ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Vmax ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Vmax ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Vmax ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Vmax *"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VPrej Min"); LSTR MSG_ACCELERATION = _UxGT("Akcelerácia"); - LSTR MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Amax ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Amax ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Amax ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Amax ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Amax ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Amax ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Amax ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Amax ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Amax ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Amax ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Amax *"); LSTR MSG_A_RETRACT = _UxGT("A-retrakt"); LSTR MSG_A_TRAVEL = _UxGT("A-prejazd"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Max. frekvencia"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min. posun"); LSTR MSG_STEPS_PER_MM = _UxGT("Kroky/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" krokov/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" krokov/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" krokov/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" krokov/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" krokov/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" krokov/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" krokov/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" krokov/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" krokov/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" krokov/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" krokov/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" krokov/mm"); LSTR MSG_E_STEPS = _UxGT("Ekrokov/mm"); LSTR MSG_EN_STEPS = _UxGT("*krokov/mm"); LSTR MSG_TEMPERATURE = _UxGT("Teplota"); @@ -397,6 +399,7 @@ namespace Language_sk { LSTR MSG_ADVANCE_K = _UxGT("K pre posun"); LSTR MSG_ADVANCE_K_E = _UxGT("K pre posun *"); LSTR MSG_CONTRAST = _UxGT("Kontrast LCD"); + LSTR MSG_BRIGHTNESS = _UxGT("Jas LCD"); LSTR MSG_STORE_EEPROM = _UxGT("Uložiť nastavenie"); LSTR MSG_LOAD_EEPROM = _UxGT("Načítať nastavenie"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Obnoviť nastavenie"); @@ -427,8 +430,14 @@ namespace Language_sk { LSTR MSG_BUTTON_BACK = _UxGT("Naspäť"); LSTR MSG_BUTTON_PROCEED = _UxGT("Pokračovať"); LSTR MSG_BUTTON_SKIP = _UxGT("Preskočiť"); + LSTR MSG_BUTTON_INFO = _UxGT("Informácie"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Vyrovnať"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Pauza"); + LSTR MSG_BUTTON_RESUME = _UxGT("Obnoviť"); + LSTR MSG_BUTTON_ADVANCED = _UxGT("Pokročilé"); LSTR MSG_PAUSING = _UxGT("Pozastavujem..."); LSTR MSG_PAUSE_PRINT = _UxGT("Pozastaviť tlač"); + LSTR MSG_ADVANCED_PAUSE = _UxGT("Pokročil. pauza"); LSTR MSG_RESUME_PRINT = _UxGT("Obnoviť tlač"); LSTR MSG_HOST_START_PRINT = _UxGT("Spustiť z hosta"); LSTR MSG_STOP_PRINT = _UxGT("Zastaviť tlač"); @@ -437,12 +446,14 @@ namespace Language_sk { LSTR MSG_CANCEL_OBJECT = _UxGT("Zrušiť objekt"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Zrušiť objekt ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Obnova po výp. nap."); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Pokračovať v úlohe"); LSTR MSG_MEDIA_MENU = _UxGT("Tlačiť z SD"); LSTR MSG_NO_MEDIA = _UxGT("Žiadna SD karta"); LSTR MSG_DWELL = _UxGT("Spím..."); LSTR MSG_USERWAIT = _UxGT("Pokrač. kliknutím..."); LSTR MSG_PRINT_PAUSED = _UxGT("Tlač pozastavená"); LSTR MSG_PRINTING = _UxGT("Tlačím..."); + LSTR MSG_STOPPING = _UxGT("Zastavujem..."); LSTR MSG_PRINT_ABORTED = _UxGT("Tlač zrušená"); LSTR MSG_PRINT_DONE = _UxGT("Tlač dokončená"); LSTR MSG_NO_MOVE = _UxGT("Žiadny pohyb."); @@ -492,6 +503,7 @@ namespace Language_sk { LSTR MSG_BLTOUCH_STOW = _UxGT("Zasunúť"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Vysunúť"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("Režim SW"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("Vysoká rýchl."); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("Režim 5V"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("Režim OD"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Ulož. režim"); @@ -516,14 +528,15 @@ namespace Language_sk { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; + LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Celkom"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Zastavenie Endstop"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Chyba ohrevu"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Chyba: REDUND. TEP."); LSTR MSG_THERMAL_RUNAWAY = _UxGT("TEPLOTNÝ SKOK"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("TEPLOTNÁ PORUCHA"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("TEPLOTNÝ SKOK PODL."); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("TEPLOTNÝ SKOK KOMO."); LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("TEPLOTNÝ SKOK CHLAD."); @@ -531,7 +544,9 @@ namespace Language_sk { LSTR MSG_ERR_MAXTEMP = _UxGT("Chyba: MAXTEMP"); LSTR MSG_ERR_MINTEMP = _UxGT("Chyba: MINTEMP"); LSTR MSG_HALTED = _UxGT("TLAČIAREŇ ZASTAVENÁ"); + LSTR MSG_PLEASE_WAIT = _UxGT("Čakajte prosím..."); LSTR MSG_PLEASE_RESET = _UxGT("Reštartuje ju"); + LSTR MSG_PREHEATING = _UxGT("Zahrievanie..."); LSTR MSG_HEATING = _UxGT("Ohrev..."); LSTR MSG_COOLING = _UxGT("Ochladzovanie..."); LSTR MSG_BED_HEATING = _UxGT("Ohrev podložky..."); @@ -570,35 +585,52 @@ namespace Language_sk { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Tepl. ochrana: VYP"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Tepl. ochrana: ZAP"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Vypr.čas nečinnosti"); + LSTR MSG_FAN_SPEED_FAULT = _UxGT("Chyba rýchl. vent."); LSTR MSG_CASE_LIGHT = _UxGT("Osvetlenie"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Jas svetla"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Nesprávna tlačiareň"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Nie je vložená karta."); + LSTR MSG_REMAINING_TIME = _UxGT("Zostávajúci čas"); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Prosím čakajte do reštartu. "); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Prosím zahrejte hotend."); + LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Vynulovať počítadlo"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Počet tlačí"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Dokončené"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Celkový čas"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Najdlhšia tlač"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Celkom vytlačené"); + LSTR MSG_COLORS_GET = _UxGT("Zvoliť farbu"); + LSTR MSG_COLORS_SELECT = _UxGT("Zvoliť farby"); + LSTR MSG_COLORS_APPLIED = _UxGT("Farby aplikované"); + LSTR MSG_COLORS_RED = _UxGT("Červená"); + LSTR MSG_COLORS_GREEN = _UxGT("Zelená"); + LSTR MSG_COLORS_BLUE = _UxGT("Modrá"); + LSTR MSG_UI_LANGUAGE = _UxGT("Jazyk rozhrania"); + LSTR MSG_SOUND_ENABLE = _UxGT("Povoliť zvuky"); + LSTR MSG_LOCKSCREEN = _UxGT("Uzamknúť obrazovku"); #else + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Žiadna karta"); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Prosím zahrejte"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Tlače"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Hotovo"); + LSTR MSG_REMAINING_TIME = _UxGT("Zostávajúci"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Čas"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Najdlhšia"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Vytlačené"); #endif + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Dokončené"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Teplota min"); LSTR MSG_INFO_MAX_TEMP = _UxGT("Teplota max"); LSTR MSG_INFO_PSU = _UxGT("Nap. zdroj"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Budenie motorov"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Motor %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Motor %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Motor %"); LSTR MSG_ERROR_TMC = _UxGT("CHYBA KOMUNIKÁ. TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Uložiť do EEPROM"); @@ -613,6 +645,7 @@ namespace Language_sk { LSTR MSG_RUNOUT_SENSOR = _UxGT("Senzor filamentu"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Vzd. mm fil. senz."); LSTR MSG_RUNOUT_ENABLE = _UxGT("Zapnúť senzor"); + LSTR MSG_FANCHECK = _UxGT("Kontrola rýchl."); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Parkovanie zlyhalo"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Kalibrácia zlyhala"); @@ -732,6 +765,10 @@ namespace Language_sk { LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Referencia Z"); LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Presúvam na pozíciu"); + LSTR MSG_XATC = _UxGT("Sprievodca X-Twist"); + LSTR MSG_XATC_DONE = _UxGT("Spriev. X-Twist dokonč.!"); + LSTR MSG_XATC_UPDATE_Z_OFFSET = _UxGT("Aktual. ofset sondy Z na "); + LSTR MSG_SOUND = _UxGT("Zvuk"); LSTR MSG_TOP_LEFT = _UxGT("Ľavý horný"); @@ -745,4 +782,6 @@ namespace Language_sk { LSTR MSG_SD_CARD = _UxGT("SD karta"); LSTR MSG_USB_DISK = _UxGT("USB disk"); + + LSTR MSG_HOST_SHUTDOWN = _UxGT("Vypnúť hosta"); } diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index cdb902aef069..744fb7e3e603 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -44,7 +44,7 @@ namespace Language_sv { LSTR MSG_MEDIA_INSERTED = _UxGT("Media Instatt"); LSTR MSG_MEDIA_REMOVED = _UxGT("Media Borttaget"); LSTR MSG_MEDIA_WAITING = _UxGT("Väntar på media"); - LSTR MSG_SD_INIT_FAIL = _UxGT("SD init misslyckades"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Media init misslyckades"); LSTR MSG_MEDIA_READ_ERROR = _UxGT("Media läsningsfel"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB enhet borttagen"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("USB start misslyckad"); @@ -298,45 +298,45 @@ namespace Language_sv { LSTR MSG_SELECT_E = _UxGT("Välj *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Ryck"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-Ryck"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-Ryck"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-Ryck"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-Ryck"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-Ryck"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-Ryck"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-Ryck"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-Ryck"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-Ryck"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT("-Ryck"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT("-Ryck"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT("-Ryck"); LSTR MSG_VE_JERK = _UxGT("Ve-Ryck"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Knutpunkt Avv"); LSTR MSG_VELOCITY = _UxGT("Hastighet"); - LSTR MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Vmax ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vmax ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vmax ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Vmax ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Vmax ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Vmax ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Vmax ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Vmax *"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VTrav Min"); LSTR MSG_ACCELERATION = _UxGT("Acceleration"); - LSTR MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Amax ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Amax ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Amax ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Amax ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Amax ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Amax ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Amax ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Amax ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Amax ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Amax ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Amax *"); LSTR MSG_A_RETRACT = _UxGT("A-Dra tillbaka"); LSTR MSG_A_TRAVEL = _UxGT("A-Färdas"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frekvens max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Flöde min"); LSTR MSG_STEPS_PER_MM = _UxGT("Steg/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" Steg/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" Steg/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" Steg/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" Steg/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" Steg/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" Steg/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" Steg/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" Steg/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" Steg/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" Steg/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" Steg/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" Steg/mm"); LSTR MSG_E_STEPS = _UxGT("E Steg/mm"); LSTR MSG_EN_STEPS = _UxGT("* Steg/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatur"); @@ -523,7 +523,7 @@ namespace Language_sv { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Ljus ljusstyrka"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("INKORREKT SKRIVARE"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Utskriftsantal"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Färdiga"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Total Utskriftstid"); @@ -541,12 +541,12 @@ namespace Language_sv { LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); LSTR MSG_INFO_PSU = _UxGT("PSU"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Driv Styrka"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); LSTR MSG_ERROR_TMC = _UxGT("TMC KOPPLNINGSFEL"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Skriv"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index 4c2bbfa0dc00..8a1864c96647 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -261,43 +261,43 @@ namespace Language_tr { LSTR MSG_ACC = _UxGT("İvme"); LSTR MSG_JERK = _UxGT("Sarsım"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-Sarsım"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-Sarsım"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-Sarsım"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-Sarsım"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-Sarsım"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-Sarsım"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-Sarsım"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-Sarsım"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-Sarsım"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT("-Sarsım"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT("-Sarsım"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT("-Sarsım"); LSTR MSG_VE_JERK = _UxGT("Ve-Sarsım"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Jonksiyon Sapması"); LSTR MSG_VELOCITY = _UxGT("Hız Vektörü"); - LSTR MSG_VMAX_A = _UxGT("HızVektör.max ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("HızVektör.max ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("HızVektör.max ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("HızVektör.max ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("HızVektör.max ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("HızVektör.max ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("HızVektör.max ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("HızVektör.max ") STR_A; + LSTR MSG_VMAX_B = _UxGT("HızVektör.max ") STR_B; + LSTR MSG_VMAX_C = _UxGT("HızVektör.max ") STR_C; + LSTR MSG_VMAX_I = _UxGT("HızVektör.max ") STR_I; + LSTR MSG_VMAX_J = _UxGT("HızVektör.max ") STR_J; + LSTR MSG_VMAX_K = _UxGT("HızVektör.max ") STR_K; + LSTR MSG_VMAX_E = _UxGT("HızVektör.max ") STR_E; LSTR MSG_VMAX_EN = _UxGT("HızVektör.max *"); LSTR MSG_VMIN = _UxGT("HızVektör.min"); LSTR MSG_VTRAV_MIN = _UxGT("HV.gezinme min"); LSTR MSG_ACCELERATION = _UxGT("Ivme"); - LSTR MSG_AMAX_A = _UxGT("Max. ivme ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Max. ivme ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Max. ivme ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Max. ivme ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Max. ivme ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Max. ivme ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Max. ivme ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Max. ivme ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Max. ivme ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Max. ivme ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Max. ivme ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Max. ivme ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Max. ivme ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Max. ivme ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Max. ivme *"); LSTR MSG_A_RETRACT = _UxGT("Ivme-geri çekme"); LSTR MSG_A_TRAVEL = _UxGT("Ivme-gezinme"); LSTR MSG_STEPS_PER_MM = _UxGT("Adım/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" adım/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" adım/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" adım/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" adım/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" adım/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" adım/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" adım/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" adım/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" adım/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" adım/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" adım/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" adım/mm"); LSTR MSG_E_STEPS = _UxGT("E adım/mm"); LSTR MSG_EN_STEPS = _UxGT("* adım/mm"); LSTR MSG_TEMPERATURE = _UxGT("Sıcaklık"); @@ -456,7 +456,7 @@ namespace Language_tr { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Aydınlatma Parlaklğı"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Yanlış Yazıcı"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Baskı Sayısı"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Tamamlanan"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Toplam Baskı Süresi"); @@ -474,12 +474,12 @@ namespace Language_tr { LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Sıc."); LSTR MSG_INFO_PSU = _UxGT("Güç Kaynağı"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Sürücü Gücü"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Sürücü %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" Sürücü %"); + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" Sürücü %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" Sürücü %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Sürücü %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Sürücü %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Sürücü %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Sürücü %"); LSTR MSG_ERROR_TMC = _UxGT("TMC BAĞLANTI HATASI"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Yaz"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index afba537008c7..7afc2e031c23 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -44,15 +44,15 @@ namespace Language_uk { LSTR MSG_MEDIA_INSERTED = _UxGT("SD-картка вставлена"); LSTR MSG_MEDIA_REMOVED = _UxGT("SD-картка видалена"); LSTR MSG_MEDIA_WAITING = _UxGT("Вставте SD-картку"); - #if LCD_WIDTH > 21 - LSTR MSG_SD_INIT_FAIL = _UxGT("Збій ініціалізації SD"); + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Збій ініціалізації SD"); #else - LSTR MSG_SD_INIT_FAIL = _UxGT("Збій ініціаліз. SD"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Збій ініціаліз. SD"); #endif LSTR MSG_MEDIA_READ_ERROR = _UxGT("Помилка зчитування"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB диск видалений"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Помилка USB диску"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Переповнення виклику"); LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Програмні кінцевики"); #else @@ -68,12 +68,10 @@ namespace Language_uk { LSTR MSG_DEBUG_MENU = _UxGT("Меню Debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Тест лінії прогр."); LSTR MSG_AUTO_HOME = _UxGT("Авто паркування"); + LSTR MSG_AUTO_HOME_A = _UxGT("Паркування @"); LSTR MSG_AUTO_HOME_X = _UxGT("Паркування X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Паркування Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Паркування Z"); - LSTR MSG_AUTO_HOME_I = _UxGT("Паркування ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Паркування ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Паркування ") LCD_STR_K; LSTR MSG_AUTO_Z_ALIGN = _UxGT("Авто Z-вирівнювання"); LSTR MSG_ITERATION = _UxGT("G34 Ітерація: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Зменьшення точності!"); @@ -83,27 +81,27 @@ namespace Language_uk { LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Наступна точка"); LSTR MSG_LEVEL_BED_DONE = _UxGT("Завершено!"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Висота спаду"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SET_HOME_OFFSETS = _UxGT("Встанов. зміщення дому"); LSTR MSG_HOME_OFFSET_X = _UxGT("Зміщення дому X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Зміщення дому Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Зміщення дому Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Зміщення дому ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Зміщення дому ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Зміщення дому ") LCD_STR_K; + LSTR MSG_HOME_OFFSET_I = _UxGT("Зміщення дому ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Зміщення дому ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Зміщення дому ") STR_K; #else LSTR MSG_SET_HOME_OFFSETS = _UxGT("Встан. зміщ. дому"); LSTR MSG_HOME_OFFSET_X = _UxGT("Зміщ. дому X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Зміщ. дому Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Зміщ. дому Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Зміщ. дому ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Зміщ. дому ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Зміщ. дому ") LCD_STR_K; + LSTR MSG_HOME_OFFSET_I = _UxGT("Зміщ. дому ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Зміщ. дому ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Зміщ. дому ") STR_K; #endif LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Зміщення прийняті"); LSTR MSG_SET_ORIGIN = _UxGT("Встановити нуль"); LSTR MSG_SELECT_ORIGIN = _UxGT("Оберіть нуль"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_LAST_VALUE_SP = _UxGT("Останнє значення "); #else LSTR MSG_LAST_VALUE_SP = _UxGT("Останнє знач. "); @@ -131,7 +129,7 @@ namespace Language_uk { LSTR MSG_CUTTER_FREQUENCY = _UxGT("Частота"); LSTR MSG_LASER_MENU = _UxGT("Керування лазером"); LSTR MSG_SPINDLE_MENU = _UxGT("Керування шпінделем"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_LASER_POWER = _UxGT("Потужність лазера"); LSTR MSG_SPINDLE_TOGGLE = _UxGT("Перемкн. шпіндель"); LSTR MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Перемкнути вакуум"); @@ -162,7 +160,7 @@ namespace Language_uk { LSTR MSG_BED_LEVELING = _UxGT("Вирівнювання столу"); LSTR MSG_LEVEL_BED = _UxGT("Вирівняти стіл"); LSTR MSG_BED_TRAMMING = _UxGT("Вирівняти кути"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Вгору до спрацюв. зонду"); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Кути в межах. Вирів.столу"); #else @@ -172,7 +170,7 @@ namespace Language_uk { LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Хороші точки: "); LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Остання Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Наступний кут"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MESH_EDITOR = _UxGT("Зміщення по Z"); #else LSTR MSG_MESH_EDITOR = _UxGT("Зміщення Z"); @@ -205,7 +203,7 @@ namespace Language_uk { LSTR MSG_UBL_TOOLS = _UxGT("Інструменти UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Налаштування UBL"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Точка нахилу"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_MANUAL_MESH = _UxGT("Ручне введення сітки"); LSTR MSG_UBL_BC_INSERT = _UxGT("Розмістити шайбу і вимір."); #else @@ -214,7 +212,7 @@ namespace Language_uk { #endif LSTR MSG_UBL_MESH_WIZARD = _UxGT("Майстер сіток UBL"); LSTR MSG_UBL_BC_INSERT2 = _UxGT("Вимірювання"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_BC_REMOVE = _UxGT("Видалити і виміряти стіл"); #else LSTR MSG_UBL_BC_REMOVE = _UxGT("Видали і вимір. стіл"); @@ -226,7 +224,7 @@ namespace Language_uk { LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" столу,") LCD_STR_DEGREE "C"; LSTR MSG_UBL_SET_TEMP_HOTEND = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE "C"; LSTR MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" сопла,") LCD_STR_DEGREE "C"; - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Редагувати свою сітку"); LSTR MSG_UBL_FINE_TUNE_MESH = _UxGT("Точне редагування сітки"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Будувати свою сітку"); @@ -256,7 +254,7 @@ namespace Language_uk { LSTR MSG_UBL_CONTINUE_MESH = _UxGT("Продовжити сітку"); LSTR MSG_UBL_MESH_LEVELING = _UxGT("Вирівнювання сітки"); LSTR MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-точкове вирівн."); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_GRID_MESH_LEVELING = _UxGT("Вирівнювання растру"); #else LSTR MSG_UBL_GRID_MESH_LEVELING = _UxGT("Вирівнюв. растру"); @@ -269,7 +267,7 @@ namespace Language_uk { LSTR MSG_UBL_OUTPUT_MAP_CSV = _UxGT("Вивести в CSV"); LSTR MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Зберегти зовні"); LSTR MSG_UBL_INFO_UBL = _UxGT("Інформація по UBL"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_FILLIN_AMOUNT = _UxGT("Обсяг заповнюв."); #else LSTR MSG_UBL_FILLIN_AMOUNT = _UxGT("Обсяг заповн."); @@ -279,7 +277,7 @@ namespace Language_uk { LSTR MSG_UBL_FILLIN_MESH = _UxGT("Заповнити сітку"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Анулювати все"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Анулювати найближчу"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Точно налаштувати все"); LSTR MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Точно налашт.найближчу"); #else @@ -308,7 +306,7 @@ namespace Language_uk { LSTR MSG_LED_CONTROL = _UxGT("Керування світлом"); LSTR MSG_LEDS = _UxGT("Підсвітка"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_LED_PRESETS = _UxGT("Передустановки світла"); #else LSTR MSG_LED_PRESETS = _UxGT("Передустан. світла"); @@ -324,7 +322,7 @@ namespace Language_uk { LSTR MSG_SET_LEDS_DEFAULT = _UxGT("За умовчанням"); LSTR MSG_LED_CHANNEL_N = _UxGT("Канал ="); LSTR MSG_LEDS2 = _UxGT("Світло #2"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_NEO2_PRESETS = _UxGT("Передустановка світла #2"); #else LSTR MSG_NEO2_PRESETS = _UxGT("Передуст. світла #2"); @@ -342,9 +340,9 @@ namespace Language_uk { LSTR MSG_MOVE_X = _UxGT("Рух по X"); LSTR MSG_MOVE_Y = _UxGT("Рух по Y"); LSTR MSG_MOVE_Z = _UxGT("Рух по Z"); - LSTR MSG_MOVE_I = _UxGT("Рух по ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Рух по ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Рух по ") LCD_STR_K; + LSTR MSG_MOVE_I = _UxGT("Рух по ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Рух по ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Рух по ") STR_K; LSTR MSG_MOVE_E = _UxGT("Екструдер"); LSTR MSG_MOVE_EN = _UxGT("Екструдер *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Сопло дуже холодне"); @@ -361,7 +359,7 @@ namespace Language_uk { LSTR MSG_NOZZLE_STANDBY = _UxGT("Сопло очікує"); LSTR MSG_BED = _UxGT("Стіл, ") LCD_STR_DEGREE "C"; LSTR MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_COOLER = _UxGT("Охолодження лазеру"); LSTR MSG_COOLER_TOGGLE = _UxGT("Перемк. охолодж."); #else @@ -372,7 +370,7 @@ namespace Language_uk { LSTR MSG_LASER = _UxGT("Лазер"); LSTR MSG_FAN_SPEED = _UxGT("Швидк. вент."); LSTR MSG_FAN_SPEED_N = _UxGT("Швидк. вент. ~"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_STORED_FAN_N = _UxGT("Збереж.швидк.вент. ~"); LSTR MSG_EXTRA_FAN_SPEED_N = _UxGT("Дод. швидк. вент. ~"); #else @@ -406,53 +404,53 @@ namespace Language_uk { LSTR MSG_SELECT_E = _UxGT("Вибрати *"); LSTR MSG_ACC = _UxGT("Прискорорення"); LSTR MSG_JERK = _UxGT("Ривок"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-ривок"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-ривок"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-ривок"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-ривок"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-ривок"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-ривок"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-ривок"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-ривок"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-ривок"); + LSTR MSG_VI_JERK = _UxGT("V") STR_I _UxGT("-ривок"); + LSTR MSG_VJ_JERK = _UxGT("V") STR_J _UxGT("-ривок"); + LSTR MSG_VK_JERK = _UxGT("V") STR_K _UxGT("-ривок"); LSTR MSG_VE_JERK = _UxGT("Ve-ривок"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_JUNCTION_DEVIATION = _UxGT("Відхилення вузла"); #else LSTR MSG_JUNCTION_DEVIATION = _UxGT("Відхил.вузла"); #endif LSTR MSG_VELOCITY = _UxGT("Швидкість, мм/с"); - LSTR MSG_VMAX_A = _UxGT("Швидк.макс ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Швидк.макс ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Швидк.макс ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Швидк.макс ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Швидк.макс ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Швидк.макс ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Швидк.макс ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Швидк.макс ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Швидк.макс ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Швидк.макс ") STR_C; + LSTR MSG_VMAX_I = _UxGT("Швидк.макс ") STR_I; + LSTR MSG_VMAX_J = _UxGT("Швидк.макс ") STR_J; + LSTR MSG_VMAX_K = _UxGT("Швидк.макс ") STR_K; + LSTR MSG_VMAX_E = _UxGT("Швидк.макс ") STR_E; LSTR MSG_VMAX_EN = _UxGT("Швидк.макс *"); LSTR MSG_VMIN = _UxGT("Швидк. мін"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_VTRAV_MIN = _UxGT("Переміщення мін"); #else LSTR MSG_VTRAV_MIN = _UxGT("Переміщ. мін"); #endif LSTR MSG_ACCELERATION = _UxGT("Прискорення, мм/с2"); - LSTR MSG_AMAX_A = _UxGT("Приск.макс ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Приск.макс ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Приск.макс ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Приск.макс ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Приск.макс ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Приск.макс ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Приск.макс ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Приск.макс ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Приск.макс ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Приск.макс ") STR_C; + LSTR MSG_AMAX_I = _UxGT("Приск.макс ") STR_I; + LSTR MSG_AMAX_J = _UxGT("Приск.макс ") STR_J; + LSTR MSG_AMAX_K = _UxGT("Приск.макс ") STR_K; + LSTR MSG_AMAX_E = _UxGT("Приск.макс ") STR_E; LSTR MSG_AMAX_EN = _UxGT("Приск.макс *"); LSTR MSG_A_RETRACT = _UxGT("Приск.втягув."); LSTR MSG_A_TRAVEL = _UxGT("Приск.переміщ."); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Частота макс."); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Подача мін."); LSTR MSG_STEPS_PER_MM = _UxGT("Кроків на мм"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" кроків/мм"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" кроків/мм"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" кроків/мм"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" кроків/мм"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" кроків/мм"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" кроків/мм"); + LSTR MSG_A_STEPS = STR_A _UxGT(" кроків/мм"); + LSTR MSG_B_STEPS = STR_B _UxGT(" кроків/мм"); + LSTR MSG_C_STEPS = STR_C _UxGT(" кроків/мм"); + LSTR MSG_I_STEPS = STR_I _UxGT(" кроків/мм"); + LSTR MSG_J_STEPS = STR_J _UxGT(" кроків/мм"); + LSTR MSG_K_STEPS = STR_K _UxGT(" кроків/мм"); LSTR MSG_E_STEPS = _UxGT("E кроків/мм"); LSTR MSG_EN_STEPS = _UxGT("* кроків/мм"); LSTR MSG_TEMPERATURE = _UxGT("Температура"); @@ -471,7 +469,7 @@ namespace Language_uk { LSTR MSG_STORE_EEPROM = _UxGT("Зберегти в EEPROM"); LSTR MSG_LOAD_EEPROM = _UxGT("Зчитати з EEPROM"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("На базові параметри"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_INIT_EEPROM = _UxGT("Ініціалізація EEPROM"); #else LSTR MSG_INIT_EEPROM = _UxGT("Ініціаліз. EEPROM"); @@ -525,7 +523,7 @@ namespace Language_uk { LSTR MSG_NO_MOVE = _UxGT("Немає руху."); LSTR MSG_KILLED = _UxGT("ПЕРЕРВАНО. "); LSTR MSG_STOPPED = _UxGT("ЗУПИНЕНО. "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_CONTROL_RETRACT = _UxGT("Втягування, мм"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Зміна втягув.,мм"); LSTR MSG_CONTROL_RETRACT_RECOVER = _UxGT("Повернення, мм"); @@ -547,7 +545,7 @@ namespace Language_uk { LSTR MSG_FILAMENT_PURGE_LENGTH = _UxGT("Очистити довжину"); LSTR MSG_TOOL_CHANGE = _UxGT("Зміна сопла"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Підняти по Z"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Початк.швидкість"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Швидкість втягув."); #else @@ -556,7 +554,7 @@ namespace Language_uk { #endif LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Паркувати голову"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Відновити швидкість"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Оберти вентилятора"); LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Час вентилятора"); #else @@ -610,9 +608,9 @@ namespace Language_uk { LSTR MSG_BABYSTEP_X = _UxGT("Мікрокрок X"); LSTR MSG_BABYSTEP_Y = _UxGT("Мікрокрок Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Мікрокрок Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Мікрокрок ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Мікрокрок ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Мікрокрок ") LCD_STR_K; + LSTR MSG_BABYSTEP_I = _UxGT("Мікрокрок ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Мікрокрок ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Мікрокрок ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Сумарно"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Кінцевик спрацював"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Збій нагріву"); @@ -621,7 +619,7 @@ namespace Language_uk { LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("ВИТІК ТЕПЛА СТОЛУ"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("ВИТІК ТЕПЛА КАМЕРИ"); LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("ВИТІК ОХОЛОДЖЕННЯ"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_COOLING_FAILED = _UxGT("ОХОЛОДЖЕННЯ НЕ ВДАЛОСЬ"); #else LSTR MSG_COOLING_FAILED = _UxGT("ОХОЛОДЖ. НЕ ВДАЛОСЬ"); @@ -638,7 +636,7 @@ namespace Language_uk { LSTR MSG_BED_HEATING = _UxGT("Нагрів столу..."); LSTR MSG_PROBE_HEATING = _UxGT("Нагрів зонду..."); LSTR MSG_CHAMBER_HEATING = _UxGT("Нагрів камери..."); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_BED_COOLING = _UxGT("Охолодження столу..."); LSTR MSG_PROBE_COOLING = _UxGT("Охолодження зонду..."); LSTR MSG_CHAMBER_COOLING = _UxGT("Охолодження камери..."); @@ -665,7 +663,7 @@ namespace Language_uk { LSTR MSG_INFO_MENU = _UxGT("Про принтер"); LSTR MSG_INFO_PRINTER_MENU = _UxGT("Дані принтера"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_3POINT_LEVELING = _UxGT("3-точкове вирівнювання"); LSTR MSG_LINEAR_LEVELING = _UxGT("Лінійне вирівнювання"); LSTR MSG_BILINEAR_LEVELING = _UxGT("Білінійне вирівнювання"); @@ -676,7 +674,7 @@ namespace Language_uk { #endif LSTR MSG_UBL_LEVELING = _UxGT("UBL"); LSTR MSG_MESH_LEVELING = _UxGT("Вирівнювання сітки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MESH_DONE = _UxGT("Зондування сітки виконано"); #else LSTR MSG_MESH_DONE = _UxGT("Зондування виконано"); @@ -688,7 +686,7 @@ namespace Language_uk { LSTR MSG_INFO_EXTRUDERS = _UxGT("Екструдери"); LSTR MSG_INFO_BAUDRATE = _UxGT("Бод"); LSTR MSG_INFO_PROTOCOL = _UxGT("Протокол"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Контроль витіку ") LCD_STR_THERMOMETER _UxGT(" Вимк"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Контроль витіку ") LCD_STR_THERMOMETER _UxGT(" Увімк"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Час простою хотенду"); @@ -704,7 +702,7 @@ namespace Language_uk { LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Завершено"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Екструдовано"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Кількість друків"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Весь час друку"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Найдовший час"); @@ -718,12 +716,12 @@ namespace Language_uk { LSTR MSG_INFO_MAX_TEMP = _UxGT("Макс. ") LCD_STR_THERMOMETER; LSTR MSG_INFO_PSU = _UxGT("Блок жив-ня"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Сила мотору"); - LSTR MSG_DAC_PERCENT_A = _UxGT("Драйвер ") LCD_STR_A _UxGT(", %"); - LSTR MSG_DAC_PERCENT_B = _UxGT("Драйвер ") LCD_STR_B _UxGT(", %"); - LSTR MSG_DAC_PERCENT_C = _UxGT("Драйвер ") LCD_STR_C _UxGT(", %"); - LSTR MSG_DAC_PERCENT_I = _UxGT("Драйвер ") LCD_STR_I _UxGT(", %"); - LSTR MSG_DAC_PERCENT_J = _UxGT("Драйвер ") LCD_STR_J _UxGT(", %"); - LSTR MSG_DAC_PERCENT_K = _UxGT("Драйвер ") LCD_STR_K _UxGT(", %"); + LSTR MSG_DAC_PERCENT_A = _UxGT("Драйвер ") STR_A _UxGT(", %"); + LSTR MSG_DAC_PERCENT_B = _UxGT("Драйвер ") STR_B _UxGT(", %"); + LSTR MSG_DAC_PERCENT_C = _UxGT("Драйвер ") STR_C _UxGT(", %"); + LSTR MSG_DAC_PERCENT_I = _UxGT("Драйвер ") STR_I _UxGT(", %"); + LSTR MSG_DAC_PERCENT_J = _UxGT("Драйвер ") STR_J _UxGT(", %"); + LSTR MSG_DAC_PERCENT_K = _UxGT("Драйвер ") STR_K _UxGT(", %"); LSTR MSG_DAC_PERCENT_E = _UxGT("Драйвер E, %"); LSTR MSG_ERROR_TMC = _UxGT("ЗБІЙ ЗВ'ЯЗКУ З TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Запис ЦАП у EEPROM"); @@ -731,7 +729,7 @@ namespace Language_uk { LSTR MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("ЗУПИНКА ДРУКУ"); LSTR MSG_FILAMENT_CHANGE_HEADER_LOAD = _UxGT("ЗАВАНТАЖИТИ ПРУТОК"); LSTR MSG_FILAMENT_CHANGE_HEADER_UNLOAD = _UxGT("ВИВАНТАЖИТИ ПРУТОК"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("ПАРАМЕТРИ ПРОДОВЖЕННЯ:"); #else LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("ПАРАМ.ПРОДОВЖЕННЯ:"); @@ -739,7 +737,7 @@ namespace Language_uk { LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Видавити ще"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Відновити друк"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Сопло: "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_RUNOUT_SENSOR = _UxGT("Датчик закінчення прутка"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Відстань закінч.,мм"); #else @@ -757,7 +755,7 @@ namespace Language_uk { LSTR MSG_MMU2_RESUMING = _UxGT("MMU Продовження..."); LSTR MSG_MMU2_LOAD_FILAMENT = _UxGT("MMU Завантажити"); LSTR MSG_MMU2_LOAD_ALL = _UxGT("MMU Завантажити все"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Завантажити в сопло"); #else LSTR MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Завант. в сопло"); @@ -774,7 +772,7 @@ namespace Language_uk { LSTR MSG_MMU2_RESETTING = _UxGT("MMU Перезапуск..."); LSTR MSG_MMU2_EJECT_RECOVER = _UxGT("Видаліть, натисніть"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MIX = _UxGT("Змішування"); #else LSTR MSG_MIX = _UxGT("Змішув."); @@ -783,7 +781,7 @@ namespace Language_uk { LSTR MSG_MIXER = _UxGT("Змішувач"); LSTR MSG_GRADIENT = _UxGT("Градієнт"); LSTR MSG_FULL_GRADIENT = _UxGT("Повний градієнт"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_TOGGLE_MIX = _UxGT("Переключити змішування"); #else LSTR MSG_TOGGLE_MIX = _UxGT("Переключ.змішування"); @@ -792,7 +790,7 @@ namespace Language_uk { LSTR MSG_GRADIENT_MIX = _UxGT("Градієнт змішування"); LSTR MSG_REVERSE_GRADIENT = _UxGT("Змінити градієнт"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_ACTIVE_VTOOL = _UxGT("Активація В-інструменту"); LSTR MSG_GRADIENT_ALIAS = _UxGT("Псевдонім В-інструменту"); LSTR MSG_RESET_VTOOLS = _UxGT("Зкидання В-інструментів"); @@ -815,7 +813,7 @@ namespace Language_uk { LSTR MSG_MAZE = _UxGT("Лабіринт"); LSTR MSG_BAD_PAGE = _UxGT("Погана сторінка"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_BAD_PAGE_SPEED = _UxGT("Погана швидкість стор."); #else LSTR MSG_BAD_PAGE_SPEED = _UxGT("Погана швидк. стор."); @@ -888,7 +886,7 @@ namespace Language_uk { LSTR MSG_REHEATING = _UxGT("Нагрівання..."); LSTR MSG_PROBE_WIZARD = _UxGT("Майстер Z-зонда"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Зондув. контрольної точки Z"); LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Рух до точки зондування"); #else diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index ae0babbf8b34..879ccdeae7c6 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -228,43 +228,43 @@ namespace Language_vi { LSTR MSG_SELECT_E = _UxGT("Lựa *"); LSTR MSG_ACC = _UxGT("Tăng Tốc"); LSTR MSG_JERK = _UxGT("Giật"); - LSTR MSG_VA_JERK = _UxGT("Giật-V") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("Giật-V") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("Giật-V") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("Giật-V") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("Giật-V") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("Giật-V") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("Giật-V") STR_A; + LSTR MSG_VB_JERK = _UxGT("Giật-V") STR_B; + LSTR MSG_VC_JERK = _UxGT("Giật-V") STR_C; + LSTR MSG_VI_JERK = _UxGT("Giật-V") STR_I; + LSTR MSG_VJ_JERK = _UxGT("Giật-V") STR_J; + LSTR MSG_VK_JERK = _UxGT("Giật-V") STR_K; LSTR MSG_VE_JERK = _UxGT("Giật-Ve"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Độ Lệch Chỗ Giao"); // Junction Dev LSTR MSG_VELOCITY = _UxGT("Vận tốc"); // velocity - LSTR MSG_VMAX_A = _UxGT("Vđa") LCD_STR_A; // Vmax - LSTR MSG_VMAX_B = _UxGT("Vđa") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vđa") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vđa") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vđa") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vđa") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vđa") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Vđa") STR_A; // Vmax + LSTR MSG_VMAX_B = _UxGT("Vđa") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vđa") STR_C; + LSTR MSG_VMAX_I = _UxGT("Vđa") STR_I; + LSTR MSG_VMAX_J = _UxGT("Vđa") STR_J; + LSTR MSG_VMAX_K = _UxGT("Vđa") STR_K; + LSTR MSG_VMAX_E = _UxGT("Vđa") STR_E; LSTR MSG_VMAX_EN = _UxGT("Vđa *"); LSTR MSG_VMIN = _UxGT("Vthiểu"); // Vmin LSTR MSG_VTRAV_MIN = _UxGT("Vchuyển thiểu"); // VTrav min LSTR MSG_ACCELERATION = _UxGT("Sự tăng tốc"); // Acceleration - LSTR MSG_AMAX_A = _UxGT("Tăng tốc ca") LCD_STR_A; // Amax - LSTR MSG_AMAX_B = _UxGT("Tăng tốc ca") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Tăng tốc ca") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Tăng tốc ca") LCD_STR_I; // Amax - LSTR MSG_AMAX_J = _UxGT("Tăng tốc ca") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Tăng tốc ca") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Tăng tốc ca") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Tăng tốc ca") STR_A; // Amax + LSTR MSG_AMAX_B = _UxGT("Tăng tốc ca") STR_B; + LSTR MSG_AMAX_C = _UxGT("Tăng tốc ca") STR_C; + LSTR MSG_AMAX_I = _UxGT("Tăng tốc ca") STR_I; // Amax + LSTR MSG_AMAX_J = _UxGT("Tăng tốc ca") STR_J; + LSTR MSG_AMAX_K = _UxGT("Tăng tốc ca") STR_K; + LSTR MSG_AMAX_E = _UxGT("Tăng tốc ca") STR_E; LSTR MSG_AMAX_EN = _UxGT("Tăng tốc ca *"); LSTR MSG_A_RETRACT = _UxGT("TT-Rút"); // A-retract LSTR MSG_A_TRAVEL = _UxGT("TT-Chuyển"); // A-travel LSTR MSG_STEPS_PER_MM = _UxGT("Bước/mm"); // Steps - LSTR MSG_A_STEPS = _UxGT("Bước") LCD_STR_A _UxGT("/mm"); // Steps/mm - LSTR MSG_B_STEPS = _UxGT("Bước") LCD_STR_B _UxGT("/mm"); - LSTR MSG_C_STEPS = _UxGT("Bước") LCD_STR_C _UxGT("/mm"); - LSTR MSG_I_STEPS = _UxGT("Bước") LCD_STR_I _UxGT("/mm"); // Steps/mm - LSTR MSG_J_STEPS = _UxGT("Bước") LCD_STR_J _UxGT("/mm"); - LSTR MSG_K_STEPS = _UxGT("Bước") LCD_STR_K _UxGT("/mm"); + LSTR MSG_A_STEPS = _UxGT("Bước") STR_A _UxGT("/mm"); // Steps/mm + LSTR MSG_B_STEPS = _UxGT("Bước") STR_B _UxGT("/mm"); + LSTR MSG_C_STEPS = _UxGT("Bước") STR_C _UxGT("/mm"); + LSTR MSG_I_STEPS = _UxGT("Bước") STR_I _UxGT("/mm"); // Steps/mm + LSTR MSG_J_STEPS = _UxGT("Bước") STR_J _UxGT("/mm"); + LSTR MSG_K_STEPS = _UxGT("Bước") STR_K _UxGT("/mm"); LSTR MSG_E_STEPS = _UxGT("BướcE/mm"); LSTR MSG_EN_STEPS = _UxGT("Bước */mm"); LSTR MSG_TEMPERATURE = _UxGT("Nhiệt độ"); // Temperature @@ -383,7 +383,7 @@ namespace Language_vi { LSTR MSG_INFO_PROTOCOL = _UxGT("Giao Thức"); // Protocol LSTR MSG_CASE_LIGHT = _UxGT("Đèn Khuông"); // Case light LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Độ Sáng"); // Light Brightness - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Số In"); // Print Count LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Đã hoàn thành"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tổng số thời gian in"); // Total print time @@ -400,12 +400,12 @@ namespace Language_vi { LSTR MSG_INFO_MAX_TEMP = _UxGT("Nhiệt độ tối đa"); // Max temp LSTR MSG_INFO_PSU = _UxGT("Bộ nguồn"); // PSU LSTR MSG_DRIVE_STRENGTH = _UxGT("Sức mạnh ổ đĩa"); // Drive Strength - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" % trình điều khiển"); // X Driver % - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" % trình điều khiển"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" % trình điều khiển"); // X Driver % + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" % trình điều khiển"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" % trình điều khiển"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" % trình điều khiển"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" % trình điều khiển"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" % trình điều khiển"); LSTR MSG_DAC_PERCENT_E = _UxGT("E % trình điều khiển"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Ghi DAC EEPROM"); // DAC EEPROM Write LSTR MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("In tạm dừng"); // PRINT PAUSED diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index d61634e431e1..7f0ca874d61e 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -267,45 +267,45 @@ namespace Language_zh_CN { LSTR MSG_SELECT_E = _UxGT("选择 *"); LSTR MSG_ACC = _UxGT("加速度"); // "Accel" acceleration LSTR MSG_JERK = _UxGT("抖动速率"); // "Jerk" - LSTR MSG_VA_JERK = _UxGT("轴抖动速率") LCD_STR_A; // "Va-jerk" - LSTR MSG_VB_JERK = _UxGT("轴抖动速率") LCD_STR_B; // "Vb-jerk" - LSTR MSG_VC_JERK = _UxGT("轴抖动速率") LCD_STR_C; // "Vc-jerk" - LSTR MSG_VI_JERK = _UxGT("轴抖动速率") LCD_STR_I; // "Vi-jerk" - LSTR MSG_VJ_JERK = _UxGT("轴抖动速率") LCD_STR_J; // "Vj-jerk" - LSTR MSG_VK_JERK = _UxGT("轴抖动速率") LCD_STR_K; // "Vk-jerk" + LSTR MSG_VA_JERK = _UxGT("轴抖动速率") STR_A; // "Va-jerk" + LSTR MSG_VB_JERK = _UxGT("轴抖动速率") STR_B; // "Vb-jerk" + LSTR MSG_VC_JERK = _UxGT("轴抖动速率") STR_C; // "Vc-jerk" + LSTR MSG_VI_JERK = _UxGT("轴抖动速率") STR_I; // "Vi-jerk" + LSTR MSG_VJ_JERK = _UxGT("轴抖动速率") STR_J; // "Vj-jerk" + LSTR MSG_VK_JERK = _UxGT("轴抖动速率") STR_K; // "Vk-jerk" LSTR MSG_VE_JERK = _UxGT("挤出机抖动速率"); // "Ve-jerk" LSTR MSG_JUNCTION_DEVIATION = _UxGT("接点差"); LSTR MSG_VELOCITY = _UxGT("速度"); // "Velocity" - LSTR MSG_VMAX_A = _UxGT("最大进料速率") LCD_STR_A; // "Vmax " max_feedrate_mm_s - LSTR MSG_VMAX_B = _UxGT("最大进料速率") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("最大进料速率") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("最大进料速率") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("最大进料速率") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("最大进料速率") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("最大进料速率") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("最大进料速率") STR_A; // "Vmax " max_feedrate_mm_s + LSTR MSG_VMAX_B = _UxGT("最大进料速率") STR_B; + LSTR MSG_VMAX_C = _UxGT("最大进料速率") STR_C; + LSTR MSG_VMAX_I = _UxGT("最大进料速率") STR_I; + LSTR MSG_VMAX_J = _UxGT("最大进料速率") STR_J; + LSTR MSG_VMAX_K = _UxGT("最大进料速率") STR_K; + LSTR MSG_VMAX_E = _UxGT("最大进料速率") STR_E; LSTR MSG_VMAX_EN = _UxGT("最大进料速率 *"); LSTR MSG_VMIN = _UxGT("最小进料速率"); // "Vmin" min_feedrate_mm_s LSTR MSG_VTRAV_MIN = _UxGT("最小移动速率"); // "VTrav min" min_travel_feedrate_mm_s, (target) speed of the move LSTR MSG_ACCELERATION = _UxGT("加速度"); // "Acceleration" - LSTR MSG_AMAX_A = _UxGT("最大打印加速度") LCD_STR_A; // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves - LSTR MSG_AMAX_B = _UxGT("最大打印加速度") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("最大打印加速度") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("最大打印加速度") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("最大打印加速度") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("最大打印加速度") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("最大打印加速度") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("最大打印加速度") STR_A; // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves + LSTR MSG_AMAX_B = _UxGT("最大打印加速度") STR_B; + LSTR MSG_AMAX_C = _UxGT("最大打印加速度") STR_C; + LSTR MSG_AMAX_I = _UxGT("最大打印加速度") STR_I; + LSTR MSG_AMAX_J = _UxGT("最大打印加速度") STR_J; + LSTR MSG_AMAX_K = _UxGT("最大打印加速度") STR_K; + LSTR MSG_AMAX_E = _UxGT("最大打印加速度") STR_E; LSTR MSG_AMAX_EN = _UxGT("最大打印加速度 *"); LSTR MSG_A_RETRACT = _UxGT("收进加速度"); // "A-retract" retract_acceleration, E acceleration in mm/s^2 for retracts LSTR MSG_A_TRAVEL = _UxGT("非打印移动加速度"); // "A-travel" travel_acceleration, X, Y, Z acceleration in mm/s^2 for travel (non printing) moves LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("频率最大"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("进给速度"); LSTR MSG_STEPS_PER_MM = _UxGT("轴步数/mm"); // "Steps/mm" axis_steps_per_mm, axis steps-per-unit G92 - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" 步数/mm"); // "Asteps/mm" - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" 步数/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" 步数/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" 步数/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" 步数/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" 步数/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" 步数/mm"); // "Asteps/mm" + LSTR MSG_B_STEPS = STR_B _UxGT(" 步数/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" 步数/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" 步数/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" 步数/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" 步数/mm"); LSTR MSG_E_STEPS = _UxGT("E 步数/mm"); // "Esteps/mm" LSTR MSG_EN_STEPS = _UxGT("* 步数/mm"); LSTR MSG_TEMPERATURE = _UxGT("温度"); // "Temperature" @@ -489,7 +489,7 @@ namespace Language_zh_CN { LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("打印机不正确"); // "The printer is incorrect" - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("打印计数"); // "Print Count" LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("完成了"); // "Completed" LSTR MSG_INFO_PRINT_TIME = _UxGT("总打印时间"); // "Total print time" @@ -507,12 +507,12 @@ namespace Language_zh_CN { LSTR MSG_INFO_MAX_TEMP = _UxGT("最高温度"); // "Max Temp" LSTR MSG_INFO_PSU = _UxGT("电源供应"); // "Power Supply" LSTR MSG_DRIVE_STRENGTH = _UxGT("驱动力度"); // "Drive Strength" - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" 驱动 %"); // "X Driver %" - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" 驱动 %"); + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" 驱动 %"); // "X Driver %" + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" 驱动 %"); + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" 驱动 %"); + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" 驱动 %"); + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" 驱动 %"); + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" 驱动 %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E 驱动 %"); // "E Driver %" LSTR MSG_ERROR_TMC = _UxGT("TMC 连接错误"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("保存驱动设置"); // "DAC EEPROM Write" diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 7680721b00e0..6c91cc1fec25 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -252,43 +252,43 @@ namespace Language_zh_TW { LSTR MSG_SELECT_E = _UxGT("選擇 *"); LSTR MSG_ACC = _UxGT("加速度"); // "Accel" acceleration LSTR MSG_JERK = _UxGT("抖動速率"); // "Jerk" - LSTR MSG_VA_JERK = _UxGT("軸抖動速率") LCD_STR_A; // "Va-jerk" - LSTR MSG_VB_JERK = _UxGT("軸抖動速率") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("軸抖動速率") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("軸抖動速率") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("軸抖動速率") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("軸抖動速率") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("軸抖動速率") STR_A; // "Va-jerk" + LSTR MSG_VB_JERK = _UxGT("軸抖動速率") STR_B; + LSTR MSG_VC_JERK = _UxGT("軸抖動速率") STR_C; + LSTR MSG_VI_JERK = _UxGT("軸抖動速率") STR_I; + LSTR MSG_VJ_JERK = _UxGT("軸抖動速率") STR_J; + LSTR MSG_VK_JERK = _UxGT("軸抖動速率") STR_K; LSTR MSG_VE_JERK = _UxGT("擠出機抖動速率"); LSTR MSG_VELOCITY = _UxGT("速度"); // "Velocity" - LSTR MSG_VMAX_A = _UxGT("最大進料速率") LCD_STR_A; // "Vmax " max_feedrate_mm_s - LSTR MSG_VMAX_B = _UxGT("最大進料速率") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("最大進料速率") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("最大進料速率") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("最大進料速率") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("最大進料速率") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("最大進料速率") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("最大進料速率") STR_A; // "Vmax " max_feedrate_mm_s + LSTR MSG_VMAX_B = _UxGT("最大進料速率") STR_B; + LSTR MSG_VMAX_C = _UxGT("最大進料速率") STR_C; + LSTR MSG_VMAX_I = _UxGT("最大進料速率") STR_I; + LSTR MSG_VMAX_J = _UxGT("最大進料速率") STR_J; + LSTR MSG_VMAX_K = _UxGT("最大進料速率") STR_K; + LSTR MSG_VMAX_E = _UxGT("最大進料速率") STR_E; LSTR MSG_VMAX_EN = _UxGT("最大進料速率 *"); // "Vmax " max_feedrate_mm_s LSTR MSG_VMIN = _UxGT("最小進料速率"); // "Vmin" min_feedrate_mm_s LSTR MSG_VTRAV_MIN = _UxGT("最小移動速率"); // "VTrav min" min_travel_feedrate_mm_s, (target) speed of the move LSTR MSG_ACCELERATION = _UxGT("加速度"); // "Acceleration" - LSTR MSG_AMAX_A = _UxGT("最大列印加速度") LCD_STR_A; // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves - LSTR MSG_AMAX_B = _UxGT("最大列印加速度") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("最大列印加速度") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("最大列印加速度") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("最大列印加速度") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("最大列印加速度") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("最大列印加速度") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("最大列印加速度") STR_A; // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves + LSTR MSG_AMAX_B = _UxGT("最大列印加速度") STR_B; + LSTR MSG_AMAX_C = _UxGT("最大列印加速度") STR_C; + LSTR MSG_AMAX_I = _UxGT("最大列印加速度") STR_I; + LSTR MSG_AMAX_J = _UxGT("最大列印加速度") STR_J; + LSTR MSG_AMAX_K = _UxGT("最大列印加速度") STR_K; + LSTR MSG_AMAX_E = _UxGT("最大列印加速度") STR_E; LSTR MSG_AMAX_EN = _UxGT("最大列印加速度 *"); // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves LSTR MSG_A_RETRACT = _UxGT("回縮加速度"); // "A-retract" retract_acceleration, E acceleration in mm/s^2 for retracts LSTR MSG_A_TRAVEL = _UxGT("非列印移動加速度"); // "A-travel" travel_acceleration, X, Y, Z acceleration in mm/s^2 for travel (non printing) moves LSTR MSG_STEPS_PER_MM = _UxGT("軸步數/mm"); // "Steps/mm" axis_steps_per_mm, axis steps-per-unit G92 - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" 軸步數/mm"); // "Asteps/mm" axis_steps_per_mm, axis steps-per-unit G92 - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" 軸步數/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" 軸步數/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" 軸步數/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" 軸步數/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" 軸步數/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" 軸步數/mm"); // "Asteps/mm" axis_steps_per_mm, axis steps-per-unit G92 + LSTR MSG_B_STEPS = STR_B _UxGT(" 軸步數/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" 軸步數/mm"); + LSTR MSG_I_STEPS = STR_I _UxGT(" 軸步數/mm"); + LSTR MSG_J_STEPS = STR_J _UxGT(" 軸步數/mm"); + LSTR MSG_K_STEPS = STR_K _UxGT(" 軸步數/mm"); LSTR MSG_E_STEPS = _UxGT("擠出機步數/mm"); // "Esteps/mm" LSTR MSG_EN_STEPS = _UxGT("擠出機~步數/mm"); LSTR MSG_TEMPERATURE = _UxGT("溫度"); // "Temperature" @@ -437,7 +437,7 @@ namespace Language_zh_TW { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("燈亮度"); // "Light BRIGHTNESS" LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("打印機不正確"); // "The printer is incorrect" - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("列印計數"); // "Print Count" LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("已完成"); // "Completed" LSTR MSG_INFO_PRINT_TIME = _UxGT("總列印時間"); // "Total print time" @@ -455,12 +455,12 @@ namespace Language_zh_TW { LSTR MSG_INFO_MAX_TEMP = _UxGT("最高溫度"); // "Max Temp" LSTR MSG_INFO_PSU = _UxGT("電源供應"); // "Power Supply" LSTR MSG_DRIVE_STRENGTH = _UxGT("驅動力度"); // "Drive Strength" - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" 驅動 %"); // X Driver % - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" 驅動 %"); // Y Driver % - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" 驅動 %"); // Z Driver % - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" 驅動 %"); // I Driver % - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" 驅動 %"); // J Driver % - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" 驅動 %"); // K Driver % + LSTR MSG_DAC_PERCENT_A = STR_A _UxGT(" 驅動 %"); // X Driver % + LSTR MSG_DAC_PERCENT_B = STR_B _UxGT(" 驅動 %"); // Y Driver % + LSTR MSG_DAC_PERCENT_C = STR_C _UxGT(" 驅動 %"); // Z Driver % + LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" 驅動 %"); // I Driver % + LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" 驅動 %"); // J Driver % + LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" 驅動 %"); // K Driver % LSTR MSG_DAC_PERCENT_E = _UxGT("E 驅動 %"); //E Driver % LSTR MSG_ERROR_TMC = _UxGT("TMC連接錯誤"); // "TMC CONNECTION ERROR" LSTR MSG_DAC_EEPROM_WRITE = _UxGT("保存驅動設置"); // "DAC EEPROM Write" diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index 498b478b1258..8ca0c8ee9e3e 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -26,7 +26,7 @@ #include "../inc/MarlinConfigPre.h" -#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI +#if HAS_LCDPRINT #include "marlinui.h" #include "lcdprint.h" @@ -103,4 +103,4 @@ int calculateWidth(PGM_P const pstr) { return n * MENU_FONT_WIDTH; } -#endif // HAS_WIRED_LCD +#endif // HAS_LCDPRINT diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index c701a59568f5..d716d035caf6 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -190,6 +190,9 @@ inline lcd_uint_t lcd_put_u8str_ind_P(const lcd_uint_t col, const lcd_uint_t row lcd_moveto(col, row); return lcd_put_u8str_ind_P(pstr, ind, inStr, maxlen); } +inline lcd_uint_t lcd_put_u8str_ind(FSTR_P const fstr, const int8_t ind, FSTR_P const inFstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { + return lcd_put_u8str_ind_P(FTOP(fstr), ind, FTOP(inFstr), maxlen); +} inline lcd_uint_t lcd_put_u8str_ind(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const fstr, const int8_t ind, FSTR_P const inFstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { return lcd_put_u8str_ind_P(col, row, FTOP(fstr), ind, FTOP(inFstr), maxlen); } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 57157d2c00ce..786a865049fa 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -24,7 +24,7 @@ #include "../MarlinCore.h" // for printingIsPaused -#ifdef LED_BACKLIGHT_TIMEOUT +#if LED_POWEROFF_TIMEOUT > 0 || BOTH(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) #include "../feature/leds/leds.h" #endif @@ -43,14 +43,12 @@ MarlinUI ui; #if HAS_DISPLAY #include "../gcode/queue.h" #include "fontutils.h" - #include "../sd/cardreader.h" #endif #if ENABLED(DWIN_CREALITY_LCD) #include "e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "fontutils.h" - #include "e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "e3v2/jyersui/dwin.h" #endif @@ -70,7 +68,7 @@ MarlinUI ui; constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_STATUS_MESSAGE - #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) uint8_t MarlinUI::status_scroll_offset; // = 0 #endif char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; @@ -97,8 +95,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif #if HAS_LCD_CONTRAST - uint8_t MarlinUI::contrast; // Initialized by settings.load() - + uint8_t MarlinUI::contrast = LCD_CONTRAST_DEFAULT; // Initialized by settings.load() void MarlinUI::set_contrast(const uint8_t value) { contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX); _set_contrast(); @@ -106,7 +103,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif #if HAS_LCD_BRIGHTNESS - uint8_t MarlinUI::brightness = DEFAULT_LCD_BRIGHTNESS; + uint8_t MarlinUI::brightness = LCD_BRIGHTNESS_DEFAULT; bool MarlinUI::backlight = true; void MarlinUI::set_brightness(const uint8_t value) { @@ -150,14 +147,14 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; 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)); + TERN_(HAS_HOTEND, if (TEST(pmask, PT_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e)); + TERN_(HAS_HEATED_BED, if (TEST(pmask, PT_BED)) thermalManager.setTargetBed(pre.bed_temp)); + //TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PT_CHAMBER)) thermalManager.setTargetBed(pre.chamber_temp)); + TERN_(HAS_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed)); } #endif -#if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) +#if EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) bool MarlinUI::lcd_clicked; #endif @@ -176,6 +173,86 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif +// Encoder Handling +#if HAS_ENCODER_ACTION + uint32_t MarlinUI::encoderPosition; + volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update +#endif + +#if LCD_BACKLIGHT_TIMEOUT + uint16_t MarlinUI::lcd_backlight_timeout; // Initialized by settings.load() + millis_t MarlinUI::backlight_off_ms = 0; + void MarlinUI::refresh_backlight_timeout() { + backlight_off_ms = lcd_backlight_timeout ? millis() + lcd_backlight_timeout * 1000UL : 0; + WRITE(LCD_BACKLIGHT_PIN, HIGH); + } +#endif + +void MarlinUI::init() { + + init_lcd(); + + #if HAS_DIGITAL_BUTTONS + #if BUTTON_EXISTS(EN1) + SET_INPUT_PULLUP(BTN_EN1); + #endif + #if BUTTON_EXISTS(EN2) + SET_INPUT_PULLUP(BTN_EN2); + #endif + #if BUTTON_EXISTS(ENC) + SET_INPUT_PULLUP(BTN_ENC); + #endif + #if BUTTON_EXISTS(ENC_EN) + SET_INPUT_PULLUP(BTN_ENC_EN); + #endif + #if BUTTON_EXISTS(BACK) + SET_INPUT_PULLUP(BTN_BACK); + #endif + #if BUTTON_EXISTS(UP) + SET_INPUT(BTN_UP); + #endif + #if BUTTON_EXISTS(DWN) + SET_INPUT(BTN_DWN); + #endif + #if BUTTON_EXISTS(LFT) + SET_INPUT(BTN_LFT); + #endif + #if BUTTON_EXISTS(RT) + SET_INPUT(BTN_RT); + #endif + #endif + + #if HAS_SHIFT_ENCODER + + #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register + + SET_OUTPUT(SR_DATA_PIN); + SET_OUTPUT(SR_CLK_PIN); + + #elif PIN_EXISTS(SHIFT_CLK) + + SET_OUTPUT(SHIFT_CLK_PIN); + OUT_WRITE(SHIFT_LD_PIN, HIGH); + #if PIN_EXISTS(SHIFT_EN) + OUT_WRITE(SHIFT_EN_PIN, LOW); + #endif + SET_INPUT_PULLUP(SHIFT_OUT_PIN); + + #endif + + #endif // HAS_SHIFT_ENCODER + + #if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS) + slow_buttons = 0; + #endif + + update_buttons(); + + TERN_(HAS_ENCODER_ACTION, encoderDiff = 0); + + reset_status(); // Set welcome message +} + #if HAS_WIRED_LCD #if HAS_MARLINUI_U8GLIB @@ -184,13 +261,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #include "lcdprint.h" - #include "../sd/cardreader.h" - #include "../module/temperature.h" #include "../module/planner.h" #include "../module/motion.h" - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU #include "../module/settings.h" #endif @@ -210,7 +285,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #include "../feature/power_monitor.h" #endif - #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + #if LED_POWEROFF_TIMEOUT > 0 #include "../feature/power.h" #endif @@ -244,18 +319,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if IS_DWIN_MARLINUI bool MarlinUI::did_first_redraw; - #endif - - // Encoder Handling - #if HAS_ENCODER_ACTION - uint32_t MarlinUI::encoderPosition; - volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update + bool MarlinUI::old_is_printing; #endif #if ENABLED(SDSUPPORT) - #include "../sd/cardreader.h" - #if MARLINUI_SCROLL_NAME uint8_t MarlinUI::filename_scroll_pos, MarlinUI::filename_scroll_max; #endif @@ -288,7 +356,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU #include "menu/menu.h" screenFunc_t MarlinUI::currentScreen; // Initialized in CTOR @@ -390,70 +458,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif // !HAS_GRAPHICAL_TFT - #endif // HAS_LCD_MENU - - void MarlinUI::init() { - - init_lcd(); - - #if HAS_DIGITAL_BUTTONS - #if BUTTON_EXISTS(EN1) - SET_INPUT_PULLUP(BTN_EN1); - #endif - #if BUTTON_EXISTS(EN2) - SET_INPUT_PULLUP(BTN_EN2); - #endif - #if BUTTON_EXISTS(ENC) - SET_INPUT_PULLUP(BTN_ENC); - #endif - #if BUTTON_EXISTS(ENC_EN) - SET_INPUT_PULLUP(BTN_ENC_EN); - #endif - #if BUTTON_EXISTS(BACK) - SET_INPUT_PULLUP(BTN_BACK); - #endif - #if BUTTON_EXISTS(UP) - SET_INPUT(BTN_UP); - #endif - #if BUTTON_EXISTS(DWN) - SET_INPUT(BTN_DWN); - #endif - #if BUTTON_EXISTS(LFT) - SET_INPUT(BTN_LFT); - #endif - #if BUTTON_EXISTS(RT) - SET_INPUT(BTN_RT); - #endif - #endif - - #if HAS_SHIFT_ENCODER - - #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register - - SET_OUTPUT(SR_DATA_PIN); - SET_OUTPUT(SR_CLK_PIN); - - #elif PIN_EXISTS(SHIFT_CLK) - - SET_OUTPUT(SHIFT_CLK_PIN); - OUT_WRITE(SHIFT_LD_PIN, HIGH); - #if PIN_EXISTS(SHIFT_EN) - OUT_WRITE(SHIFT_EN_PIN, LOW); - #endif - SET_INPUT_PULLUP(SHIFT_OUT_PIN); - - #endif - - #endif // HAS_SHIFT_ENCODER - - #if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS) - slow_buttons = 0; - #endif - - update_buttons(); - - TERN_(HAS_ENCODER_ACTION, encoderDiff = 0); - } + #endif // HAS_MARLINUI_MENU //////////////////////////////////////////// ///////////// Keypad Handling ////////////// @@ -463,7 +468,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; volatile uint8_t MarlinUI::keypad_buttons; - #if HAS_LCD_MENU && !HAS_ADC_BUTTONS + #if HAS_MARLINUI_MENU && !HAS_ADC_BUTTONS void lcd_move_x(); void lcd_move_y(); @@ -490,7 +495,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (keypad_buttons) { #if HAS_ENCODER_ACTION refresh(LCDVIEW_REDRAW_NOW); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (encoderDirection == -(ENCODERBASE)) { // HAS_ADC_BUTTONS forces REVERSE_MENU_DIRECTION, so this indicates menu navigation if (RRK(EN_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; else if (RRK(EN_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; @@ -500,7 +505,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; else #endif { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (RRK(EN_KEYPAD_UP)) encoderPosition -= epps; else if (RRK(EN_KEYPAD_DOWN)) encoderPosition += epps; else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); } @@ -531,7 +536,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; const bool homed = all_axes_homed(); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (RRK(EN_KEYPAD_MIDDLE)) goto_screen(menu_move); @@ -550,7 +555,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (RRK(EN_KEYPAD_UP)) _reprapworld_keypad_move(Y_AXIS, -1); } - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU if (!homed && RRK(EN_KEYPAD_F1)) queue.inject_P(G28_STR); return true; @@ -578,7 +583,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::status_screen() { - TERN_(HAS_LCD_MENU, ENCODER_RATE_MULTIPLY(false)); + TERN_(HAS_MARLINUI_MENU, ENCODER_RATE_MULTIPLY(false)); #if BASIC_PROGRESS_BAR @@ -622,15 +627,13 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif // BASIC_PROGRESS_BAR - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (use_click()) { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) next_filament_display = millis() + 5000UL; // Show status message for 5s #endif goto_screen(menu_main); - #if DISABLED(NO_LCD_REINIT) - init_lcd(); // May revive the LCD if static electricity killed it - #endif + reinit_lcd(); // Revive a noisy shared SPI LCD return; } @@ -678,10 +681,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) { init(); status_printf(1, F(S_FMT ": " S_FMT), FTOP(lcd_error), FTOP(lcd_component)); - TERN_(HAS_LCD_MENU, return_to_status()); + TERN_(HAS_MARLINUI_MENU, return_to_status()); // RED ALERT. RED ALERT. - #ifdef LED_BACKLIGHT_TIMEOUT + #if ENABLED(PRINTER_EVENT_LEDS) leds.set_color(LEDColorRed()); #ifdef NEOPIXEL_BKGD_INDEX_FIRST neo.set_background_color(255, 0, 0, 0); @@ -706,10 +709,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up the TFT with most buttons - TERN_(HAS_LCD_MENU, refresh()); + TERN_(HAS_MARLINUI_MENU, refresh()); #if HAS_ENCODER_ACTION - if (clear_buttons) buttons = 0; + if (clear_buttons) + TERN_(HAS_ADC_BUTTONS, keypad_buttons =) buttons = 0; next_button_update_ms = millis() + 500; #else UNUSED(clear_buttons); @@ -717,9 +721,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_CHIRP chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_LCD_MENU, USE_BEEPER) + #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER) for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_LCD_MENU + #elif HAS_MARLINUI_MENU delay(10); #endif #endif @@ -729,7 +733,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; /////////////// Manual Move //////////////// //////////////////////////////////////////// - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU ManualMove MarlinUI::manual_move{}; @@ -771,7 +775,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; // Add a manual move to the queue? if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) { - const feedRate_t fr_mm_s = (axis <= LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; + const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; #if IS_KINEMATIC @@ -841,7 +845,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU /** * Update the LCD, read encoder buttons, etc. @@ -888,11 +892,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; static uint16_t max_display_update_time = 0; millis_t ms = millis(); - #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + #if LED_POWEROFF_TIMEOUT > 0 leds.update_timeout(powerManager.psu_on); #endif - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU // Handle any queued Move Axis motion manual_move.task(); @@ -947,7 +951,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; goto_previous_screen(); } - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU if (ELAPSED(ms, next_lcd_update_ms) || TERN0(HAS_MARLINUI_U8GLIB, drawing_screen)) { @@ -994,7 +998,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (encoderPastThreshold || lcd_clicked) { if (encoderPastThreshold && TERN1(IS_TFTGLCD_PANEL, !external_control)) { - #if BOTH(HAS_LCD_MENU, ENCODER_RATE_MULTIPLIER) + #if BOTH(HAS_MARLINUI_MENU, ENCODER_RATE_MULTIPLIER) int32_t encoderMultiplier = 1; @@ -1037,14 +1041,18 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; reset_status_timeout(ms); + #if LCD_BACKLIGHT_TIMEOUT + refresh_backlight_timeout(); + #endif + refresh(LCDVIEW_REDRAW_NOW); - #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + #if LED_POWEROFF_TIMEOUT > 0 if (!powerManager.psu_on) leds.reset_timeout(ms); #endif - } + } // encoder activity - #endif + #endif // HAS_ENCODER_ACTION // This runs every ~100ms when idling often enough. // Instead of tracking changes just redraw the Status Screen once per second. @@ -1054,7 +1062,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; refresh(LCDVIEW_REDRAW_NOW); } - #if BOTH(HAS_LCD_MENU, SCROLL_LONG_FILENAMES) + #if BOTH(HAS_MARLINUI_MENU, SCROLL_LONG_FILENAMES) // If scrolling of long file names is enabled and we are in the sd card menu, // cause a refresh to occur until all the text has scrolled into view. if (currentScreen == menu_media && !lcd_status_update_delay--) { @@ -1125,7 +1133,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif - TERN_(HAS_LCD_MENU, lcd_clicked = false); + TERN_(HAS_MARLINUI_MENU, lcd_clicked = false); // Keeping track of the longest time for an individual LCD update. // Used to do screen throttling when the planner starts to fill up. @@ -1141,6 +1149,13 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; return_to_status(); #endif + #if LCD_BACKLIGHT_TIMEOUT + if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) { + WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off + backlight_off_ms = 0; + } + #endif + // Change state of drawing flag between screen updates if (!drawing_screen) switch (lcdDrawUpdate) { case LCDVIEW_CLEAR_CALL_REDRAW: @@ -1161,7 +1176,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_ADC_BUTTONS typedef struct { - uint16_t ADCKeyValueMin, ADCKeyValueMax; + raw_adc_t ADCKeyValueMin, ADCKeyValueMax; uint8_t ADCKeyNo; } _stADCKeypadTable_; @@ -1188,10 +1203,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif // Calculate the ADC value for the voltage divider with specified pull-down resistor value - #define ADC_BUTTON_VALUE(r) int(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) + #define ADC_BUTTON_VALUE(r) raw_adc_t(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) - static constexpr uint16_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, - adc_other_button = HAL_ADC_RANGE * 1000 / 1024; + static constexpr raw_adc_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, + adc_other_button = HAL_ADC_RANGE * 1000 / 1024; static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = { // VALUE_MIN, VALUE_MAX, KEY { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F1 }, // F1 @@ -1211,13 +1226,13 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; uint8_t get_ADC_keyValue() { if (thermalManager.ADCKey_count >= 16) { - const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw; + const raw_adc_t currentkpADCValue = thermalManager.current_ADCKey_raw; thermalManager.current_ADCKey_raw = HAL_ADC_RANGE; thermalManager.ADCKey_count = 0; if (currentkpADCValue < adc_other_button) LOOP_L_N(i, ADC_KEY_NUM) { - const uint16_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin), - hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax); + const raw_adc_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin), + hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax); if (WITHIN(currentkpADCValue, lo, hi)) return pgm_read_byte(&stADCKeyTable[i].ADCKeyNo); } } @@ -1339,7 +1354,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; case ENCODER_PHASE_2: ENCODER_SPIN(ENCODER_PHASE_1, ENCODER_PHASE_3); break; case ENCODER_PHASE_3: ENCODER_SPIN(ENCODER_PHASE_2, ENCODER_PHASE_0); break; } - #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL) + #if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL) external_encoder(); #endif lastEncoderBits = enc; @@ -1367,7 +1382,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::set_status(const char * const cstr, const bool persist) { if (alert_level) return; - TERN_(HOST_PROMPT_SUPPORT, hostui.notify(cstr)); + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(cstr)); // Here we have a problem. The message is encoded in UTF8, so // arbitrarily cutting it will be a problem. We MUST be sure @@ -1425,8 +1440,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; else if (print_job_timer.needsService(3)) msg = FPSTR(service3); #endif - else if (!no_welcome) - msg = GET_TEXT_F(WELCOME_MSG); + else if (!no_welcome) msg = GET_TEXT_F(WELCOME_MSG); + + else if (ENABLED(DWIN_LCD_PROUI)) + msg = F(""); else return; @@ -1439,7 +1456,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (level < alert_level) return; alert_level = level; - TERN_(HOST_PROMPT_SUPPORT, hostui.notify(fstr)); + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr)); // Since the message is encoded in UTF8 it must // only be cut on a character boundary. @@ -1465,7 +1482,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::set_alert_status(FSTR_P const fstr) { set_status(fstr, 1); TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); - TERN_(HAS_LCD_MENU, return_to_status()); + TERN_(HAS_MARLINUI_MENU, return_to_status()); } #include @@ -1477,6 +1494,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; va_start(args, FTOP(fmt)); vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, FTOP(fmt), args); va_end(args); + + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(status_message)); + finish_status(level > 0); } @@ -1503,13 +1523,13 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif - #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) status_scroll_offset = 0; #endif TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message)); TERN_(DWIN_CREALITY_LCD, DWIN_StatusChanged(status_message)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_CheckStatusMessage()); + TERN_(DWIN_LCD_PROUI, DWIN_CheckStatusMessage()); TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Update_Status(status_message)); } @@ -1550,28 +1570,26 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; IF_DISABLED(SDSUPPORT, print_job_timer.stop()); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("UI Aborted"), FPSTR(DISMISS_STR))); LCD_MESSAGE(MSG_PRINT_ABORTED); - TERN_(HAS_LCD_MENU, return_to_status()); + TERN_(HAS_MARLINUI_MENU, return_to_status()); } - #if BOTH(PSU_CONTROL, PS_OFF_CONFIRM) + #if BOTH(HAS_MARLINUI_MENU, PSU_CONTROL) + void MarlinUI::poweroff() { - queue.inject(F("M81")); - goto_previous_screen(); + queue.inject(F("M81" TERN_(POWER_OFF_WAIT_FOR_COOLDOWN, "S"))); + return_to_status(); } + #endif void MarlinUI::flow_fault() { LCD_ALERTMESSAGE(MSG_FLOWMETER_FAULT); TERN_(HAS_BUZZER, buzz(1000, 440)); - TERN_(HAS_LCD_MENU, return_to_status()); + TERN_(HAS_MARLINUI_MENU, return_to_status()); } - #if ANY(PARK_HEAD_ON_PAUSE, SDSUPPORT) - #include "../gcode/queue.h" - #endif - void MarlinUI::pause_print() { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU synchronize(GET_TEXT(MSG_PAUSING)); defer_status_screen(); #endif @@ -1693,33 +1711,31 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; ExtUI::onMediaRemoved(); #elif PIN_EXISTS(SD_DETECT) LCD_MESSAGE(MSG_MEDIA_REMOVED); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (!defer_return_to_status) return_to_status(); #endif #endif } } - #if PIN_EXISTS(SD_DETECT) && DISABLED(NO_LCD_REINIT) - init_lcd(); // Revive a noisy shared SPI LCD - #endif + reinit_lcd(); // Revive a noisy shared SPI LCD refresh(); - #if HAS_WIRED_LCD || defined(LED_BACKLIGHT_TIMEOUT) + #if HAS_WIRED_LCD || LED_POWEROFF_TIMEOUT > 0 const millis_t ms = millis(); #endif TERN_(HAS_WIRED_LCD, next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL); // Delay LCD update for SD activity - #ifdef LED_BACKLIGHT_TIMEOUT + #if LED_POWEROFF_TIMEOUT > 0 leds.reset_timeout(ms); #endif } #endif // SDSUPPORT -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU void MarlinUI::reset_settings() { settings.reset(); completion_feedback(); @@ -1775,7 +1791,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if ENABLED(EEPROM_SETTINGS) - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU void MarlinUI::init_eeprom() { const bool good = settings.init_eeprom(); completion_feedback(good); @@ -1803,7 +1819,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; } void MarlinUI::eeprom_alert(const uint8_t msgid) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU editable.uint8 = msgid; goto_screen([]{ PGM_P const restore_msg = GET_TEXT(MSG_INIT_EEPROM); diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index ed5b539eaf8f..b28687ee9173 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -21,6 +21,7 @@ */ #pragma once +#include "../sd/cardreader.h" #include "../module/motion.h" #include "buttons.h" @@ -30,15 +31,11 @@ #include "../libs/buzzer.h" #endif -#if ENABLED(SDSUPPORT) - #include "../sd/cardreader.h" -#endif - #if ENABLED(TOUCH_SCREEN_CALIBRATION) #include "tft_io/touch_calibration.h" #endif -#if ANY(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) +#if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) #define HAS_ENCODER_ACTION 1 #endif @@ -54,14 +51,14 @@ #include "../module/printcounter.h" #endif -#if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2) +#if ENABLED(ADVANCED_PAUSE_FEATURE) #include "../feature/pause.h" #endif #if ENABLED(DWIN_CREALITY_LCD) #include "e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "e3v2/proui/dwin.h" #endif #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) @@ -80,7 +77,7 @@ uint8_t get_ADC_keyValue(); #endif - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU #include "lcdprint.h" @@ -93,7 +90,7 @@ typedef void (*screenFunc_t)(); typedef void (*menuAction_t)(); - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU #endif // HAS_WIRED_LCD @@ -129,7 +126,7 @@ } preheat_t; #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU // Manual Movement class class ManualMove { @@ -201,9 +198,25 @@ class MarlinUI { public: MarlinUI() { - TERN_(HAS_LCD_MENU, currentScreen = status_screen); + TERN_(HAS_MARLINUI_MENU, currentScreen = status_screen); } + static void init(); + + #if HAS_DISPLAY || HAS_DWIN_E3V2 + static void init_lcd(); + #else + static void init_lcd() {} + #endif + + static void reinit_lcd() { TERN_(REINIT_NOISY_LCD, init_lcd()); } + + #if HAS_WIRED_LCD + static bool detected(); + #else + static bool detected() { return true; } + #endif + #if HAS_MULTI_LANGUAGE static uint8_t language; static void set_language(const uint8_t lang); @@ -234,7 +247,7 @@ class MarlinUI { // LCD implementations static void clear_lcd(); - #if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) + #if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) static void check_touch_calibration() { if (touch_calibration.need_calibration()) currentScreen = touch_calibration_screen; } @@ -252,8 +265,8 @@ class MarlinUI { #ifndef LCD_BRIGHTNESS_MAX #define LCD_BRIGHTNESS_MAX 255 #endif - #ifndef DEFAULT_LCD_BRIGHTNESS - #define DEFAULT_LCD_BRIGHTNESS LCD_BRIGHTNESS_MAX + #ifndef LCD_BRIGHTNESS_DEFAULT + #define LCD_BRIGHTNESS_DEFAULT LCD_BRIGHTNESS_MAX #endif static uint8_t brightness; static bool backlight; @@ -262,6 +275,14 @@ class MarlinUI { FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); } #endif + #if LCD_BACKLIGHT_TIMEOUT + #define LCD_BKL_TIMEOUT_MIN 1 + #define LCD_BKL_TIMEOUT_MAX (60*60*18) // 18 hours max within uint16_t + static uint16_t lcd_backlight_timeout; + static millis_t backlight_off_ms; + static void refresh_backlight_timeout(); + #endif + #if HAS_DWIN_E3V2_BASIC static void refresh(); #else @@ -270,14 +291,6 @@ class MarlinUI { } #endif - #if HAS_WIRED_LCD - static bool detected(); - static void init_lcd(); - #else - static inline bool detected() { return true; } - static inline void init_lcd() {} - #endif - #if HAS_PRINT_PROGRESS #if HAS_PRINT_PROGRESS_PERMYRIAD typedef uint16_t progress_t; @@ -293,20 +306,20 @@ class MarlinUI { static void set_progress(const progress_t p) { progress_override = _MIN(p, 100U * (PROGRESS_SCALE)); } static void set_progress_done() { progress_override = (PROGRESS_MASK + 1U) + 100U * (PROGRESS_SCALE); } static void progress_reset() { if (progress_override & (PROGRESS_MASK + 1U)) set_progress(0); } - #if ENABLED(SHOW_REMAINING_TIME) - static inline uint32_t _calculated_remaining_time() { - const duration_t elapsed = print_job_timer.duration(); - const progress_t progress = _get_progress(); - return progress ? elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress : 0; - } - #if ENABLED(USE_M73_REMAINING_TIME) - static uint32_t remaining_time; - FORCE_INLINE static void set_remaining_time(const uint32_t r) { remaining_time = r; } - FORCE_INLINE static uint32_t get_remaining_time() { return remaining_time ?: _calculated_remaining_time(); } - FORCE_INLINE static void reset_remaining_time() { set_remaining_time(0); } - #else - FORCE_INLINE static uint32_t get_remaining_time() { return _calculated_remaining_time(); } - #endif + #endif + #if ENABLED(SHOW_REMAINING_TIME) + static uint32_t _calculated_remaining_time() { + const duration_t elapsed = print_job_timer.duration(); + const progress_t progress = _get_progress(); + return progress ? elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress : 0; + } + #if ENABLED(USE_M73_REMAINING_TIME) + static uint32_t remaining_time; + FORCE_INLINE static void set_remaining_time(const uint32_t r) { remaining_time = r; } + FORCE_INLINE static uint32_t get_remaining_time() { return remaining_time ?: _calculated_remaining_time(); } + FORCE_INLINE static void reset_remaining_time() { set_remaining_time(0); } + #else + FORCE_INLINE static uint32_t get_remaining_time() { return _calculated_remaining_time(); } #endif #endif static progress_t _get_progress(); @@ -320,7 +333,7 @@ class MarlinUI { #if HAS_STATUS_MESSAGE - #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) #if ENABLED(STATUS_MESSAGE_SCROLLING) #define MAX_MESSAGE_LENGTH _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH)) #else @@ -342,30 +355,20 @@ class MarlinUI { static bool has_status(); static void reset_status(const bool no_welcome=false); static void set_alert_status(FSTR_P const fstr); - static inline void reset_alert_level() { alert_level = 0; } + static void reset_alert_level() { alert_level = 0; } #else static constexpr bool has_status() { return false; } - static inline void reset_status(const bool=false) {} - static inline void set_alert_status(FSTR_P const) {} - static inline void reset_alert_level() {} + static void reset_status(const bool=false) {} + static void set_alert_status(FSTR_P const) {} + static void reset_alert_level() {} #endif static void set_status(const char * const cstr, const bool persist=false); static void set_status(FSTR_P const fstr, const int8_t level=0); static void status_printf(const uint8_t level, FSTR_P const fmt, ...); - #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) - static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); - #if DISABLED(LIGHTWEIGHT_UI) - static void draw_status_message(const bool blink); - #endif - #else - static inline void kill_screen(FSTR_P const, FSTR_P const) {} - #endif - #if HAS_DISPLAY - static void init(); static void update(); static void abort_print(); @@ -373,7 +376,7 @@ class MarlinUI { static void resume_print(); static void flow_fault(); - #if BOTH(PSU_CONTROL, PS_OFF_CONFIRM) + #if BOTH(HAS_MARLINUI_MENU, PSU_CONTROL) static void poweroff(); #endif @@ -444,7 +447,7 @@ class MarlinUI { #if HAS_BUZZER static void completion_feedback(const bool good=true); #else - static inline void completion_feedback(const bool=true) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); } + static void completion_feedback(const bool=true) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); } #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) @@ -468,6 +471,7 @@ class MarlinUI { #if IS_DWIN_MARLINUI static bool did_first_redraw; + static bool old_is_printing; #endif #if EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) @@ -476,17 +480,21 @@ class MarlinUI { #endif static void draw_kill_screen(); + static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); + #if DISABLED(LIGHTWEIGHT_UI) + static void draw_status_message(const bool blink); + #endif #else // No LCD - static inline void init() {} - static inline void update() {} - static inline void return_to_status() {} + static void update() {} + static void return_to_status() {} + static void kill_screen(FSTR_P const, FSTR_P const) {} #endif #if ENABLED(SDSUPPORT) - #if BOTH(SCROLL_LONG_FILENAMES, HAS_LCD_MENU) + #if BOTH(SCROLL_LONG_FILENAMES, HAS_MARLINUI_MENU) #define MARLINUI_SCROLL_NAME 1 #endif #if MARLINUI_SCROLL_NAME @@ -496,24 +504,22 @@ class MarlinUI { #endif #if HAS_PREHEAT - enum PreheatMask : uint8_t { PM_HOTEND = _BV(0), PM_BED = _BV(1), PM_FAN = _BV(2), PM_CHAMBER = _BV(3) }; + enum PreheatTarget : uint8_t { PT_HOTEND, PT_BED, PT_FAN, PT_CHAMBER, PT_ALL = 0xFF }; 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); } + static void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, _BV(PT_FAN))); } + static void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, _BV(PT_HOTEND))); } + static void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); } + static void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, _BV(PT_BED))); } + static void preheat_all(const uint8_t m) { apply_preheat(m, PT_ALL); } #endif - #if SCREENS_CAN_TIME_OUT - static inline void reset_status_timeout(const millis_t ms) { return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; } - #else - static inline void reset_status_timeout(const millis_t) {} - #endif + static void reset_status_timeout(const millis_t ms) { + TERN(SCREENS_CAN_TIME_OUT, return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS, UNUSED(ms)); + } - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU #if HAS_TOUCH_BUTTONS static uint8_t touch_buttons; @@ -548,11 +554,11 @@ class MarlinUI { // goto_previous_screen and go_back may also be used as menu item callbacks static void _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back)); - static inline void goto_previous_screen() { _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, false)); } - static inline void go_back() { _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, true)); } + static void goto_previous_screen() { _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, false)); } + static void go_back() { _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, true)); } static void return_to_status(); - static inline bool on_status_screen() { return currentScreen == status_screen; } + static bool on_status_screen() { return currentScreen == status_screen; } FORCE_INLINE static void run_current_screen() { (*currentScreen)(); } #if ENABLED(LIGHTWEIGHT_UI) @@ -567,7 +573,7 @@ class MarlinUI { TERN(SCREENS_CAN_TIME_OUT, defer_return_to_status = defer, UNUSED(defer)); } - static inline void goto_previous_screen_no_defer() { + static void goto_previous_screen_no_defer() { defer_status_screen(false); goto_previous_screen(); } @@ -597,50 +603,50 @@ class MarlinUI { #endif - #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) + #if EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) static bool lcd_clicked; - static inline bool use_click() { + static bool use_click() { const bool click = lcd_clicked; lcd_clicked = false; return click; } #else static constexpr bool lcd_clicked = false; - static inline bool use_click() { return false; } + static bool use_click() { return false; } #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI) + #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder); #else - static inline void _pause_show_message() {} + static void _pause_show_message() {} #define pause_show_message(...) _pause_show_message() #endif // // EEPROM: Reset / Init / Load / Store // - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU static void reset_settings(); #endif #if ENABLED(EEPROM_SETTINGS) - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU static void init_eeprom(); static void load_settings(); static void store_settings(); #endif #if DISABLED(EEPROM_AUTO_INIT) static void eeprom_alert(const uint8_t msgid); - static inline void eeprom_alert_crc() { eeprom_alert(0); } - static inline void eeprom_alert_index() { eeprom_alert(1); } - static inline void eeprom_alert_version() { eeprom_alert(2); } + static void eeprom_alert_crc() { eeprom_alert(0); } + static void eeprom_alert_index() { eeprom_alert(1); } + static void eeprom_alert_version() { eeprom_alert(2); } #endif #endif // // Special handling if a move is underway // - #if ANY(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION, PROBE_OFFSET_WIZARD) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)) + #if ANY(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION, PROBE_OFFSET_WIZARD, X_AXIS_TWIST_COMPENSATION) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)) #define LCD_HAS_WAIT_FOR_MOVE 1 static bool wait_for_move; #else @@ -650,7 +656,7 @@ class MarlinUI { // // Block interaction while under external control // - #if HAS_LCD_MENU && EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) + #if HAS_MARLINUI_MENU && EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) static bool external_control; FORCE_INLINE static void capture() { external_control = true; } FORCE_INLINE static void release() { external_control = false; } @@ -674,7 +680,31 @@ class MarlinUI { #endif static void update_buttons(); - static inline bool button_pressed() { return BUTTON_CLICK() || TERN(TOUCH_SCREEN, touch_pressed(), false); } + + #if HAS_ENCODER_NOISE + #ifndef ENCODER_SAMPLES + #define ENCODER_SAMPLES 10 + #endif + + /** + * Some printers may have issues with EMI noise especially using a motherboard with 3.3V logic levels + * it may cause the logical LOW to float into the undefined region and register as a logical HIGH + * causing it to errorenously register as if someone clicked the button and in worst case make the printer + * unusable in practice. + */ + static bool hw_button_pressed() { + LOOP_L_N(s, ENCODER_SAMPLES) { + if (!BUTTON_CLICK()) return false; + safe_delay(1); + } + return true; + } + #else + static bool hw_button_pressed() { return BUTTON_CLICK(); } + #endif + + static bool button_pressed() { return hw_button_pressed() || TERN0(TOUCH_SCREEN, touch_pressed()); } + #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) static void wait_for_release(); #endif @@ -705,7 +735,7 @@ class MarlinUI { #else - static inline void update_buttons() {} + static void update_buttons() {} #endif diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index a24ad883f788..52c43ec5e90f 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu.h" #include "../../module/planner.h" @@ -38,7 +38,7 @@ #include "../../module/probe.h" #endif -#if EITHER(ENABLE_LEVELING_FADE_HEIGHT, AUTO_BED_LEVELING_UBL) +#if HAS_LEVELING #include "../../feature/bedlevel/bedlevel.h" #endif @@ -46,6 +46,13 @@ ///////////// Global Variables ///////////// //////////////////////////////////////////// +#if HAS_LEVELING && ANY(LEVEL_BED_CORNERS, PROBE_OFFSET_WIZARD, X_AXIS_TWIST_COMPENSATION) + bool leveling_was_active; // = false +#endif +#if ANY(PROBE_MANUALLY, MESH_BED_LEVELING, X_AXIS_TWIST_COMPENSATION) + uint8_t manual_probe_index; // = 0 +#endif + // Menu Navigation int8_t encoderTopLine, encoderLine, screen_items; @@ -213,7 +220,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co screen_changed = true; TERN_(HAS_MARLINUI_U8GLIB, drawing_screen = false); - TERN_(HAS_LCD_MENU, encoder_direction_normal()); + TERN_(HAS_MARLINUI_MENU, encoder_direction_normal()); set_selection(false); } @@ -269,11 +276,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { #if HAS_BUZZER void MarlinUI::completion_feedback(const bool good/*=true*/) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click... - if (good) { - BUZZ(100, 659); - BUZZ(100, 698); - } - else BUZZ(20, 440); + if (good) OKAY_BUZZ(); else ERR_BUZZ(); } #endif @@ -339,7 +342,6 @@ void _lcd_draw_homing() { } #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)) - #include "../../feature/bedlevel/bedlevel.h" void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); } #endif @@ -362,7 +364,8 @@ void MenuItem_confirm::select_screen( PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/ ) { ui.defer_status_screen(); - const bool ui_selection = ui.update_selection(), got_click = ui.use_click(); + const bool ui_selection = !yes ? false : !no || ui.update_selection(), + got_click = ui.use_click(); if (got_click || ui.should_draw()) { draw_select_screen(yes, no, ui_selection, pref, string, suff); if (got_click) { @@ -372,4 +375,4 @@ void MenuItem_confirm::select_screen( } } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 44b0e89aca36..b111236d69cd 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -109,13 +109,13 @@ class MenuItem_confirm : public MenuItemBase { selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr ); - static inline void select_screen( + static void select_screen( PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, FSTR_P const string, PGM_P const suff=nullptr ) { - char str[strlen_P((PGM_P)string) + 1]; - strcpy_P(str, (PGM_P)string); + char str[strlen_P(FTOP(string)) + 1]; + strcpy_P(str, FTOP(string)); select_screen(yes, no, yesFunc, noFunc, pref, str, suff); } // Shortcut for prompt with "NO"/ "YES" labels @@ -178,7 +178,7 @@ class MenuEditItemBase : public MenuItemBase { static void draw_edit_screen(PGM_P const pstr, const char * const value); // This method is for the current menu item - static inline void draw_edit_screen(const char * const value) { draw_edit_screen(editLabel, value); } + static void draw_edit_screen(const char * const value) { draw_edit_screen(editLabel, value); } }; #if ENABLED(SDSUPPORT) @@ -218,6 +218,11 @@ void _lcd_draw_homing(); void goto_probe_offset_wizard(); #endif +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + void xatc_wizard_continue(); + void menu_advanced_settings(); +#endif + #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)) void _lcd_toggle_bed_leveling(); #endif @@ -249,3 +254,11 @@ extern uint8_t screen_history_depth; inline void clear_menu_history() { screen_history_depth = 0; } #define STICKY_SCREEN(S) []{ ui.defer_status_screen(); ui.goto_screen(S); } + +#if HAS_LEVELING && ANY(LEVEL_BED_CORNERS, PROBE_OFFSET_WIZARD, X_AXIS_TWIST_COMPENSATION) + extern bool leveling_was_active; +#endif + +#if ANY(PROBE_MANUALLY, MESH_BED_LEVELING, X_AXIS_TWIST_COMPENSATION) + extern uint8_t manual_probe_index; +#endif diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 8b688ab2ab96..1bc9b9e88ed8 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu_item.h" #include "../../module/planner.h" @@ -84,10 +84,10 @@ void menu_backlash(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_CURRENT_PWM(LABEL,I) EDIT_ITEM_P(long5, PSTR(LABEL), &stepper.motor_current_setting[I], 100, 2000, stepper.refresh_motor_power) #if ANY_PIN(MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y) - EDIT_CURRENT_PWM(STR_X STR_Y, 0); + EDIT_CURRENT_PWM(STR_A STR_B, 0); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - EDIT_CURRENT_PWM(STR_Z, 1); + EDIT_CURRENT_PWM(STR_C, 1); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) EDIT_CURRENT_PWM(STR_E, 2); @@ -508,6 +508,10 @@ void menu_backlash(); SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard); #endif + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + SUBMENU(MSG_XATC, xatc_wizard_continue); + #endif + END_MENU(); } #endif @@ -519,7 +523,7 @@ void menu_advanced_steps_per_mm() { START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - #define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float51, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); }) + #define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float61, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); }) LINEAR_AXIS_CODE( EDIT_QSTEPS(A), EDIT_QSTEPS(B), EDIT_QSTEPS(C), EDIT_QSTEPS(I), EDIT_QSTEPS(J), EDIT_QSTEPS(K) @@ -527,7 +531,7 @@ void menu_advanced_steps_per_mm() { #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ + EDIT_ITEM_FAST_N(float61, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ const uint8_t e = MenuItemBase::itemIndex; if (e == active_extruder) planner.refresh_positioning(); @@ -535,7 +539,7 @@ void menu_advanced_steps_per_mm() { planner.mm_per_step[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)]; }); #elif E_STEPPERS - EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); + EDIT_ITEM_FAST(float61, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); #endif END_MENU(); @@ -649,4 +653,4 @@ void menu_advanced_settings() { END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_backlash.cpp b/Marlin/src/lcd/menu/menu_backlash.cpp index b9adacc5021d..faed8cf77763 100644 --- a/Marlin/src/lcd/menu/menu_backlash.cpp +++ b/Marlin/src/lcd/menu/menu_backlash.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, BACKLASH_GCODE) +#if BOTH(HAS_MARLINUI_MENU, BACKLASH_GCODE) #include "menu_item.h" @@ -36,14 +36,20 @@ void menu_backlash() { START_MENU(); BACK_ITEM(MSG_MAIN); - EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &backlash.correction, all_off, all_on); + editable.uint8 = backlash.get_correction_uint8(); + EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &editable.uint8, backlash.all_off, backlash.all_on, []{ backlash.set_correction_uint8(editable.uint8); }); - #if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY) + #if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX) #define _CAN_CALI AXIS_CAN_CALIBRATE #else #define _CAN_CALI(A) true #endif - #define EDIT_BACKLASH_DISTANCE(N) EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &backlash.distance_mm[_AXIS(N)], 0.0f, 9.9f); + + #define EDIT_BACKLASH_DISTANCE(N) do { \ + editable.decimal = backlash.get_distance_mm(_AXIS(N)); \ + EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &editable.decimal, 0.0f, 9.9f, []{ backlash.set_distance_mm(_AXIS(N), editable.decimal); }); \ + } while (0); + if (_CAN_CALI(A)) EDIT_BACKLASH_DISTANCE(A); #if HAS_Y_AXIS && _CAN_CALI(B) EDIT_BACKLASH_DISTANCE(B); @@ -51,21 +57,22 @@ void menu_backlash() { #if HAS_Z_AXIS && _CAN_CALI(C) EDIT_BACKLASH_DISTANCE(C); #endif - #if LINEAR_AXES >= 4 && _CAN_CALI(I) + #if HAS_I_AXIS && _CAN_CALI(I) EDIT_BACKLASH_DISTANCE(I); #endif - #if LINEAR_AXES >= 5 && _CAN_CALI(J) + #if HAS_J_AXIS && _CAN_CALI(J) EDIT_BACKLASH_DISTANCE(J); #endif - #if LINEAR_AXES >= 6 && _CAN_CALI(K) + #if HAS_K_AXIS && _CAN_CALI(K) EDIT_BACKLASH_DISTANCE(K); #endif #ifdef BACKLASH_SMOOTHING_MM - EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &backlash.smoothing_mm, 0.0f, 9.9f); + editable.decimal = backlash.get_smoothing_mm(); + EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &editable.decimal, 0.0f, 9.9f, []{ backlash.set_smoothing_mm(editable.decimal); }); #endif END_MENU(); } -#endif // HAS_LCD_MENU && BACKLASH_GCODE +#endif // HAS_MARLINUI_MENU && BACKLASH_GCODE diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 872b9b3840d8..e3f5c460ed24 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, LEVEL_BED_CORNERS) +#if BOTH(HAS_MARLINUI_MENU, LEVEL_BED_CORNERS) #include "menu_item.h" #include "../../module/motion.h" @@ -66,10 +66,6 @@ static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); -#if HAS_LEVELING - static bool leveling_was_active = false; -#endif - #ifndef LEVEL_CORNERS_LEVELING_ORDER #define LEVEL_CORNERS_LEVELING_ORDER { LF, RF, LB, RB } // Default //#define LEVEL_CORNERS_LEVELING_ORDER { LF, LB, RF } // 3 hard-coded points @@ -211,23 +207,25 @@ static void _lcd_level_bed_corners_get_next_position() { void _lcd_draw_level_prompt() { 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 + MenuItem_confirm::select_screen( + GET_TEXT(TERN(HAS_LEVELING, MSG_BUTTON_LEVEL, MSG_BUTTON_DONE)), + TERN(HAS_LEVELING, GET_TEXT(MSG_BUTTON_BACK), nullptr) + , []{ queue.inject(TERN(HAS_LEVELING, F("G29N"), FPSTR(G28_STR))); ui.return_to_status(); } + , TERN(HAS_LEVELING, ui.goto_previous_screen_no_defer, []{}) , GET_TEXT(MSG_BED_TRAMMING_IN_RANGE) - , (const char*)nullptr, PSTR("?") + , (const char*)nullptr, NUL_STR ); } bool _lcd_level_bed_corners_probe(bool verify=false) { if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed - TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action + TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); - TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); // Stow in LOW SPEED MODE on every trigger + TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.stow()); // Stow in LOW SPEED MODE on every trigger // Triggered outside tolerance range? if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) { last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners. @@ -253,7 +251,7 @@ static void _lcd_level_bed_corners_get_next_position() { } idle(); } - TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); + TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.stow()); ui.goto_screen(_lcd_draw_probing); return (probe_triggered); } @@ -267,13 +265,14 @@ static void _lcd_level_bed_corners_get_next_position() { do { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance + + do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + TERN0(BLTOUCH, bltouch.z_extra_clearance())); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets do_blocking_move_to_xy(current_position); // Goto corner - TERN_(BLTOUCH_HS_MODE, bltouch.deploy()); // Deploy in HIGH SPEED MODE + TERN_(BLTOUCH, if (bltouch.high_speed_mode) bltouch.deploy()); // Deploy in HIGH SPEED MODE if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify @@ -294,10 +293,12 @@ static void _lcd_level_bed_corners_get_next_position() { } while (good_points < nr_edge_points); // loop until all points within tolerance - #if ENABLED(BLTOUCH_HS_MODE) - // In HIGH SPEED MODE do clearance and stow at the very end - do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); - bltouch.stow(); + #if ENABLED(BLTOUCH) + if (bltouch.high_speed_mode) { + // In HIGH SPEED MODE do clearance and stow at the very end + do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); + bltouch.stow(); + } #endif ui.goto_screen(_lcd_draw_level_prompt); // prompt for bed leveling @@ -363,4 +364,4 @@ void _lcd_level_bed_corners() { ui.goto_screen(_lcd_level_bed_corners_homing); } -#endif // HAS_LCD_MENU && LEVEL_BED_CORNERS +#endif // HAS_MARLINUI_MENU && LEVEL_BED_CORNERS diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index eb286f96b9ea..a47e2517aedf 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -52,8 +52,6 @@ // Motion > Level Bed handlers // - static uint8_t manual_probe_index; - // LCD probed points are from defaults constexpr uint8_t total_probe_points = TERN(AUTO_BED_LEVELING_3POINT, 3, GRID_MAX_POINTS); diff --git a/Marlin/src/lcd/menu/menu_cancelobject.cpp b/Marlin/src/lcd/menu/menu_cancelobject.cpp index f2a06ecf6a4a..8db698d300f2 100644 --- a/Marlin/src/lcd/menu/menu_cancelobject.cpp +++ b/Marlin/src/lcd/menu/menu_cancelobject.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, CANCEL_OBJECTS) +#if BOTH(HAS_MARLINUI_MENU, CANCEL_OBJECTS) #include "menu_item.h" #include "menu_addon.h" @@ -71,4 +71,4 @@ void menu_cancelobject() { END_MENU(); } -#endif // HAS_LCD_MENU && CANCEL_OBJECTS +#endif // HAS_MARLINUI_MENU && CANCEL_OBJECTS diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 6d6b0228fb40..b4e9287bd4a3 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu_item.h" @@ -34,6 +34,10 @@ #include "../../feature/runout.h" #endif +#if HAS_FANCHECK + #include "../../feature/fancheck.h" +#endif + #if ENABLED(POWER_LOSS_RECOVERY) #include "../../feature/powerloss.h" #endif @@ -49,6 +53,8 @@ #include "../../libs/buzzer.h" #endif +#include "../../core/debug_out.h" + #define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST) void menu_advanced_settings(); @@ -213,11 +219,14 @@ void menu_advanced_settings(); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) void bltouch_report() { - SERIAL_ECHOLNPGM("EEPROM Last BLTouch Mode - ", bltouch.last_written_mode); - SERIAL_ECHOLNPGM("Configuration BLTouch Mode - " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD")); + PGMSTR(mode0, "OD"); + PGMSTR(mode1, "5V"); + DEBUG_ECHOPGM("BLTouch Mode: "); + DEBUG_ECHOPGM_P(bltouch.od_5v_mode ? mode1 : mode0); + DEBUG_ECHOLNPGM(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")"); char mess[21]; - strcpy_P(mess, PSTR("BLTouch Mode - ")); - strcpy_P(&mess[15], bltouch.last_written_mode ? PSTR("5V") : PSTR("OD")); + strcpy_P(mess, PSTR("BLTouch Mode: ")); + strcpy_P(&mess[15], bltouch.od_5v_mode ? mode1 : mode0); ui.set_status(mess); ui.return_to_status(); } @@ -231,6 +240,9 @@ void menu_advanced_settings(); ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); + #ifdef BLTOUCH_HS_MODE + EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode); + #endif #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); @@ -266,10 +278,10 @@ void menu_advanced_settings(); void menu_controller_fan() { START_MENU(); BACK_ITEM(MSG_CONFIGURATION); - EDIT_ITEM_FAST(percent, MSG_CONTROLLER_FAN_IDLE_SPEED, &controllerFan.settings.idle_speed, _MAX(1, CONTROLLERFAN_SPEED_MIN) - 1, 255); + EDIT_ITEM_FAST(percent, MSG_CONTROLLER_FAN_IDLE_SPEED, &controllerFan.settings.idle_speed, CONTROLLERFAN_SPEED_MIN, 255); EDIT_ITEM(bool, MSG_CONTROLLER_FAN_AUTO_ON, &controllerFan.settings.auto_mode); if (controllerFan.settings.auto_mode) { - EDIT_ITEM_FAST(percent, MSG_CONTROLLER_FAN_SPEED, &controllerFan.settings.active_speed, _MAX(1, CONTROLLERFAN_SPEED_MIN) - 1, 255); + EDIT_ITEM_FAST(percent, MSG_CONTROLLER_FAN_SPEED, &controllerFan.settings.active_speed, CONTROLLERFAN_SPEED_MIN, 255); EDIT_ITEM(uint16_4, MSG_CONTROLLER_FAN_DURATION, &controllerFan.settings.duration, 0, 4800); } END_MENU(); @@ -526,9 +538,13 @@ void menu_configuration() { #if HAS_LCD_BRIGHTNESS EDIT_ITEM_FAST(uint8, MSG_BRIGHTNESS, &ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.refresh_brightness, true); #endif - #if HAS_LCD_CONTRAST + #if HAS_LCD_CONTRAST && LCD_CONTRAST_MIN < LCD_CONTRAST_MAX EDIT_ITEM_FAST(uint8, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true); #endif + #if LCD_BACKLIGHT_TIMEOUT && LCD_BKL_TIMEOUT_MIN < LCD_BKL_TIMEOUT_MAX + EDIT_ITEM(uint16_4, MSG_LCD_BKL_TIMEOUT, &ui.lcd_backlight_timeout, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX, ui.refresh_backlight_timeout); + #endif + #if ENABLED(FWRETRACT) SUBMENU(MSG_RETRACT, menu_config_retract); #endif @@ -537,6 +553,10 @@ void menu_configuration() { EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset); #endif + #if HAS_FANCHECK + EDIT_ITEM(bool, MSG_FANCHECK, &fan_check.enabled); + #endif + #if ENABLED(POWER_LOSS_RECOVERY) EDIT_ITEM(bool, MSG_OUTAGE_RECOVERY, &recovery.enabled, recovery.changed); #endif @@ -561,4 +581,4 @@ void menu_configuration() { END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index ea627f69e781..f491c5b576ee 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) +#if HAS_MARLINUI_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) #include "menu_item.h" #include "../../module/delta.h" @@ -151,4 +151,4 @@ void menu_delta_calibrate() { END_MENU(); } -#endif // HAS_LCD_MENU && (DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION) +#endif // HAS_MARLINUI_MENU && (DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION) diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index e7365744e9a1..9f432c405c4f 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE) +#if BOTH(HAS_MARLINUI_MENU, ADVANCED_PAUSE_FEATURE) #include "menu_item.h" #include "../../module/temperature.h" @@ -342,4 +342,4 @@ void MarlinUI::pause_show_message( ui.return_to_status(); } -#endif // HAS_LCD_MENU && ADVANCED_PAUSE_FEATURE +#endif // HAS_MARLINUI_MENU && ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/lcd/menu/menu_info.cpp b/Marlin/src/lcd/menu/menu_info.cpp index 388aebb74469..3a23cf004884 100644 --- a/Marlin/src/lcd/menu/menu_info.cpp +++ b/Marlin/src/lcd/menu/menu_info.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, LCD_INFO_MENU) +#if BOTH(HAS_MARLINUI_MENU, LCD_INFO_MENU) #include "menu_item.h" @@ -103,7 +103,7 @@ void menu_info_thermistors() { #if HAS_EXTRUDERS #define THERMISTOR_ID TEMP_SENSOR_0 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E0 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR(STR_E0 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_0_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_0_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -113,7 +113,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_1 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E1 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR(STR_E1 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_1_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_1_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -123,7 +123,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_2 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E2 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR(STR_E2 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_2_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_2_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -133,7 +133,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_3 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E3 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR(STR_E3 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_3_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_3_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -143,7 +143,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_4 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E4 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR(STR_E4 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_4_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_4_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -153,7 +153,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_5 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E5 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR(STR_E5 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_5_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_5_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -163,7 +163,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_6 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E6 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR(STR_E6 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_6_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_6_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -173,7 +173,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_7 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E7 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR(STR_E7 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_7_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -317,4 +317,4 @@ void menu_info() { END_MENU(); } -#endif // HAS_LCD_MENU && LCD_INFO_MENU +#endif // HAS_MARLINUI_MENU && LCD_INFO_MENU diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 56138a15bd6b..fcde9f580193 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -39,14 +39,14 @@ class MenuItem_submenu : public MenuItemBase { FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]); } - static inline void action(PGM_P const, const screenFunc_t func) { ui.push_current_screen(); ui.goto_screen(func); } + static void action(PGM_P const, const screenFunc_t func) { ui.push_current_screen(); ui.goto_screen(func); } }; // Any menu item that invokes an immediate action class MenuItem_button : public MenuItemBase { public: // Button-y Items are selectable lines with no other indicator - static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { + static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { _draw(sel, row, pstr, '>', ' '); } }; @@ -54,8 +54,8 @@ class MenuItem_button : public MenuItemBase { // ACTION_ITEM(LABEL, FUNC) class MenuItem_function : public MenuItem_button { public: - //static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); }; - static inline void action(PGM_P const, const menuAction_t func) { (*func)(); }; + //static void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); }; + static void action(PGM_P const, const menuAction_t func) { if (func) (*func)(); }; }; // GCODES_ITEM(LABEL, GCODES) @@ -65,7 +65,7 @@ class MenuItem_gcode : public MenuItem_button { _draw(sel, row, pstr, '>', ' '); } static void action(PGM_P const, PGM_P const pgcode) { queue.inject(FPSTR(pgcode)); } - static inline void action(PGM_P const pstr, const uint8_t, PGM_P const pgcode) { action(pstr, pgcode); } + static void action(PGM_P const pstr, const uint8_t, PGM_P const pgcode) { action(pstr, pgcode); } }; //////////////////////////////////////////// @@ -77,8 +77,8 @@ template class TMenuEditItem : MenuEditItemBase { private: typedef typename NAME::type_t type_t; - static inline float scale(const_float_t value) { return NAME::scale(value); } - static inline float unscale(const_float_t value) { return NAME::unscale(value); } + static float scale(const_float_t value) { return NAME::scale(value); } + static float unscale(const_float_t value) { return NAME::unscale(value); } static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); } static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); } public: @@ -117,9 +117,9 @@ class TMenuEditItem : MenuEditItemBase { * * struct MenuEditItemInfo_percent { * typedef uint8_t type_t; - * static inline float scale(const_float_t value) { return value * (100.f/255.f) +0.5f; } - * static inline float unscale(const_float_t value) { return value / (100.f/255.f) +0.5f; } - * static inline const char* strfunc(const_float_t value) { return ui8tostr4pctrj(_DOFIX(uint8_t,value)); } + * static float scale(const_float_t value) { return value * (100.f/255.f) +0.5f; } + * static float unscale(const_float_t value) { return value / (100.f/255.f) +0.5f; } + * static const char* strfunc(const_float_t value) { return ui8tostr4pctrj(_DOFIX(uint8_t,value)); } * }; * typedef TMenuEditItem MenuItem_percent */ @@ -128,9 +128,9 @@ class TMenuEditItem : MenuEditItemBase { #define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, ETC...) \ struct MenuEditItemInfo_##NAME { \ typedef TYPE type_t; \ - static inline float scale(const_float_t value) { return value * (SCALE) ETC; } \ - static inline float unscale(const_float_t value) { return value / (SCALE) ETC; } \ - static inline const char* strfunc(const_float_t value) { return STRFUNC(_DOFIX(TYPE,value)); } \ + static float scale(const_float_t value) { return value * (SCALE) ETC; } \ + static float unscale(const_float_t value) { return value / (SCALE) ETC; } \ + static const char* strfunc(const_float_t value) { return STRFUNC(_DOFIX(TYPE,value)); } \ }; \ typedef TMenuEditItem MenuItem_##NAME @@ -150,7 +150,7 @@ DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); DEFINE_MENU_EDIT_ITEM_TYPE(float4 ,float ,ftostr4sign , 1 ); // 1234 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) -DEFINE_MENU_EDIT_ITEM_TYPE(float51 ,float ,ftostr51rj , 10 ); // 1234.5 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float61 ,float ,ftostr61rj , 10 ); // 12345.6 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(float31sign ,float ,ftostr31sign , 10 ); // +12.3 DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 ); // +123.4 DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 ); // +1234.5 diff --git a/Marlin/src/lcd/menu/menu_job_recovery.cpp b/Marlin/src/lcd/menu/menu_job_recovery.cpp index 963806b1d6b3..6329c5839786 100644 --- a/Marlin/src/lcd/menu/menu_job_recovery.cpp +++ b/Marlin/src/lcd/menu/menu_job_recovery.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, POWER_LOSS_RECOVERY) +#if BOTH(HAS_MARLINUI_MENU, POWER_LOSS_RECOVERY) #include "menu_item.h" #include "../../gcode/queue.h" @@ -54,4 +54,4 @@ void menu_job_recovery() { END_MENU(); } -#endif // HAS_LCD_MENU && POWER_LOSS_RECOVERY +#endif // HAS_MARLINUI_MENU && POWER_LOSS_RECOVERY diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 3261ecc65874..0c08f6fa944b 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU) +#if HAS_MARLINUI_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU) #include "menu_item.h" @@ -169,4 +169,4 @@ void menu_led() { END_MENU(); } -#endif // HAS_LCD_MENU && LED_CONTROL_MENU +#endif // HAS_MARLINUI_MENU && LED_CONTROL_MENU diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index aca10edc6a0c..a15653589523 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu_item.h" #include "../../module/temperature.h" @@ -249,7 +249,14 @@ void menu_main() { #if PIN_EXISTS(SD_DETECT) GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21")); // M21 Change Media #else // - or - - GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22")); // M22 Release Media + ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media + queue.inject(PSTR("M22")); + #if ENABLED(TFT_COLOR_UI) + // Menu display issue on item removal with multi language selection menu + if (encoderTopLine > 0) encoderTopLine--; + ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); + #endif + }); #endif SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) } @@ -373,7 +380,7 @@ void menu_main() { GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?") ); #else - GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81")); + ACTION_ITEM(MSG_SWITCH_PS_OFF, ui.poweroff); #endif else GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80")); @@ -454,4 +461,4 @@ void menu_main() { END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index 4ce0a396d4e4..db1baa9bee6f 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, SDSUPPORT) +#if BOTH(HAS_MARLINUI_MENU, SDSUPPORT) #include "menu_item.h" #include "../../sd/cardreader.h" @@ -161,4 +161,4 @@ void menu_media() { TERN(MULTI_VOLUME, menu_media_select, menu_media_filelist)(); } -#endif // HAS_LCD_MENU && SDSUPPORT +#endif // HAS_MARLINUI_MENU && SDSUPPORT diff --git a/Marlin/src/lcd/menu/menu_mixer.cpp b/Marlin/src/lcd/menu/menu_mixer.cpp index be4363574b26..f91f62ef8393 100644 --- a/Marlin/src/lcd/menu/menu_mixer.cpp +++ b/Marlin/src/lcd/menu/menu_mixer.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, MIXING_EXTRUDER) +#if BOTH(HAS_MARLINUI_MENU, MIXING_EXTRUDER) #include "menu_item.h" #include "menu_addon.h" @@ -275,4 +275,4 @@ void menu_mixer() { END_MENU(); } -#endif // HAS_LCD_MENU && MIXING_EXTRUDER +#endif // HAS_MARLINUI_MENU && MIXING_EXTRUDER diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index 99e5c0624517..4f3728b74e90 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if BOTH(HAS_LCD_MENU, MMU2_MENUS) +#if BOTH(HAS_MARLINUI_MENU, MMU2_MENUS) #include "../../MarlinCore.h" #include "../../feature/mmu/mmu2.h" @@ -167,4 +167,4 @@ uint8_t mmu2_choose_filament() { return feeder_index; } -#endif // HAS_LCD_MENU && MMU2_MENUS +#endif // HAS_MARLINUI_MENU && MMU2_MENUS diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index cddb7ede744d..0a446b1349e3 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || (Y_BED_SIZE) >= 1000 || (Z_MAX_POS) >= 1000) @@ -97,13 +97,13 @@ void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); } #if HAS_Z_AXIS void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); } #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS void lcd_move_i() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_I), I_AXIS); } #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS void lcd_move_j() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_J), J_AXIS); } #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS void lcd_move_k() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_K), K_AXIS); } #endif @@ -134,6 +134,15 @@ void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); } #endif // E_MANUAL +#if EITHER(PROBE_OFFSET_WIZARD, X_AXIS_TWIST_COMPENSATION) + + void _goto_manual_move_z(const_float_t scale) { + ui.manual_move.menu_scale = scale; + ui.goto_screen(lcd_move_z); + } + +#endif + // // "Motion" > "Move Xmm" > "Move XYZ" submenu // @@ -245,13 +254,13 @@ void menu_move() { #if HAS_Z_AXIS SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); }); #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS SUBMENU(MSG_MOVE_I, []{ _menu_move_distance(I_AXIS, lcd_move_i); }); #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS SUBMENU(MSG_MOVE_J, []{ _menu_move_distance(J_AXIS, lcd_move_j); }); #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS SUBMENU(MSG_MOVE_K, []{ _menu_move_distance(K_AXIS, lcd_move_k); }); #endif } @@ -336,14 +345,14 @@ void menu_move() { #if HAS_Z_AXIS GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, PSTR("G28Z")); #endif - #if LINEAR_AXES >= 4 - GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS4_STR)); + #if HAS_I_AXIS + GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_I)); #endif - #if LINEAR_AXES >= 5 - GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS5_STR)); + #if HAS_J_AXIS + GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_J)); #endif - #if LINEAR_AXES >= 6 - GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS6_STR)); + #if HAS_K_AXIS + GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_K)); #endif END_MENU(); @@ -389,14 +398,14 @@ void menu_motion() { #if HAS_Z_AXIS GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, PSTR("G28Z")); #endif - #if LINEAR_AXES >= 4 - GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS4_STR)); + #if HAS_I_AXIS + GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_I)); #endif - #if LINEAR_AXES >= 5 - GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS5_STR)); + #if HAS_J_AXIS + GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_J)); #endif - #if LINEAR_AXES >= 6 - GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS6_STR)); + #if HAS_K_AXIS + GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_K)); #endif #endif #endif @@ -468,4 +477,4 @@ void menu_motion() { END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index d3a35abff2e0..32059103b3f4 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, PASSWORD_FEATURE) +#if BOTH(HAS_MARLINUI_MENU, PASSWORD_FEATURE) #include "../../feature/password/password.h" @@ -184,4 +184,4 @@ void Password::menu_password() { END_MENU(); } -#endif // HAS_LCD_MENU && PASSWORD_FEATURE +#endif // HAS_MARLINUI_MENU && PASSWORD_FEATURE diff --git a/Marlin/src/lcd/menu/menu_power_monitor.cpp b/Marlin/src/lcd/menu/menu_power_monitor.cpp index b43327f63bc2..3cd9909e5cf7 100644 --- a/Marlin/src/lcd/menu/menu_power_monitor.cpp +++ b/Marlin/src/lcd/menu/menu_power_monitor.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && HAS_POWER_MONITOR +#if HAS_MARLINUI_MENU && HAS_POWER_MONITOR #include "menu_item.h" #include "../../feature/power_monitor.h" @@ -59,4 +59,4 @@ void menu_power_monitor() { END_MENU(); } -#endif // HAS_LCD_MENU && HAS_POWER_MONITOR +#endif // HAS_MARLINUI_MENU && HAS_POWER_MONITOR diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index 12b55969a39b..79db47005d0a 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -39,23 +39,13 @@ #include "../../feature/bedlevel/bedlevel.h" #endif +void _goto_manual_move_z(const_float_t); + // Global storage float z_offset_backup, calculated_z_offset, z_offset_ref; -#if HAS_LEVELING - bool leveling_was_active; -#endif - inline void z_clearance_move() { - do_z_clearance( - #ifdef Z_AFTER_HOMING - Z_AFTER_HOMING - #elif defined(Z_HOMING_HEIGHT) - Z_HOMING_HEIGHT - #else - 10 - #endif - ); + do_z_clearance(Z_POST_CLEARANCE); } void set_offset_and_go_back(const_float_t z) { @@ -65,11 +55,6 @@ void set_offset_and_go_back(const_float_t z) { ui.goto_previous_screen_no_defer(); } -void _goto_manual_move_z(const_float_t scale) { - ui.manual_move.menu_scale = scale; - ui.goto_screen(lcd_move_z); -} - void probe_offset_wizard_menu() { START_MENU(); calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; @@ -77,7 +62,7 @@ void probe_offset_wizard_menu() { if (LCD_HEIGHT >= 4) STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT); - STATIC_ITEM_P(PSTR("Z="), SS_CENTER, ftostr42_52(current_position.z)); + STATIC_ITEM_P(PSTR("Z"), SS_CENTER, ftostr42_52(current_position.z)); STATIC_ITEM(MSG_ZPROBE_ZOFFSET, SS_LEFT, ftostr42_52(calculated_z_offset)); SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move_z( 1); }); diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index 26f555ad620d..306d3d6c57df 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_LCD_MENU && HAS_CUTTER +#if HAS_MARLINUI_MENU && HAS_CUTTER #include "menu_item.h" @@ -74,11 +74,11 @@ ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse); #endif - #if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) + #if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency); #endif END_MENU(); } -#endif // HAS_LCD_MENU && HAS_CUTTER +#endif // HAS_MARLINUI_MENU && HAS_CUTTER diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 0e3688485804..fb539f006c14 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_LCD_MENU && HAS_TEMPERATURE +#if HAS_MARLINUI_MENU && HAS_TEMPERATURE #include "menu_item.h" #include "../../module/temperature.h" @@ -307,4 +307,4 @@ void menu_temperature() { #endif -#endif // HAS_LCD_MENU && HAS_TEMPERATURE +#endif // HAS_MARLINUI_MENU && HAS_TEMPERATURE diff --git a/Marlin/src/lcd/menu/menu_tmc.cpp b/Marlin/src/lcd/menu/menu_tmc.cpp index ad7d63205879..7e206e8d7990 100644 --- a/Marlin/src/lcd/menu/menu_tmc.cpp +++ b/Marlin/src/lcd/menu/menu_tmc.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && HAS_TRINAMIC_CONFIG +#if HAS_MARLINUI_MENU && HAS_TRINAMIC_CONFIG #include "menu_item.h" #include "../../module/stepper/indirection.h" @@ -38,13 +38,13 @@ void menu_tmc_current() { START_MENU(); BACK_ITEM(MSG_TMC_DRIVERS); #if AXIS_IS_TMC(X) - TMC_EDIT_STORED_I_RMS(X, STR_X); + TMC_EDIT_STORED_I_RMS(X, STR_A); #endif #if AXIS_IS_TMC(Y) - TMC_EDIT_STORED_I_RMS(Y, STR_Y); + TMC_EDIT_STORED_I_RMS(Y, STR_B); #endif #if AXIS_IS_TMC(Z) - TMC_EDIT_STORED_I_RMS(Z, STR_Z); + TMC_EDIT_STORED_I_RMS(Z, STR_C); #endif #if AXIS_IS_TMC(X2) TMC_EDIT_STORED_I_RMS(X2, STR_X2); @@ -62,28 +62,28 @@ void menu_tmc_current() { TMC_EDIT_STORED_I_RMS(Z4, STR_Z4); #endif #if AXIS_IS_TMC(E0) - TMC_EDIT_STORED_I_RMS(E0, LCD_STR_E0); + TMC_EDIT_STORED_I_RMS(E0, STR_E0); #endif #if AXIS_IS_TMC(E1) - TMC_EDIT_STORED_I_RMS(E1, LCD_STR_E1); + TMC_EDIT_STORED_I_RMS(E1, STR_E1); #endif #if AXIS_IS_TMC(E2) - TMC_EDIT_STORED_I_RMS(E2, LCD_STR_E2); + TMC_EDIT_STORED_I_RMS(E2, STR_E2); #endif #if AXIS_IS_TMC(E3) - TMC_EDIT_STORED_I_RMS(E3, LCD_STR_E3); + TMC_EDIT_STORED_I_RMS(E3, STR_E3); #endif #if AXIS_IS_TMC(E4) - TMC_EDIT_STORED_I_RMS(E4, LCD_STR_E4); + TMC_EDIT_STORED_I_RMS(E4, STR_E4); #endif #if AXIS_IS_TMC(E5) - TMC_EDIT_STORED_I_RMS(E5, LCD_STR_E5); + TMC_EDIT_STORED_I_RMS(E5, STR_E5); #endif #if AXIS_IS_TMC(E6) - TMC_EDIT_STORED_I_RMS(E6, LCD_STR_E6); + TMC_EDIT_STORED_I_RMS(E6, STR_E6); #endif #if AXIS_IS_TMC(E7) - TMC_EDIT_STORED_I_RMS(E7, LCD_STR_E7); + TMC_EDIT_STORED_I_RMS(E7, STR_E7); #endif END_MENU(); } @@ -103,14 +103,14 @@ void menu_tmc_current() { TERN_(Z2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z2, STR_Z2)); TERN_(Z3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z3, STR_Z3)); TERN_(Z4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z4, STR_Z4)); - TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E0, LCD_STR_E0)); - TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E1, LCD_STR_E1)); - TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E2, LCD_STR_E2)); - TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E3, LCD_STR_E3)); - TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E4, LCD_STR_E4)); - TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E5, LCD_STR_E5)); - TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E6, LCD_STR_E6)); - TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E7, LCD_STR_E7)); + TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E0, STR_E0)); + TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E1, STR_E1)); + TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E2, STR_E2)); + TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E3, STR_E3)); + TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E4, STR_E4)); + TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E5, STR_E5)); + TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E6, STR_E6)); + TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E7, STR_E7)); END_MENU(); } @@ -155,14 +155,14 @@ void menu_tmc_current() { TERN_(Z2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z2, STR_Z2)); TERN_(Z3_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z3, STR_Z3)); TERN_(Z4_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z4, STR_Z4)); - TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E0, LCD_STR_E0)); - TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E1, LCD_STR_E1)); - TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E2, LCD_STR_E2)); - TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E3, LCD_STR_E3)); - TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E4, LCD_STR_E4)); - TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E5, LCD_STR_E5)); - TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E6, LCD_STR_E6)); - TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E7, LCD_STR_E7)); + TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E0, STR_E0)); + TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E1, STR_E1)); + TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E2, STR_E2)); + TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E3, STR_E3)); + TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E4, STR_E4)); + TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E5, STR_E5)); + TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E6, STR_E6)); + TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E7, STR_E7)); END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_touch_screen.cpp b/Marlin/src/lcd/menu/menu_touch_screen.cpp index 5fc4b584d51e..130308dadffa 100644 --- a/Marlin/src/lcd/menu/menu_touch_screen.cpp +++ b/Marlin/src/lcd/menu/menu_touch_screen.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) +#if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) #include "menu_item.h" #include "../marlinui.h" diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 8e9d4b3942b6..7c241e09ece6 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, ASSISTED_TRAMMING_WIZARD) +#if BOTH(HAS_MARLINUI_MENU, ASSISTED_TRAMMING_WIZARD) #include "menu_item.h" @@ -36,6 +36,10 @@ #include "../../module/probe.h" #include "../../gcode/queue.h" +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + //#define DEBUG_OUT 1 #include "../../core/debug_out.h" @@ -51,7 +55,7 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true); + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN0(BLTOUCH, bltouch.high_speed_mode) ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); @@ -105,4 +109,4 @@ void goto_tramming_wizard() { }); } -#endif // HAS_LCD_MENU && ASSISTED_TRAMMING_WIZARD +#endif // HAS_MARLINUI_MENU && ASSISTED_TRAMMING_WIZARD diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index b3f078d7a05d..854f36985f84 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu_item.h" #include "../../module/motion.h" @@ -236,4 +236,4 @@ void menu_tune() { END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index a08eceed7797..c7ffd414cb7f 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL) +#if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL) #include "menu_item.h" #include "../../gcode/gcode.h" @@ -684,4 +684,4 @@ void _lcd_ubl_level_bed() { END_MENU(); } -#endif // HAS_LCD_MENU && AUTO_BED_LEVELING_UBL +#endif // HAS_MARLINUI_MENU && AUTO_BED_LEVELING_UBL diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp new file mode 100644 index 000000000000..ce46053dfc34 --- /dev/null +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -0,0 +1,226 @@ +/** + * 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 . + * + */ +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + +#include "menu_item.h" +#include "menu_addon.h" +#include "../../module/planner.h" +#include "../../feature/bedlevel/bedlevel.h" +#include "../../feature/x_twist.h" +#include "../../module/motion.h" +#include "../../gcode/queue.h" +#include "../../module/probe.h" + +#ifndef XATC_Y_POSITION + #define XATC_Y_POSITION ((probe.max_y() - probe.min_y())/2) +#endif + +void _goto_manual_move_z(const_float_t); + +float measured_z, z_offset; + +// +// Step 9: X Axis Twist Compensation Wizard is finished. +// +void xatc_wizard_done() { + if (!ui.wait_for_move) { + xatc.print_points(); + set_bed_leveling_enabled(leveling_was_active); + SET_SOFT_ENDSTOP_LOOSE(false); + ui.goto_screen(menu_advanced_settings); + } + if (ui.should_draw()) + MenuItem_static::draw(LCD_HEIGHT >= 4, GET_TEXT(MSG_XATC_DONE)); + ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); +} + +void xatc_wizard_goto_next_point(); + +// +// Step 8: Ask the user if he wants to update the z-offset of the probe +// +void xatc_wizard_update_z_offset() { + MenuItem_confirm::select_screen( + GET_TEXT(MSG_YES), GET_TEXT(MSG_NO) + , []{ + probe.offset.z = z_offset; + ui.goto_screen(xatc_wizard_done); + } + , xatc_wizard_done + , GET_TEXT(MSG_XATC_UPDATE_Z_OFFSET) + , ftostr42_52(z_offset), PSTR("?") + ); +} + +// +// Step 7: Set the Z-offset for this point and go to the next one. +// +void xatc_wizard_set_offset_and_go_to_next_point() { + // Set Z-offset at probed point + xatc.z_offset[manual_probe_index++] = probe.offset.z + current_position.z - measured_z; + // Go to next point + ui.goto_screen(xatc_wizard_goto_next_point); +} + +// +// Step 6: Wizard Menu. Move the nozzle down until it touches the bed. +// +void xatc_wizard_menu() { + START_MENU(); + float calculated_z_offset = probe.offset.z + current_position.z - measured_z; + + if (LCD_HEIGHT >= 4) + STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT); + + STATIC_ITEM_P(PSTR("Z="), SS_CENTER, ftostr42_52(current_position.z)); + STATIC_ITEM(MSG_ZPROBE_ZOFFSET, SS_LEFT, ftostr42_52(calculated_z_offset)); + + SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move_z( 1); }); + SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move_z( 0.1f); }); + + if ((FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) { + char tmp[20], numstr[10]; + // Determine digits needed right of decimal + const uint8_t digs = !UNEAR_ZERO((FINE_MANUAL_MOVE) * 1000 - int((FINE_MANUAL_MOVE) * 1000)) ? 4 : + !UNEAR_ZERO((FINE_MANUAL_MOVE) * 100 - int((FINE_MANUAL_MOVE) * 100)) ? 3 : 2; + sprintf_P(tmp, GET_TEXT(MSG_MOVE_N_MM), dtostrf(FINE_MANUAL_MOVE, 1, digs, numstr)); + #if DISABLED(HAS_GRAPHICAL_TFT) + SUBMENU_P(NUL_STR, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); }); + MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780)); + lcd_put_u8str(tmp); + MENU_ITEM_ADDON_END(); + #else + SUBMENU_P(tmp, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); }); + #endif + } + + ACTION_ITEM(MSG_BUTTON_DONE, xatc_wizard_set_offset_and_go_to_next_point); + + END_MENU(); +} + +// +// Step 5: Display "Next point: 1 / 9" while waiting for move to finish +// +void xatc_wizard_moving() { + if (ui.should_draw()) { + char msg[10]; + sprintf_P(msg, PSTR("%i / %u"), manual_probe_index + 1, XATC_MAX_POINTS); + MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_LEVEL_BED_NEXT_POINT), msg); + } + ui.refresh(LCDVIEW_CALL_NO_REDRAW); + if (!ui.wait_for_move) ui.goto_screen(xatc_wizard_menu); +} + +// +// Step 4: Initiate a move to the next point +// +void xatc_wizard_goto_next_point() { + if (manual_probe_index < XATC_MAX_POINTS) { + + const float x = xatc.start + manual_probe_index * xatc.spacing; + + // Avoid probing outside the round or hexagonal area + if (!TERN0(IS_KINEMATIC, !probe.can_reach(x, XATC_Y_POSITION))) { + ui.wait_for_move = true; + ui.goto_screen(xatc_wizard_moving); + + // Deploy certain probes before starting probing + TERN_(BLTOUCH, do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE)); + + xatc.set_enabled(false); + measured_z = probe.probe_at_point(x, XATC_Y_POSITION, PROBE_PT_STOW); + xatc.set_enabled(true); + current_position += probe.offset_xy; + current_position.z = (XATC_START_Z) - probe.offset.z + measured_z; + line_to_current_position(MMM_TO_MMS(XY_PROBE_FEEDRATE)); + ui.wait_for_move = false; + } + else + manual_probe_index++; // Go to next point + } + else { + // Compute the z-offset by averaging the values found with this wizard + z_offset = 0; + LOOP_L_N(i, XATC_MAX_POINTS) z_offset += xatc.z_offset[i]; + z_offset /= XATC_MAX_POINTS; + + // Subtract the average from the values found with this wizard. + // This way they are indipendent from the z-offset + LOOP_L_N(i, XATC_MAX_POINTS) xatc.z_offset[i] -= z_offset; + + ui.goto_screen(xatc_wizard_update_z_offset); + } +} + +// +// Step 3: Display "Click to Begin", wait for click +// Move to the first probe position +// +void xatc_wizard_homing_done() { + if (ui.should_draw()) { + MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING)); + + // Color UI needs a control to detect a touch + #if BOTH(TOUCH_SCREEN, HAS_GRAPHICAL_TFT) + touch.add_control(CLICK, 0, 0, TFT_WIDTH, TFT_HEIGHT); + #endif + } + + if (ui.use_click()) { + xatc.reset(); + + SET_SOFT_ENDSTOP_LOOSE(true); // Disable soft endstops for free Z movement + + ui.goto_screen(xatc_wizard_goto_next_point); + } +} + +// +// Step 2: Display "Homing XYZ" - Wait for homing to finish +// +void xatc_wizard_homing() { + _lcd_draw_homing(); + if (all_axes_homed()) + ui.goto_screen(xatc_wizard_homing_done); +} + +// +// Step 1: Prepare for the wizard... +// +void xatc_wizard_continue() { + // Store Bed-Leveling-State and disable + #if HAS_LEVELING + leveling_was_active = planner.leveling_active; + set_bed_leveling_enabled(false); + #endif + + // Home all axes + ui.defer_status_screen(); + set_all_unhomed(); + ui.goto_screen(xatc_wizard_homing); + queue.inject_P(G28_STR); +} + +#endif // X_AXIS_TWIST_COMPENSATION diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index 1576518b4bb7..435e7c30bf51 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -81,24 +81,24 @@ class TFT { static uint16_t buffer[TFT_BUFFER_SIZE]; static void init(); - static inline void set_font(const uint8_t *Font) { string.set_font(Font); } - static inline void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); } + static void set_font(const uint8_t *Font) { string.set_font(Font); } + static void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); } - static inline bool is_busy() { return io.isBusy(); } - static inline void abort() { io.Abort(); } - static inline void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); } - static inline void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); } - static inline void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); } + static bool is_busy() { return io.isBusy(); } + static void abort() { io.Abort(); } + static void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); } + static void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); } + static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); } - static inline void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); } - static inline void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); } - static inline void set_background(uint16_t color) { queue.set_background(color); } - static inline void add_text(uint16_t x, uint16_t y, uint16_t color, TFT_String tft_string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, tft_string.string(), maxWidth); } - static inline void add_text(uint16_t x, uint16_t y, uint16_t color, const char *string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, (uint8_t *)string, maxWidth); } - static inline void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) { queue.add_image(x, y, image, colors); } - static inline void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t color_main = COLOR_WHITE, uint16_t color_background = COLOR_BACKGROUND, uint16_t color_shadow = COLOR_BLACK) { queue.add_image(x, y, image, color_main, color_background, color_shadow); } - static inline void add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_bar(x, y, width, height, color); } - static inline void add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_rectangle(x, y, width, height, color); } + static void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); } + static void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); } + static void set_background(uint16_t color) { queue.set_background(color); } + static void add_text(uint16_t x, uint16_t y, uint16_t color, TFT_String tft_string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, tft_string.string(), maxWidth); } + static void add_text(uint16_t x, uint16_t y, uint16_t color, const char *string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, (uint8_t *)string, maxWidth); } + static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) { queue.add_image(x, y, image, colors); } + static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t color_main = COLOR_WHITE, uint16_t color_background = COLOR_BACKGROUND, uint16_t color_shadow = COLOR_BLACK) { queue.add_image(x, y, image, color_main, color_background, color_shadow); } + static void add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_bar(x, y, width, height, color); } + static void add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_rectangle(x, y, width, height, color); } static void draw_edit_screen_buttons(); }; diff --git a/Marlin/src/lcd/tft/tft_string.h b/Marlin/src/lcd/tft/tft_string.h index 133889d9ae54..e486c2ee91c8 100644 --- a/Marlin/src/lcd/tft/tft_string.h +++ b/Marlin/src/lcd/tft/tft_string.h @@ -81,7 +81,7 @@ class TFT_String { static font_t *font() { return font_header; }; static uint16_t font_height() { return font_header->FontAscent - font_header->FontDescent; } static glyph_t *glyph(uint8_t character) { return glyphs[character] ?: glyphs[0x3F]; } /* Use '?' for unknown glyphs */ - static inline glyph_t *glyph(uint8_t *character) { return glyph(*character); } + static glyph_t *glyph(uint8_t *character) { return glyph(*character); } static void set(); static void add(uint8_t character) { add_character(character); eol(); } @@ -89,9 +89,9 @@ class TFT_String { static void add(uint8_t *string, int8_t index, uint8_t *itemString=nullptr); static void set(uint8_t *string) { set(); add(string); }; static void set(uint8_t *string, int8_t index, const char *itemString=nullptr) { set(); add(string, index, (uint8_t *)itemString); }; - static inline void set(const char *string) { set((uint8_t *)string); } - static inline void set(const char *string, int8_t index, const char *itemString=nullptr) { set((uint8_t *)string, index, itemString); } - static inline void add(const char *string) { add((uint8_t *)string); } + static void set(const char *string) { set((uint8_t *)string); } + static void set(const char *string, int8_t index, const char *itemString=nullptr) { set((uint8_t *)string, index, itemString); } + static void add(const char *string) { add((uint8_t *)string); } static void trim(uint8_t character=0x20); static void rtrim(uint8_t character=0x20); diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index dc1f2ecb6c13..a04715a2952d 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -287,15 +287,17 @@ bool Touch::get_point(int16_t *x, int16_t *y) { #if HAS_TOUCH_SLEEP void Touch::sleepTimeout() { - #if PIN_EXISTS(TFT_BACKLIGHT) - OUT_WRITE(TFT_BACKLIGHT_PIN, LOW); + #if HAS_LCD_BRIGHTNESS + ui.set_brightness(0); + #elif PIN_EXISTS(TFT_BACKLIGHT) + WRITE(TFT_BACKLIGHT_PIN, LOW); #endif next_sleep_ms = TSLP_SLEEPING; } void Touch::wakeUp() { if (isSleeping()) { #if HAS_LCD_BRIGHTNESS - ui._set_brightness(); + ui.set_brightness(ui.brightness); #elif PIN_EXISTS(TFT_BACKLIGHT) WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif diff --git a/Marlin/src/lcd/tft/touch.h b/Marlin/src/lcd/tft/touch.h index 238453f765ed..6021a840b65e 100644 --- a/Marlin/src/lcd/tft/touch.h +++ b/Marlin/src/lcd/tft/touch.h @@ -106,7 +106,7 @@ class Touch { static millis_t last_touch_ms, time_to_hold, repeat_delay, touch_time; static TouchControlType touch_control_type; - static inline bool get_point(int16_t *x, int16_t *y); + static bool get_point(int16_t *x, int16_t *y); static void touch(touch_control_t *control); static void hold(touch_control_t *control, millis_t delay = 0); @@ -126,7 +126,7 @@ class Touch { static void enable() { enabled = true; } #if HAS_TOUCH_SLEEP static millis_t next_sleep_ms; - static inline bool isSleeping() { return next_sleep_ms == TSLP_SLEEPING; } + static bool isSleeping() { return next_sleep_ms == TSLP_SLEEPING; } static void sleepTimeout(); static void wakeUp(); #endif diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 3f0c70ab4ce2..7c3d04345f48 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -258,21 +258,31 @@ void MarlinUI::draw_status_screen() { tft.set_background(COLOR_BACKGROUND); tft.add_rectangle(0, 0, TFT_WIDTH - 8, FONT_LINE_HEIGHT, COLOR_AXIS_HOMED); - tft.add_text(200, 3, COLOR_AXIS_HOMED , "X"); - tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y"); + if (TERN0(LCD_SHOW_E_TOTAL, printingIsActive())) { + #if ENABLED(LCD_SHOW_E_TOTAL) + tft.add_text(200, 3, COLOR_AXIS_HOMED , "E"); + const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm + tft_string.set(ftostr4sign(e_move_accumulator / escale)); + tft_string.add(escale == 10 ? 'c' : 'm'); + tft_string.add('m'); + tft.add_text(500 - tft_string.width(), 3, COLOR_AXIS_HOMED, tft_string); + #endif + } + else { + tft.add_text(200, 3, COLOR_AXIS_HOMED , "X"); + const bool nhx = axis_should_home(X_AXIS); + tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); + tft.add_text(300 - tft_string.width(), 3, nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + + tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y"); + const bool nhy = axis_should_home(Y_AXIS); + tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); + tft.add_text(600 - tft_string.width(), 3, nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + } tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z"); - - bool not_homed = axis_should_home(X_AXIS); - tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); - tft.add_text(300 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); - - not_homed = axis_should_home(Y_AXIS); - tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); - tft.add_text(600 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); - uint16_t offset = 32; - not_homed = axis_should_home(Z_AXIS); - if (blink && not_homed) + const bool nhz = axis_should_home(Z_AXIS); + if (blink && nhz) tft_string.set("?"); else { const float z = LOGICAL_Z_POSITION(current_position.z); @@ -283,7 +293,7 @@ void MarlinUI::draw_status_screen() { tft_string.set(ftostr52sp(z)); offset -= tft_string.width(); } - tft.add_text(900 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + tft.add_text(900 - tft_string.width() - offset, 3, nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT)); y += 100; @@ -586,9 +596,9 @@ MotionAxisState motionAxisState; static void quick_feedback() { #if HAS_CHIRP ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_LCD_MENU, USE_BEEPER) + #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER) for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_LCD_MENU + #elif HAS_MARLINUI_MENU delay(10); #endif #endif diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 1ef4c5881c24..812a03594795 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -256,21 +256,32 @@ void MarlinUI::draw_status_screen() { tft.set_background(COLOR_BACKGROUND); tft.add_rectangle(0, 0, 312, 24, COLOR_AXIS_HOMED); - tft.add_text( 10, 3, COLOR_AXIS_HOMED , "X"); - tft.add_text(127, 3, COLOR_AXIS_HOMED , "Y"); - tft.add_text(219, 3, COLOR_AXIS_HOMED , "Z"); - - bool not_homed = axis_should_home(X_AXIS); - tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); - tft.add_text( 68 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); - - not_homed = axis_should_home(Y_AXIS); - tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); - tft.add_text(185 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + if (TERN0(LCD_SHOW_E_TOTAL, printingIsActive())) { + #if ENABLED(LCD_SHOW_E_TOTAL) + tft.add_text( 10, 3, COLOR_AXIS_HOMED , "E"); + const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm + tft_string.set(ftostr4sign(e_move_accumulator / escale)); + tft_string.add(escale == 10 ? 'c' : 'm'); + tft_string.add('m'); + tft.add_text(127 - tft_string.width(), 3, COLOR_AXIS_HOMED, tft_string); + #endif + } + else { + tft.add_text( 10, 3, COLOR_AXIS_HOMED , "X"); + const bool nhx = axis_should_home(X_AXIS); + tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); + tft.add_text( 68 - tft_string.width(), 3, nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + + tft.add_text(127, 3, COLOR_AXIS_HOMED , "Y"); + const bool nhy = axis_should_home(Y_AXIS); + tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); + tft.add_text(185 - tft_string.width(), 3, nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + } - not_homed = axis_should_home(Z_AXIS); + tft.add_text(219, 3, COLOR_AXIS_HOMED , "Z"); + const bool nhz = axis_should_home(Z_AXIS); uint16_t offset = 25; - if (blink && not_homed) + if (blink && nhz) tft_string.set("?"); else { const float z = LOGICAL_Z_POSITION(current_position.z); @@ -281,7 +292,7 @@ void MarlinUI::draw_status_screen() { tft_string.set(ftostr52sp(z)); offset -= tft_string.width(); } - tft.add_text(301 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + tft.add_text(301 - tft_string.width() - offset, 3, nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 0, 103, 312, 24)); // feed rate @@ -429,8 +440,8 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); } #if ENABLED(TOUCH_SCREEN) - add_control(48, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); - add_control(208, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); + if (no) add_control( 48, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); + if (yes) add_control(208, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); #endif } @@ -567,9 +578,9 @@ MotionAxisState motionAxisState; static void quick_feedback() { #if HAS_CHIRP ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_LCD_MENU, USE_BEEPER) + #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER) for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_LCD_MENU + #elif HAS_MARLINUI_MENU delay(10); #endif #endif diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index f6591d682dc1..f142dbbc06c1 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -258,21 +258,31 @@ void MarlinUI::draw_status_screen() { tft.set_background(COLOR_BACKGROUND); tft.add_rectangle(0, 0, TFT_WIDTH - 8, FONT_LINE_HEIGHT, COLOR_AXIS_HOMED); - tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X"); - tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y"); + if (TERN0(LCD_SHOW_E_TOTAL, printingIsActive())) { + #if ENABLED(LCD_SHOW_E_TOTAL) + tft.add_text( 16, 3, COLOR_AXIS_HOMED , "E"); + const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm + tft_string.set(ftostr4sign(e_move_accumulator / escale)); + tft_string.add(escale == 10 ? 'c' : 'm'); + tft_string.add('m'); + tft.add_text(192 - tft_string.width(), 3, COLOR_AXIS_HOMED, tft_string); + #endif + } + else { + tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X"); + const bool nhx = axis_should_home(X_AXIS); + tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); + tft.add_text(102 - tft_string.width(), 3, nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + + tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y"); + const bool nhy = axis_should_home(Y_AXIS); + tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); + tft.add_text(280 - tft_string.width(), 3, nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + } tft.add_text(330, 3, COLOR_AXIS_HOMED , "Z"); - - bool not_homed = axis_should_home(X_AXIS); - tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); - tft.add_text(102 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); - - not_homed = axis_should_home(Y_AXIS); - tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); - tft.add_text(280 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); - uint16_t offset = 32; - not_homed = axis_should_home(Z_AXIS); - if (blink && not_homed) + const bool nhz = axis_should_home(Z_AXIS); + if (blink && nhz) tft_string.set("?"); else { const float z = LOGICAL_Z_POSITION(current_position.z); @@ -283,7 +293,7 @@ void MarlinUI::draw_status_screen() { tft_string.set(ftostr52sp(z)); offset -= tft_string.width(); } - tft.add_text(455 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + tft.add_text(455 - tft_string.width() - offset, 3, nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT)); y += TERN(HAS_UI_480x272, 38, 48); @@ -435,8 +445,8 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); } #if ENABLED(TOUCH_SCREEN) - add_control(88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); - add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); + if (no) add_control( 88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); + if (yes) add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); #endif } @@ -573,9 +583,9 @@ MotionAxisState motionAxisState; static void quick_feedback() { #if HAS_CHIRP ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_LCD_MENU, USE_BEEPER) + #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER) for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_LCD_MENU + #elif HAS_MARLINUI_MENU delay(10); #endif #endif diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index 65602240d63a..50b921cd2a93 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -121,6 +121,11 @@ class TFT_IO { inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); }; inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }; + + #if ENABLED(USE_SPI_DMA_TC) + inline static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { io.WriteSequenceIT(Data, Count); }; + #endif + // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); }; diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 4f6dd23ece90..2571efe0759c 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -70,6 +70,10 @@ #define THERMISTOR_NAME "Zonestar (P802M Hot Bed)" #elif THERMISTOR_ID == 503 #define THERMISTOR_NAME "Zonestar (Z8XM2 Bed)" +#elif THERMISTOR_ID == 504 + #define THERMISTOR_NAME "Zonestar (P802QR2 Hot End)" +#elif THERMISTOR_ID == 505 + #define THERMISTOR_NAME "Zonestar (P802QR2 Bed)" #elif THERMISTOR_ID == 512 #define THERMISTOR_NAME "RPW-Ultra" #elif THERMISTOR_ID == 6 diff --git a/Marlin/src/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp index feaba8483b27..dcdc7def8667 100644 --- a/Marlin/src/lcd/touch/touch_buttons.cpp +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -79,7 +79,7 @@ uint8_t TouchButtons::read_buttons() { #if ENABLED(TOUCH_SCREEN_CALIBRATION) const calibrationState state = touch_calibration.get_calibration_state(); - if (state >= CALIBRATION_TOP_LEFT && state <= CALIBRATION_BOTTOM_RIGHT) { + if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_RIGHT)) { if (touch_calibration.handleTouch(x, y)) ui.refresh(); return 0; } @@ -115,15 +115,17 @@ uint8_t TouchButtons::read_buttons() { #if HAS_TOUCH_SLEEP void TouchButtons::sleepTimeout() { - #if PIN_EXISTS(TFT_BACKLIGHT) - OUT_WRITE(TFT_BACKLIGHT_PIN, LOW); + #if HAS_LCD_BRIGHTNESS + ui.set_brightness(0); + #elif PIN_EXISTS(TFT_BACKLIGHT) + WRITE(TFT_BACKLIGHT_PIN, LOW); #endif next_sleep_ms = TSLP_SLEEPING; } void TouchButtons::wakeUp() { if (isSleeping()) { #if HAS_LCD_BRIGHTNESS - ui._set_brightness(); + ui.set_brightness(ui.brightness); #elif PIN_EXISTS(TFT_BACKLIGHT) WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index 6f80652ce5b4..a8c2695630d6 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -39,7 +39,7 @@ L64XX_Marlin L64xxManager; static const char LINEAR_AXIS_LIST( str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ", - str_I[] PROGMEM = AXIS4_STR " ", str_J[] PROGMEM = AXIS5_STR " ", str_K[] PROGMEM = AXIS6_STR " " + str_I[] PROGMEM = STR_I " ", str_J[] PROGMEM = STR_J " ", str_K[] PROGMEM = STR_K " " ), str_X2[] PROGMEM = "X2", str_Y2[] PROGMEM = "Y2", str_Z2[] PROGMEM = "Z2", str_Z3[] PROGMEM = "Z3", str_Z4[] PROGMEM = "Z4", @@ -497,7 +497,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in } break; #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case AXIS4_NAME: { position_min = I_center - displacement; position_max = I_center + displacement; @@ -509,7 +509,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in } break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case AXIS5_NAME: { position_min = J_center - displacement; position_max = J_center + displacement; @@ -521,7 +521,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in } break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case AXIS6_NAME: { position_min = K_center - displacement; position_max = K_center + displacement; diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.h b/Marlin/src/libs/L64XX/L64XX_Marlin.h index e11d8e872e60..de7c0d605740 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.h +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.h @@ -118,11 +118,11 @@ class L64XX_Marlin : public L64XXHelper { #if ENABLED(MONITOR_L6470_DRIVER_STATUS) static bool monitor_paused; - static inline void pause_monitor(const bool p) { monitor_paused = p; } + static void pause_monitor(const bool p) { monitor_paused = p; } static void monitor_update(L64XX_axis_t stepper_index); static void monitor_driver(); #else - static inline void pause_monitor(const bool) {} + static void pause_monitor(const bool) {} #endif //protected: diff --git a/Marlin/src/libs/MAX31865.cpp b/Marlin/src/libs/MAX31865.cpp index 94048af2089c..c042504cf872 100644 --- a/Marlin/src/libs/MAX31865.cpp +++ b/Marlin/src/libs/MAX31865.cpp @@ -40,20 +40,19 @@ * All rights reserved. */ -// Useful for RTD debugging. -//#define MAX31865_DEBUG -//#define MAX31865_DEBUG_SPI - #include "../inc/MarlinConfig.h" #if HAS_MAX31865 && !USE_ADAFRUIT_MAX31865 #include "MAX31865.h" -#ifdef TARGET_LPC1768 - #include +#ifndef MAX31865_MIN_SAMPLING_TIME_MSEC + #define MAX31865_MIN_SAMPLING_TIME_MSEC 0 #endif +#define DEBUG_OUT ENABLED(DEBUG_MAX31865) +#include "../core/debug_out.h" + // The maximum speed the MAX31865 can do is 5 MHz SPISettings MAX31865::spiConfig = SPISettings( TERN(TARGET_LPC1768, SPI_QUARTER_SPEED, TERN(ARDUINO_ARCH_STM32, SPI_CLOCK_DIV4, 500000)), @@ -61,7 +60,7 @@ SPISettings MAX31865::spiConfig = SPISettings( SPI_MODE1 // CPOL0 CPHA1 ); -#ifndef LARGE_PINMAP +#if DISABLED(LARGE_PINMAP) /** * Create the interface object using software (bitbang) SPI for PIN values @@ -73,10 +72,10 @@ SPISettings MAX31865::spiConfig = SPISettings( * @param spi_clk the SPI clock pin to use */ MAX31865::MAX31865(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, int8_t spi_clk) { - _cs = spi_cs; - _mosi = spi_mosi; - _miso = spi_miso; - _sclk = spi_clk; + cselPin = spi_cs; + mosiPin = spi_mosi; + misoPin = spi_miso; + sclkPin = spi_clk; } /** @@ -86,8 +85,8 @@ SPISettings MAX31865::spiConfig = SPISettings( * @param spi_cs the SPI CS pin to use along with the default SPI device */ MAX31865::MAX31865(int8_t spi_cs) { - _cs = spi_cs; - _sclk = _miso = _mosi = -1; + cselPin = spi_cs; + sclkPin = misoPin = mosiPin = -1; } #else // LARGE_PINMAP @@ -104,10 +103,10 @@ SPISettings MAX31865::spiConfig = SPISettings( * @param pin_mapping set to 1 for positive pin values */ MAX31865::MAX31865(uint32_t spi_cs, uint32_t spi_mosi, uint32_t spi_miso, uint32_t spi_clk, uint8_t pin_mapping) { - _cs = spi_cs; - _mosi = spi_mosi; - _miso = spi_miso; - _sclk = spi_clk; + cselPin = spi_cs; + mosiPin = spi_mosi; + misoPin = spi_miso; + sclkPin = spi_clk; } /** @@ -119,8 +118,8 @@ SPISettings MAX31865::spiConfig = SPISettings( * @param pin_mapping set to 1 for positive pin values */ MAX31865::MAX31865(uint32_t spi_cs, uint8_t pin_mapping) { - _cs = spi_cs; - _sclk = _miso = _mosi = -1UL; //-1UL or 0xFFFFFFFF or 4294967295 + cselPin = spi_cs; + sclkPin = misoPin = mosiPin = -1UL; //-1UL or 0xFFFFFFFF or 4294967295 } #endif // LARGE_PINMAP @@ -137,117 +136,229 @@ SPISettings MAX31865::spiConfig = SPISettings( * @param wires The number of wires in enum format. Can be MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE. * @param zero The resistance of the RTD at 0 degC, in ohms. * @param ref The resistance of the reference resistor, in ohms. + * @param wire The resistance of the wire connecting the sensor to the RTD, in ohms. */ -void MAX31865::begin(max31865_numwires_t wires, float zero, float ref) { - Rzero = zero; - Rref = ref; +void MAX31865::begin(max31865_numwires_t wires, float zero_res, float ref_res, float wire_res) { + zeroRes = zero_res; + refRes = ref_res; + wireRes = wire_res; - OUT_WRITE(_cs, HIGH); + pinMode(cselPin, OUTPUT); + digitalWrite(cselPin, HIGH); - if (_sclk != TERN(LARGE_PINMAP, -1UL, -1)) { - softSpiBegin(SPI_QUARTER_SPEED); // Define pin modes for Software SPI - } + if (sclkPin != TERN(LARGE_PINMAP, -1UL, 255)) + softSpiInit(); // Define pin modes for Software SPI else { - #ifdef MAX31865_DEBUG - SERIAL_ECHOLNPGM("Initializing MAX31865 Hardware SPI"); - #endif + DEBUG_ECHOLNPGM("Init MAX31865 Hardware SPI"); SPI.begin(); // Start and configure hardware SPI } - setWires(wires); - enableBias(false); - autoConvert(false); - clearFault(); + initFixedFlags(wires); + + DEBUG_ECHOLNPGM("MAX31865 Regs: CFG ", readRegister8(MAX31865_CONFIG_REG), + "|RTD ", readRegister16(MAX31865_RTDMSB_REG), + "|HTHRS ", readRegister16(MAX31865_HFAULTMSB_REG), + "|LTHRS ", readRegister16(MAX31865_LFAULTMSB_REG), + "|FLT ", readRegister8(MAX31865_FAULTSTAT_REG)); + + // fault detection cycle seems to initialize the sensor better + runAutoFaultDetectionCycle(); // also initializes flags + + if (lastFault) + SERIAL_ECHOLNPGM("MAX31865 init fault ", lastFault); + + writeRegister16(MAX31865_HFAULTMSB_REG, 0xFFFF); + writeRegister16(MAX31865_LFAULTMSB_REG, 0); + + #if ENABLED(MAX31865_USE_AUTO_MODE) // make a proper first read to initialize _lastRead + + uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG); + + #if MAX31865_IGNORE_INITIAL_FAULTY_READS > 0 + rtd = fixFault(rtd); + #endif + + if (rtd & 1) { + lastRead = 0xFFFF; // some invalid value + lastFault = readRegister8(MAX31865_FAULTSTAT_REG); + clearFault(); // also clears the bias voltage flag, so no further action is required + + DEBUG_ECHOLNPGM("MAX31865 read fault: ", rtd); + } + else { + DEBUG_ECHOLNPGM("RTD MSB:", (rtd >> 8), " RTD LSB:", (rtd & 0x00FF)); + lastRead = rtd; + TERN_(MAX31865_USE_READ_ERROR_DETECTION, lastReadStamp = millis()); + } - #ifdef MAX31865_DEBUG_SPI - SERIAL_ECHOLNPGM( - TERN(LARGE_PINMAP, "LARGE_PINMAP", "Regular") - " begin call with _cs: ", _cs, - " _miso: ", _miso, - " _sclk: ", _sclk, - " _mosi: ", _mosi, - " config: ", readRegister8(MAX31856_CONFIG_REG) + #else + + enableBias(); + DELAY_US(2000); // according to the datasheet, 10.5τ+1msec (see below) + oneShot(); + DELAY_US(63000); + uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG); + + #if MAX31865_IGNORE_INITIAL_FAULTY_READS > 0 + rtd = fixFault(rtd); + #endif + + if (rtd & 1) { + lastRead = 0xFFFF; // some invalid value + lastFault = readRegister8(MAX31865_FAULTSTAT_REG); + clearFault(); // also clears the bias voltage flag, so no further action is required + + DEBUG_ECHOLNPGM("MAX31865 read fault: ", rtd); + } + else { + DEBUG_ECHOLNPGM("RTD MSB:", (rtd >> 8), " RTD LSB:", (rtd & 0x00FF)); + + resetFlags(); + + lastRead = rtd; + nextEvent = SETUP_BIAS_VOLTAGE; + millis_t now = millis(); + nextEventStamp = now + MAX31865_MIN_SAMPLING_TIME_MSEC; + + TERN_(MAX31865_USE_READ_ERROR_DETECTION, lastReadStamp = now); + } + + #endif // MAX31865_USE_AUTO_MODE + + DEBUG_ECHOLNPGM( + TERN(LARGE_PINMAP, "LARGE_PINMAP", "Regular") + " begin call with cselPin: ", cselPin, + " misoPin: ", misoPin, + " sclkPin: ", sclkPin, + " mosiPin: ", mosiPin, + " config: ", readRegister8(MAX31865_CONFIG_REG) ); - #endif } /** - * Read the raw 8-bit FAULTSTAT register + * Return and clear the last fault value * - * @return The raw unsigned 8-bit FAULT status register + * @return The raw unsigned 8-bit FAULT status register or spike fault */ uint8_t MAX31865::readFault() { - return readRegister8(MAX31856_FAULTSTAT_REG); + uint8_t r = lastFault; + lastFault = 0; + return r; } /** - * Clear all faults in FAULTSTAT. + * Clear last fault */ void MAX31865::clearFault() { - setConfig(MAX31856_CONFIG_FAULTSTAT, 1); -} - -/** - * Whether we want to have continuous conversions (50/60 Hz) - * - * @param b If true, auto conversion is enabled - */ -void MAX31865::autoConvert(bool b) { - setConfig(MAX31856_CONFIG_MODEAUTO, b); + setConfig(MAX31865_CONFIG_FAULTSTAT, 1); } /** - * Whether we want filter out 50Hz noise or 60Hz noise - * - * @param b If true, 50Hz noise is filtered, else 60Hz(default) + * Reset flags */ -void MAX31865::enable50HzFilter(bool b) { - setConfig(MAX31856_CONFIG_FILT50HZ, b); +void MAX31865::resetFlags() { + writeRegister8(MAX31865_CONFIG_REG, stdFlags); } /** * Enable the bias voltage on the RTD sensor - * - * @param b If true bias is enabled, else disabled */ -void MAX31865::enableBias(bool b) { - setConfig(MAX31856_CONFIG_BIAS, b); - - // From the datasheet: - // Note that if VBIAS is off (to reduce supply current between conversions), any filter - // capacitors at the RTDIN inputs need to charge before an accurate conversion can be - // performed. Therefore, enable VBIAS and wait at least 10.5 time constants of the input - // RC network plus an additional 1ms before initiating the conversion. - if (b) - DELAY_US(11500); //11.5ms +void MAX31865::enableBias() { + setConfig(MAX31865_CONFIG_BIAS, 1); } /** * Start a one-shot temperature reading. */ void MAX31865::oneShot() { - setConfig(MAX31856_CONFIG_1SHOT, 1); + setConfig(MAX31865_CONFIG_1SHOT | MAX31865_CONFIG_BIAS, 1); +} - // From the datasheet: - // Note that a single conversion requires approximately 52ms in 60Hz filter - // mode or 62.5ms in 50Hz filter mode to complete. 1-Shot is a self-clearing bit. - // TODO: switch this out depending on the filter mode. - DELAY_US(65000); // 65ms +void MAX31865::runAutoFaultDetectionCycle() { + writeRegister8(MAX31865_CONFIG_REG, (stdFlags & 0x11) | 0x84 ); // cfg reg = 100X010Xb + DELAY_US(600); + for (int i = 0; i < 10 && (readRegister8(MAX31865_CONFIG_REG) & 0xC) > 0; i++) DELAY_US(100); // Fault det completes when bits 2 and 3 are zero (or after 10 tries) + readFault(); + clearFault(); } /** - * How many wires we have in our RTD setup, can be MAX31865_2WIRE, - * MAX31865_3WIRE, or MAX31865_4WIRE + * Set a value in the configuration register. + * + * @param config 8-bit value for the config item + * @param enable whether to enable or disable the value + */ +void MAX31865::setConfig(uint8_t config, bool enable) { + uint8_t t = stdFlags; + if (enable) + t |= config; + else + t &= ~config; + writeRegister8(MAX31865_CONFIG_REG, t); +} + +/** + * Initialize standard flags with flags that will not change during operation (Hz, polling mode and no. of wires) * * @param wires The number of wires in enum format */ -void MAX31865::setWires(max31865_numwires_t wires) { - uint8_t t = readRegister8(MAX31856_CONFIG_REG); +void MAX31865::initFixedFlags(max31865_numwires_t wires) { + + // set config-defined flags (same for all sensors) + stdFlags = TERN(MAX31865_50HZ_FILTER, MAX31865_CONFIG_FILT50HZ, MAX31865_CONFIG_FILT60HZ) | + TERN(MAX31865_USE_AUTO_MODE, MAX31865_CONFIG_MODEAUTO | MAX31865_CONFIG_BIAS, MAX31865_CONFIG_MODEOFF); + if (wires == MAX31865_3WIRE) - t |= MAX31856_CONFIG_3WIRE; - else // 2 or 4 wire - t &= ~MAX31856_CONFIG_3WIRE; - writeRegister8(MAX31856_CONFIG_REG, t); + stdFlags |= MAX31865_CONFIG_3WIRE; // 3 wire + else + stdFlags &= ~MAX31865_CONFIG_3WIRE; // 2 or 4 wire +} + +#if MAX31865_IGNORE_INITIAL_FAULTY_READS > 0 + + inline uint16_t MAX31865::fixFault(uint16_t rtd) { + if (!ignore_faults || !(rtd & 1)) + return rtd; + + ignore_faults--; + clearFault(); + + DEBUG_ECHOLNPGM("MAX31865 ignoring fault ", (MAX31865_IGNORE_INITIAL_FAULTY_READS) - ignore_faults); + + return rtd & ~1; // 0xFFFE + } + +#endif + +inline uint16_t MAX31865::readRawImmediate() { + uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG); + DEBUG_ECHOLNPGM("MAX31865 RTD MSB:", (rtd >> 8), " LSB:", (rtd & 0x00FF)); + + #if MAX31865_IGNORE_INITIAL_FAULTY_READS > 0 + rtd = fixFault(rtd); + #endif + + if (rtd & 1) { + lastFault = readRegister8(MAX31865_FAULTSTAT_REG); + lastRead |= 1; + clearFault(); // also clears the bias voltage flag, so no further action is required + DEBUG_ECHOLNPGM("MAX31865 read fault: ", lastFault); + } + else { + TERN_(MAX31865_USE_READ_ERROR_DETECTION, const millis_t ms = millis()); + if (TERN0(MAX31865_USE_READ_ERROR_DETECTION, ABS((int)(lastRead - rtd)) > 500 && PENDING(ms, lastReadStamp + 1000))) { + // If 2 readings within 1s differ too much (~20°C) it's a read error. + lastFault = 0x01; + lastRead |= 1; + DEBUG_ECHOLNPGM("MAX31865 read error: ", rtd); + } + else { + lastRead = rtd; + TERN_(MAX31865_USE_READ_ERROR_DETECTION, lastReadStamp = ms); + } + } + + return rtd; } /** @@ -257,33 +368,59 @@ void MAX31865::setWires(max31865_numwires_t wires) { * @return The raw unsigned 16-bit register value with ERROR bit attached, NOT temperature! */ uint16_t MAX31865::readRaw() { - clearFault(); - enableBias(true); - oneShot(); - uint16_t rtd = readRegister16(MAX31856_RTDMSB_REG); + #if ENABLED(MAX31865_USE_AUTO_MODE) - #ifdef MAX31865_DEBUG - SERIAL_ECHOLNPGM("RTD MSB:", (rtd >> 8), " RTD LSB:", (rtd & 0x00FF)); - #endif + readRawImmediate(); - // Disable the bias to lower power dissipation between reads. - // If the ref resistor heats up, the temperature reading will be skewed. - enableBias(false); + #else - return rtd; + const millis_t ms = millis(); + + if (PENDING(ms, nextEventStamp)) { + DEBUG_ECHOLNPGM("MAX31865 waiting for event ", nextEvent); + return lastRead; + } + + switch (nextEvent) { + case SETUP_BIAS_VOLTAGE: + enableBias(); + nextEventStamp = ms + 2; // wait at least 10.5*τ (τ = 100nF*430Ω max for PT100 / 10nF*4.3ΚΩ for PT1000 = 43μsec) + 1msec + nextEvent = SETUP_1_SHOT_MODE; + DEBUG_ECHOLNPGM("MAX31865 bias voltage enabled"); + break; + + case SETUP_1_SHOT_MODE: + oneShot(); + nextEventStamp = ms + TERN(MAX31865_50HZ_FILTER, 63, 52); // wait at least 52msec for 60Hz (63msec for 50Hz) before reading RTD register + nextEvent = READ_RTD_REG; + DEBUG_ECHOLNPGM("MAX31865 1 shot mode enabled"); + break; + + case READ_RTD_REG: + + if (!(readRawImmediate() & 1)) // if clearFault() was not invoked, need to clear the bias voltage and 1-shot flags + resetFlags(); + + nextEvent = SETUP_BIAS_VOLTAGE; + nextEventStamp = ms + (MAX31865_MIN_SAMPLING_TIME_MSEC); // next step should not occur within less than MAX31865_MIN_SAMPLING_TIME_MSEC from the last one + break; + } + + #endif + + return lastRead; } /** * Calculate and return the resistance value of the connected RTD. * - * @param refResistor The value of the matching reference resistor, usually 430 or 4300 * @return The raw RTD resistance value, NOT temperature! */ float MAX31865::readResistance() { // Strip the error bit (D0) and convert to a float ratio. - // less precise method: (readRaw() * Rref) >> 16 - return (((readRaw() >> 1) / 32768.0f) * Rref); + // less precise method: (readRaw() * refRes) >> 16 + return ((readRaw() * RECIPROCAL(65536.0f)) * refRes - wireRes); } /** @@ -300,8 +437,8 @@ float MAX31865::temperature() { * * @return Temperature in C */ -float MAX31865::temperature(uint16_t adcVal) { - return temperature(((adcVal) / 32768.0f) * Rref); +float MAX31865::temperature(uint16_t adc_val) { + return temperature(((adc_val) * RECIPROCAL(32768.0f)) * refRes - wireRes); } /** @@ -309,11 +446,11 @@ float MAX31865::temperature(uint16_t adcVal) { * Uses the technique outlined in this PDF: * http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf * - * @param Rrtd the resistance value in ohms - * @return the temperature in degC + * @param rtd_res the resistance value in ohms + * @return the temperature in degC */ -float MAX31865::temperature(float Rrtd) { - float temp = (RTD_Z1 + sqrt(RTD_Z2 + (RTD_Z3 * Rrtd))) / RTD_Z4; +float MAX31865::temperature(float rtd_res) { + float temp = (RTD_Z1 + sqrt(RTD_Z2 + (RTD_Z3 * rtd_res))) * RECIPROCAL(RTD_Z4); // From the PDF... // @@ -324,41 +461,34 @@ float MAX31865::temperature(float Rrtd) { // of resistance. // if (temp < 0) { - Rrtd = (Rrtd / Rzero) * 100; // normalize to 100 ohm - float rpoly = Rrtd; + rtd_res = (rtd_res / zeroRes) * 100; // normalize to 100 ohm + float rpoly = rtd_res; temp = -242.02 + (2.2228 * rpoly); - rpoly *= Rrtd; // square + rpoly *= rtd_res; // square temp += 2.5859e-3 * rpoly; - rpoly *= Rrtd; // ^3 + rpoly *= rtd_res; // ^3 temp -= 4.8260e-6 * rpoly; - rpoly *= Rrtd; // ^4 + rpoly *= rtd_res; // ^4 temp -= 2.8183e-8 * rpoly; - rpoly *= Rrtd; // ^5 + rpoly *= rtd_res; // ^5 temp += 1.5243e-10 * rpoly; } return temp; } -// -// private: -// - /** - * Set a value in the configuration register. - * - * @param config 8-bit value for the config item - * @param enable whether to enable or disable the value + * MAX31865 SPI Timing constants + * See MAX31865 datasheet (https://datasheets.maximintegrated.com/en/ds/MAX31865.pdf) + * All timings in nsec, minimum values. */ -void MAX31865::setConfig(uint8_t config, bool enable) { - uint8_t t = readRegister8(MAX31856_CONFIG_REG); - if (enable) - t |= config; - else - t &= ~config; // disable - writeRegister8(MAX31856_CONFIG_REG, t); -} + +#define MAX31865_SPI_TIMING_TCC 400 // CS to SCLK setup +#define MAX31865_SPI_TIMING_TDC 35 // Data to SCLK setup +#define MAX31865_SPI_TIMING_TCL 100 // SCK half period +#define MAX31865_SPI_TIMING_TCCH 100 // SCK to CS hold +#define MAX31865_SPI_TIMING_TCWH 400 // CS inactive time (min) /** * Read a single byte from the specified register address. @@ -369,7 +499,6 @@ void MAX31865::setConfig(uint8_t config, bool enable) { uint8_t MAX31865::readRegister8(uint8_t addr) { uint8_t ret = 0; readRegisterN(addr, &ret, 1); - return ret; } @@ -380,14 +509,9 @@ uint8_t MAX31865::readRegister8(uint8_t addr) { * @return both register contents as a single 16-bit int */ uint16_t MAX31865::readRegister16(uint8_t addr) { - uint8_t buffer[2] = {0, 0}; + uint8_t buffer[2] = { 0 }; readRegisterN(addr, buffer, 2); - - uint16_t ret = buffer[0]; - ret <<= 8; - ret |= buffer[1]; - - return ret; + return uint16_t(buffer[0]) << 8 | buffer[1]; } /** @@ -398,32 +522,26 @@ uint16_t MAX31865::readRegister16(uint8_t addr) { * @param n the number of bytes to read */ void MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) { - addr &= 0x7F; // make sure top bit is not set - if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) - SPI.beginTransaction(spiConfig); - else - WRITE(_sclk, LOW); - WRITE(_cs, LOW); - - #ifdef TARGET_LPC1768 - DELAY_CYCLES(_spi_speed); - #endif + addr &= 0x7F; // make sure top bit is not set + spiBeginTransaction(); spiTransfer(addr); while (n--) { buffer[0] = spiTransfer(0xFF); - #ifdef MAX31865_DEBUG_SPI - SERIAL_ECHOLNPGM("buffer read ", n, " data: ", buffer[0]); - #endif buffer++; } - if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) - SPI.endTransaction(); + spiEndTransaction(); +} - WRITE(_cs, HIGH); +void MAX31865::writeRegister16(uint8_t addr, uint16_t data) { + spiBeginTransaction(); + spiTransfer(addr | 0x80); // make sure top bit is set + spiTransfer(data >> 8); + spiTransfer(data & 0xFF); + spiEndTransaction(); } /** @@ -433,24 +551,33 @@ void MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) { * @param data the data to write */ void MAX31865::writeRegister8(uint8_t addr, uint8_t data) { - if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) - SPI.beginTransaction(spiConfig); - else - WRITE(_sclk, LOW); - - WRITE(_cs, LOW); - - #ifdef TARGET_LPC1768 - DELAY_CYCLES(_spi_speed); - #endif - + spiBeginTransaction(); spiTransfer(addr | 0x80); // make sure top bit is set spiTransfer(data); + spiEndTransaction(); +} + +void MAX31865::spiBeginTransaction() { + digitalWrite(sclkPin, LOW); // ensure CPOL0 + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCWH); // ensure minimum time of CS inactivity after previous operation + digitalWrite(cselPin, LOW); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCC); + + if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) + SPI.beginTransaction(spiConfig); + else + digitalWrite(sclkPin, HIGH); +} - if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) +void MAX31865::spiEndTransaction() { + if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) SPI.endTransaction(); + else + digitalWrite(sclkPin, LOW); - WRITE(_cs, HIGH); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCCH); + + digitalWrite(cselPin, HIGH); } /** @@ -463,37 +590,30 @@ void MAX31865::writeRegister8(uint8_t addr, uint8_t data) { * @return the 8-bit response */ uint8_t MAX31865::spiTransfer(uint8_t x) { - if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) return SPI.transfer(x); - #ifdef TARGET_LPC1768 - return swSpiTransfer(x, _spi_speed, _sclk, _miso, _mosi); - #else - uint8_t reply = 0; - for (int i = 7; i >= 0; i--) { - WRITE(_sclk, HIGH); DELAY_NS_VAR(_spi_delay); - reply <<= 1; - WRITE(_mosi, x & _BV(i)); DELAY_NS_VAR(_spi_delay); - if (READ(_miso)) reply |= 1; - WRITE(_sclk, LOW); DELAY_NS_VAR(_spi_delay); - } - return reply; - #endif + uint8_t reply = 0; + for (int i = 7; i >= 0; i--) { + digitalWrite(mosiPin, x & _BV(i)); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TDC); + digitalWrite(sclkPin, LOW); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCL - MAX31865_SPI_TIMING_TDC); + reply <<= 1; + if (digitalRead(misoPin)) reply |= 1; + DELAY_NS_VAR(MAX31865_SPI_TIMING_TDC); + digitalWrite(sclkPin, HIGH); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCL - MAX31865_SPI_TIMING_TDC); + } + return reply; } -void MAX31865::softSpiBegin(const uint8_t spi_speed) { - #ifdef MAX31865_DEBUG - SERIAL_ECHOLNPGM("Initializing MAX31865 Software SPI"); - #endif - #ifdef TARGET_LPC1768 - swSpiBegin(_sclk, _miso, _mosi); - _spi_speed = swSpiInit(spi_speed, _sclk, _mosi); - #else - _spi_delay = (100UL << spi_speed) / 3; // Calculate delay in ns. Top speed is ~10MHz, or 100ns delay between bits. - OUT_WRITE(_sclk, LOW); - SET_OUTPUT(_mosi); - SET_INPUT(_miso); - #endif +void MAX31865::softSpiInit() { + DEBUG_ECHOLNPGM("Initializing MAX31865 Software SPI"); + pinMode(sclkPin, OUTPUT); + digitalWrite(sclkPin, LOW); + pinMode(mosiPin, OUTPUT); + pinMode(misoPin, INPUT); } #endif // HAS_MAX31865 && !USE_ADAFRUIT_MAX31865 diff --git a/Marlin/src/libs/MAX31865.h b/Marlin/src/libs/MAX31865.h index 7610924c2313..baea455485d4 100644 --- a/Marlin/src/libs/MAX31865.h +++ b/Marlin/src/libs/MAX31865.h @@ -41,28 +41,30 @@ */ #pragma once +//#define DEBUG_MAX31865 + #include "../inc/MarlinConfig.h" #include "../HAL/shared/Delay.h" #include HAL_PATH(../HAL, MarlinSPI.h) -#define MAX31856_CONFIG_REG 0x00 -#define MAX31856_CONFIG_BIAS 0x80 -#define MAX31856_CONFIG_MODEAUTO 0x40 -#define MAX31856_CONFIG_MODEOFF 0x00 -#define MAX31856_CONFIG_1SHOT 0x20 -#define MAX31856_CONFIG_3WIRE 0x10 -#define MAX31856_CONFIG_24WIRE 0x00 -#define MAX31856_CONFIG_FAULTSTAT 0x02 -#define MAX31856_CONFIG_FILT50HZ 0x01 -#define MAX31856_CONFIG_FILT60HZ 0x00 - -#define MAX31856_RTDMSB_REG 0x01 -#define MAX31856_RTDLSB_REG 0x02 -#define MAX31856_HFAULTMSB_REG 0x03 -#define MAX31856_HFAULTLSB_REG 0x04 -#define MAX31856_LFAULTMSB_REG 0x05 -#define MAX31856_LFAULTLSB_REG 0x06 -#define MAX31856_FAULTSTAT_REG 0x07 +#define MAX31865_CONFIG_REG 0x00 +#define MAX31865_CONFIG_BIAS 0x80 +#define MAX31865_CONFIG_MODEAUTO 0x40 +#define MAX31865_CONFIG_MODEOFF 0x00 +#define MAX31865_CONFIG_1SHOT 0x20 +#define MAX31865_CONFIG_3WIRE 0x10 +#define MAX31865_CONFIG_24WIRE 0x00 +#define MAX31865_CONFIG_FAULTSTAT 0x02 +#define MAX31865_CONFIG_FILT50HZ 0x01 +#define MAX31865_CONFIG_FILT60HZ 0x00 + +#define MAX31865_RTDMSB_REG 0x01 +#define MAX31865_RTDLSB_REG 0x02 +#define MAX31865_HFAULTMSB_REG 0x03 +#define MAX31865_HFAULTLSB_REG 0x04 +#define MAX31865_LFAULTMSB_REG 0x05 +#define MAX31865_LFAULTLSB_REG 0x06 +#define MAX31865_FAULTSTAT_REG 0x07 #define MAX31865_FAULT_HIGHTHRESH 0x80 // D7 #define MAX31865_FAULT_LOWTHRESH 0x40 // D6 @@ -84,20 +86,43 @@ typedef enum max31865_numwires { MAX31865_4WIRE = 0 } max31865_numwires_t; +#if DISABLED(MAX31865_USE_AUTO_MODE) + typedef enum one_shot_event : uint8_t { + SETUP_BIAS_VOLTAGE, + SETUP_1_SHOT_MODE, + READ_RTD_REG + } one_shot_event_t; +#endif + /* Interface class for the MAX31865 RTD Sensor reader */ class MAX31865 { private: static SPISettings spiConfig; - TERN(LARGE_PINMAP, uint32_t, uint8_t) _sclk, _miso, _mosi, _cs; + TERN(LARGE_PINMAP, uint32_t, uint8_t) sclkPin, misoPin, mosiPin, cselPin; - #ifdef TARGET_LPC1768 - uint8_t _spi_speed; - #else - uint16_t _spi_delay; + uint16_t spiDelay; + + float zeroRes, refRes, wireRes; + + #if ENABLED(MAX31865_USE_READ_ERROR_DETECTION) + millis_t lastReadStamp = 0; + #endif + + uint16_t lastRead = 0; + uint8_t lastFault = 0; + + #if DISABLED(MAX31865_USE_AUTO_MODE) + millis_t nextEventStamp; + one_shot_event_t nextEvent; + #endif + + #ifdef MAX31865_IGNORE_INITIAL_FAULTY_READS + uint8_t ignore_faults = MAX31865_IGNORE_INITIAL_FAULTY_READS; + uint16_t fixFault(uint16_t rtd); #endif - float Rzero, Rref; + uint8_t stdFlags = 0; void setConfig(uint8_t config, bool enable); @@ -106,12 +131,26 @@ class MAX31865 { uint16_t readRegister16(uint8_t addr); void writeRegister8(uint8_t addr, uint8_t reg); + void writeRegister16(uint8_t addr, uint16_t reg); + + void softSpiInit(); + void spiBeginTransaction(); uint8_t spiTransfer(uint8_t addr); + void spiEndTransaction(); + + void initFixedFlags(max31865_numwires_t wires); + + void enable50HzFilter(bool b); + void enableBias(); + void oneShot(); + void resetFlags(); - void softSpiBegin(const uint8_t spi_speed); + uint16_t readRawImmediate(); + + void runAutoFaultDetectionCycle(); public: - #ifdef LARGE_PINMAP + #if ENABLED(LARGE_PINMAP) MAX31865(uint32_t spi_cs, uint8_t pin_mapping); MAX31865(uint32_t spi_cs, uint32_t spi_mosi, uint32_t spi_miso, uint32_t spi_clk, uint8_t pin_mapping); @@ -121,20 +160,14 @@ class MAX31865 { int8_t spi_clk); #endif - void begin(max31865_numwires_t wires, float zero, float ref); + void begin(max31865_numwires_t wires, float zero_res, float ref_res, float wire_res); uint8_t readFault(); void clearFault(); - void setWires(max31865_numwires_t wires); - void autoConvert(bool b); - void enable50HzFilter(bool b); - void enableBias(bool b); - void oneShot(); - uint16_t readRaw(); float readResistance(); float temperature(); - float temperature(uint16_t adcVal); - float temperature(float Rrtd); + float temperature(uint16_t adc_val); + float temperature(float rtd_res); }; diff --git a/Marlin/src/libs/W25Qxx.cpp b/Marlin/src/libs/W25Qxx.cpp index b458a7c965ef..033402d04ab0 100644 --- a/Marlin/src/libs/W25Qxx.cpp +++ b/Marlin/src/libs/W25Qxx.cpp @@ -133,7 +133,7 @@ uint16_t W25QXXFlash::W25QXX_ReadID(void) { return Temp; } -void W25QXXFlash::SPI_FLASH_WriteEnable(void) { +void W25QXXFlash::SPI_FLASH_WriteEnable() { // Select the FLASH: Chip Select low SPI_FLASH_CS_L(); // Send "Write Enable" instruction @@ -151,7 +151,7 @@ void W25QXXFlash::SPI_FLASH_WriteEnable(void) { * Output : None * Return : None *******************************************************************************/ -void W25QXXFlash::SPI_FLASH_WaitForWriteEnd(void) { +void W25QXXFlash::SPI_FLASH_WaitForWriteEnd() { uint8_t FLASH_Status = 0; // Select the FLASH: Chip Select low @@ -216,7 +216,7 @@ void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) { * Output : None * Return : None *******************************************************************************/ -void W25QXXFlash::SPI_FLASH_BulkErase(void) { +void W25QXXFlash::SPI_FLASH_BulkErase() { // Send write enable instruction SPI_FLASH_WriteEnable(); diff --git a/Marlin/src/libs/W25Qxx.h b/Marlin/src/libs/W25Qxx.h index 1133af2e74dd..778463477d82 100644 --- a/Marlin/src/libs/W25Qxx.h +++ b/Marlin/src/libs/W25Qxx.h @@ -61,11 +61,11 @@ class W25QXXFlash { static void spi_flash_Send(uint8_t b); static void spi_flash_SendBlock(uint8_t token, const uint8_t *buf); static uint16_t W25QXX_ReadID(void); - static void SPI_FLASH_WriteEnable(void); - static void SPI_FLASH_WaitForWriteEnd(void); + static void SPI_FLASH_WriteEnable(); + static void SPI_FLASH_WaitForWriteEnd(); static void SPI_FLASH_SectorErase(uint32_t SectorAddr); static void SPI_FLASH_BlockErase(uint32_t BlockAddr); - static void SPI_FLASH_BulkErase(void); + static void SPI_FLASH_BulkErase(); static void SPI_FLASH_PageWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); static void SPI_FLASH_BufferWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); static void SPI_FLASH_BufferRead(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); diff --git a/Marlin/src/libs/buzzer.h b/Marlin/src/libs/buzzer.h index 21b69002ffd3..9fc46ff6296c 100644 --- a/Marlin/src/libs/buzzer.h +++ b/Marlin/src/libs/buzzer.h @@ -77,7 +77,7 @@ * @brief Resets the state of the class * @details Brings the class state to a known one. */ - static inline void reset() { + static void reset() { off(); state.endtime = 0; } @@ -86,7 +86,7 @@ /** * @brief Init Buzzer */ - static inline void init() { + static void init() { SET_OUTPUT(BEEPER_PIN); reset(); } @@ -127,3 +127,8 @@ #define BUZZ(d,f) NOOP #endif + +#define ERR_BUZZ() BUZZ(400, 40); +#define ATTN_BUZZ() do{ BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); }while(0) +#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0) +#define DONE_BUZZ(OK) do{ if (OK) OKAY_BUZZ(); else ERR_BUZZ(); }while(0) diff --git a/Marlin/src/libs/duration_t.h b/Marlin/src/libs/duration_t.h index 2528bcdbff89..df2c9cd099c1 100644 --- a/Marlin/src/libs/duration_t.h +++ b/Marlin/src/libs/duration_t.h @@ -127,11 +127,11 @@ struct duration_t { * 59s */ char* toString(char * const buffer) const { - int y = this->year(), - d = this->day() % 365, - h = this->hour() % 24, - m = this->minute() % 60, - s = this->second() % 60; + const uint16_t y = this->year(), + d = this->day() % 365, + h = this->hour() % 24, + m = this->minute() % 60, + s = this->second() % 60; if (y) sprintf_P(buffer, PSTR("%iy %id %ih %im %is"), y, d, h, m, s); else if (d) sprintf_P(buffer, PSTR("%id %ih %im %is"), d, h, m, s); @@ -149,23 +149,29 @@ struct duration_t { * * Output examples: * 123456789 (strlen) + * 12'34 * 99:59 * 11d 12:33 */ uint8_t toDigital(char *buffer, bool with_days=false) const { - uint16_t h = uint16_t(this->hour()), - m = uint16_t(this->minute() % 60UL); + const uint16_t h = uint16_t(this->hour()), + m = uint16_t(this->minute() % 60UL); if (with_days) { - uint16_t d = this->day(); - sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); + const uint16_t d = this->day(); + sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45 return d >= 10 ? 9 : 8; } + else if (!h) { + const uint16_t s = uint16_t(this->second() % 60UL); + sprintf_P(buffer, PSTR("%02hu'%02hu"), m, s); // 12'34 + return 5; + } else if (h < 100) { - sprintf_P(buffer, PSTR("%02hu:%02hu"), h, m); + sprintf_P(buffer, PSTR("%02hu:%02hu"), h, m); // 12:34 return 5; } else { - sprintf_P(buffer, PSTR("%hu:%02hu"), h, m); + sprintf_P(buffer, PSTR("%hu:%02hu"), h, m); // 123:45 return 6; } } diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index e277216ab4e5..4ca8fa2cae1e 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -254,11 +254,18 @@ Nozzle nozzle; break; } - do_blocking_move_to_xy( - TERN(NOZZLE_PARK_Y_ONLY, current_position, park).x, - TERN(NOZZLE_PARK_X_ONLY, current_position, park).y, - fr_xy - ); + #ifndef NOZZLE_PARK_MOVE + #define NOZZLE_PARK_MOVE 0 + #endif + switch (NOZZLE_PARK_MOVE) { + case 0: do_blocking_move_to_xy(park, fr_xy); break; + case 1: do_blocking_move_to_x(park.x, fr_xy); break; + case 2: do_blocking_move_to_y(park.y, fr_xy); break; + case 3: do_blocking_move_to_x(park.x, fr_xy); + do_blocking_move_to_y(park.y, fr_xy); break; + case 4: do_blocking_move_to_y(park.y, fr_xy); + do_blocking_move_to_x(park.x, fr_xy); break; + } report_current_position(); } diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index 1e1ac0571012..f4d47983d225 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -377,10 +377,10 @@ const char* ftostr53sign(const_float_t f) { return conv; } -// Convert unsigned float to string with ____4.5, __34.5, _234.5, 1234.5 format -const char* ftostr51rj(const_float_t f) { +// Convert unsigned float to string with ____5.6, ___45.6, __345.6, _2345.6, 12345.6 format +const char* ftostr61rj(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[0] = ' '; + conv[0] = RJDIGIT(i, 100000); conv[1] = RJDIGIT(i, 10000); conv[2] = RJDIGIT(i, 1000); conv[3] = RJDIGIT(i, 100); diff --git a/Marlin/src/libs/numtostr.h b/Marlin/src/libs/numtostr.h index b058f3cdf6c6..1704d35e889d 100644 --- a/Marlin/src/libs/numtostr.h +++ b/Marlin/src/libs/numtostr.h @@ -113,8 +113,8 @@ const char* ftostr52sign(const_float_t x); // Convert signed float to string with +12.345 format const char* ftostr53sign(const_float_t f); -// Convert unsigned float to string with 1234.5 format omitting trailing zeros -const char* ftostr51rj(const_float_t x); +// Convert unsigned float to string with 12345.6 format omitting trailing zeros +const char* ftostr61rj(const_float_t x); // Convert float to rj string with 123 or -12 format FORCE_INLINE const char* ftostr3(const_float_t x) { return i16tostr3rj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } diff --git a/Marlin/src/libs/stopwatch.h b/Marlin/src/libs/stopwatch.h index fe5101a5beaa..829d510050d3 100644 --- a/Marlin/src/libs/stopwatch.h +++ b/Marlin/src/libs/stopwatch.h @@ -53,7 +53,7 @@ class Stopwatch { * @return true on success */ static bool stop(); - static inline bool abort() { return stop(); } // Alias by default + static bool abort() { return stop(); } // Alias by default /** * @brief Pause the stopwatch @@ -114,7 +114,7 @@ class Stopwatch { #else - static inline void debug(FSTR_P const) {} + static void debug(FSTR_P const) {} #endif }; diff --git a/Marlin/src/libs/vector_3.cpp b/Marlin/src/libs/vector_3.cpp index 614d2121b893..02945fe6871a 100644 --- a/Marlin/src/libs/vector_3.cpp +++ b/Marlin/src/libs/vector_3.cpp @@ -141,8 +141,7 @@ void matrix_3x3::debug(FSTR_P const title) { if (title) SERIAL_ECHOLNF(title); LOOP_L_N(i, 3) { LOOP_L_N(j, 3) { - if (vectors[i][j] >= 0.0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(vectors[i][j], 6); + serial_offset(vectors[i][j], 2); SERIAL_CHAR(' '); } SERIAL_EOL(); diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 2a4efb47da73..cd40175da4d2 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -63,6 +63,13 @@ abc_float_t delta_diagonal_rod_trim; float delta_safe_distance_from_top(); +void refresh_delta_clip_start_height() { + delta_clip_start_height = TERN(HAS_SOFTWARE_ENDSTOPS, + soft_endstop.max.z, + DIFF_TERN(HAS_BED_PROBE, delta_height, probe.offset.z) + ) - delta_safe_distance_from_top(); +} + /** * Recalculate factors used for delta kinematics whenever * settings have been changed (e.g., by M665). diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index f1e43c7e4c9d..7cd42805c90a 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -82,6 +82,8 @@ void inverse_kinematics(const xyz_pos_t &raw); */ float delta_safe_distance_from_top(); +void refresh_delta_clip_start_height(); + /** * Delta Forward Kinematics * diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index aa5907477eb1..3dd6d8aeb685 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -352,7 +352,7 @@ void Endstops::init() { } // Endstops::init -// Called at ~1KHz from Temperature ISR: Poll endstop state if required +// Called at ~1kHz from Temperature ISR: Poll endstop state if required void Endstops::poll() { TERN_(PINS_DEBUGGING, run_monitor()); // Report changes in endstop status @@ -403,7 +403,7 @@ void Endstops::not_homing() { void Endstops::resync() { if (!abort_enabled()) return; // If endstops/probes are disabled the loop below can hang - // Wait for Temperature ISR to run at least once (runs at 1KHz) + // Wait for Temperature ISR to run at least once (runs at 1kHz) TERN(ENDSTOP_INTERRUPTS_FEATURE, update(), safe_delay(2)); while (TERN0(ENDSTOP_NOISE_THRESHOLD, endstop_poll_count)) safe_delay(1); } @@ -558,13 +558,13 @@ void _O2 Endstops::report_states() { #if HAS_J_MAX ES_REPORT(J_MAX); #endif - #if HAS_K_MIN + #if HAS_K_MIN ES_REPORT(K_MIN); #endif #if HAS_K_MAX ES_REPORT(K_MAX); #endif - #if BOTH(MARLIN_DEV_MODE, PROBE_ACTIVATION_SWITCH) + #if ENABLED(PROBE_ACTIVATION_SWITCH) print_es_state(probe_switch_activated(), F(STR_PROBE_EN)); #endif #if USES_Z_MIN_PROBE_PIN @@ -593,9 +593,6 @@ void _O2 Endstops::report_states() { } // Endstops::report_states -// The following routines are called from an ISR context. It could be the temperature ISR, the -// endstop ISR or the Stepper ISR. - #if HAS_DELTA_SENSORLESS_PROBING #define __ENDSTOP(AXIS, ...) AXIS ##_MAX #define _ENDSTOP_PIN(AXIS, ...) AXIS ##_MAX_PIN @@ -607,17 +604,22 @@ void _O2 Endstops::report_states() { #endif #define _ENDSTOP(AXIS, MINMAX) __ENDSTOP(AXIS, MINMAX) -// Check endstops - Could be called from Temperature ISR! +/** + * Called from interrupt context by the Endstop ISR or Stepper ISR! + * Read endstops to get their current states, register hits for all + * axes moving in the direction of their endstops, and abort moves. + */ void Endstops::update() { - #if !ENDSTOP_NOISE_THRESHOLD - if (!abort_enabled()) return; + #if !ENDSTOP_NOISE_THRESHOLD // If not debouncing... + if (!abort_enabled()) return; // ...and not enabled, exit. #endif + // Macros to update / copy the live_state #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT)) - #if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) + #if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_XY) #define HAS_G38_PROBE 1 // For G38 moves check the probe's pin for ALL movement if (G38_move) UPDATE_ENDSTOP_BIT(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN)); @@ -628,12 +630,12 @@ void Endstops::update() { #define X_MAX_TEST() TERN1(DUAL_X_CARRIAGE, TERN0(X_HOME_TO_MAX, stepper.last_moved_extruder == 0) || TERN0(X2_HOME_TO_MAX, stepper.last_moved_extruder != 0)) // Use HEAD for core axes, AXIS for others - #if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) + #if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_XY) #define X_AXIS_HEAD X_HEAD #else #define X_AXIS_HEAD X_AXIS #endif - #if ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY) + #if ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY, MARKFORGED_YX) #define Y_AXIS_HEAD Y_HEAD #else #define Y_AXIS_HEAD Y_AXIS @@ -1059,7 +1061,7 @@ void Endstops::update() { } #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS if (stepper.axis_is_moving(I_AXIS)) { if (stepper.motor_direction(I_AXIS_HEAD)) { // -direction #if HAS_I_MIN || (I_SPI_SENSORLESS && I_HOME_TO_MIN) @@ -1074,7 +1076,7 @@ void Endstops::update() { } #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS if (stepper.axis_is_moving(J_AXIS)) { if (stepper.motor_direction(J_AXIS_HEAD)) { // -direction #if HAS_J_MIN || (J_SPI_SENSORLESS && J_HOME_TO_MIN) @@ -1089,7 +1091,7 @@ void Endstops::update() { } #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS if (stepper.axis_is_moving(K_AXIS)) { if (stepper.motor_direction(K_AXIS_HEAD)) { // -direction #if HAS_K_MIN || (K_SPI_SENSORLESS && K_HOME_TO_MIN) @@ -1107,11 +1109,12 @@ void Endstops::update() { #if ENABLED(SPI_ENDSTOPS) + // Called from idle() to read Trinamic stall states bool Endstops::tmc_spi_homing_check() { bool hit = false; #if X_SPI_SENSORLESS if (tmc_spi_homing.x && (stepperX.test_stall_status() - #if ANY(CORE_IS_XY, MARKFORGED_XY) && Y_SPI_SENSORLESS + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SPI_SENSORLESS || stepperY.test_stall_status() #elif CORE_IS_XZ && Z_SPI_SENSORLESS || stepperZ.test_stall_status() @@ -1123,7 +1126,7 @@ void Endstops::update() { #endif #if Y_SPI_SENSORLESS if (tmc_spi_homing.y && (stepperY.test_stall_status() - #if ANY(CORE_IS_XY, MARKFORGED_XY) && X_SPI_SENSORLESS + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SPI_SENSORLESS || stepperX.test_stall_status() #elif CORE_IS_YZ && Z_SPI_SENSORLESS || stepperZ.test_stall_status() @@ -1345,7 +1348,7 @@ void Endstops::update() { ES_REPORT_CHANGE(K_MAX); #endif SERIAL_ECHOLNPGM("\n"); - set_pwm_duty(pin_t(LED_PIN), local_LED_status); + hal.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/endstops.h b/Marlin/src/module/endstops.h index a35966a98c91..82a44cf95b83 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -47,16 +47,26 @@ enum EndstopEnum : char { _ES_ITEM(HAS_K_MAX, K_MAX) // Extra Endstops for XYZ - _ES_ITEM(HAS_X2_MIN, X2_MIN) - _ES_ITEM(HAS_X2_MAX, X2_MAX) - _ES_ITEM(HAS_Y2_MIN, Y2_MIN) - _ES_ITEM(HAS_Y2_MAX, Y2_MAX) - _ES_ITEM(HAS_Z2_MIN, Z2_MIN) - _ES_ITEM(HAS_Z2_MAX, Z2_MAX) - _ES_ITEM(HAS_Z3_MIN, Z3_MIN) - _ES_ITEM(HAS_Z3_MAX, Z3_MAX) - _ES_ITEM(HAS_Z4_MIN, Z4_MIN) - _ES_ITEM(HAS_Z4_MAX, Z4_MAX) + #if ENABLED(X_DUAL_ENDSTOPS) + _ES_ITEM(HAS_X_MIN, X2_MIN) + _ES_ITEM(HAS_X_MAX, X2_MAX) + #endif + #if ENABLED(Y_DUAL_ENDSTOPS) + _ES_ITEM(HAS_Y_MIN, Y2_MIN) + _ES_ITEM(HAS_Y_MAX, Y2_MAX) + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) + _ES_ITEM(HAS_Z_MIN, Z2_MIN) + _ES_ITEM(HAS_Z_MAX, Z2_MAX) + #if NUM_Z_STEPPER_DRIVERS >= 3 + _ES_ITEM(HAS_Z_MIN, Z3_MIN) + _ES_ITEM(HAS_Z_MAX, Z3_MAX) + #endif + #if NUM_Z_STEPPER_DRIVERS >= 4 + _ES_ITEM(HAS_Z_MIN, Z4_MIN) + _ES_ITEM(HAS_Z_MAX, Z4_MAX) + #endif + #endif // Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop) #if !HAS_DELTA_SENSORLESS_PROBING @@ -136,7 +146,7 @@ class Endstops { return enabled || TERN0(HAS_BED_PROBE, z_probe_enabled); } - static inline bool global_enabled() { return enabled_globally; } + static bool global_enabled() { return enabled_globally; } /** * Periodic call to poll endstops if required. Called from temperature ISR @@ -168,7 +178,7 @@ class Endstops { ; } - static inline bool probe_switch_activated() { + static bool probe_switch_activated() { return (true #if ENABLED(PROBE_ACTIVATION_SWITCH) && READ(PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 71239501fd84..0f8e02db9e5f 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -125,9 +125,7 @@ xyze_pos_t destination; // {0} ); // Transpose from [XYZ][HOTENDS] to [HOTENDS][XYZ] HOTEND_LOOP() LOOP_ABC(a) hotend_offset[e][a] = tmp[a][e]; - #if ENABLED(DUAL_X_CARRIAGE) - hotend_offset[1].x = _MAX(X2_HOME_POS, X2_MAX_POS); - #endif + TERN_(DUAL_X_CARRIAGE, hotend_offset[1].x = _MAX(X2_HOME_POS, X2_MAX_POS)); } #endif @@ -217,9 +215,7 @@ void report_real_position() { xyze_pos_t npos = LOGICAL_AXIS_ARRAY( planner.get_axis_position_mm(E_AXIS), cartes.x, cartes.y, cartes.z, - planner.get_axis_position_mm(I_AXIS), - planner.get_axis_position_mm(J_AXIS), - planner.get_axis_position_mm(K_AXIS) + cartes.i, cartes.j, cartes.k ); TERN_(HAS_POSITION_MODIFIERS, planner.unapply_modifiers(npos, true)); @@ -263,27 +259,25 @@ void report_current_position_projected() { * Output the current position (processed) to serial while moving */ void report_current_position_moving() { - get_cartesian_from_steppers(); const xyz_pos_t lpos = cartes.asLogical(); - SERIAL_ECHOPGM( - "X:", lpos.x - #if HAS_Y_AXIS - , " Y:", lpos.y - #endif - #if HAS_Z_AXIS - , " Z:", lpos.z - #endif + + SERIAL_ECHOPGM_P( + LIST_N(DOUBLE(LINEAR_AXES), + X_LBL, lpos.x, + SP_Y_LBL, lpos.y, + SP_Z_LBL, lpos.z, + SP_I_LBL, lpos.i, + SP_J_LBL, lpos.j, + SP_K_LBL, lpos.k + ) #if HAS_EXTRUDERS - , " E:", current_position.e + , SP_E_LBL, current_position.e #endif ); stepper.report_positions(); - #if IS_SCARA - scara_report_positions(); - #endif - + TERN_(IS_SCARA, scara_report_positions()); report_current_grblstate_moving(); } @@ -471,8 +465,8 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ } /** - * Plan a move to (X, Y, Z, [I, [J, [K]]]) and set the current_position - * Plan a move to (X, Y, Z) with separation of Z from other components. + * Plan a move to (X, Y, Z, [I, [J, [K...]]]) and set the current_position + * Plan a move to (X, Y, Z, [I, [J, [K...]]]) with separation of Z from other components. * * - If Z is moving up, the Z move is done before XY, etc. * - If Z is moving down, the Z move is done after XY, etc. @@ -488,6 +482,15 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s #if HAS_Z_AXIS const feedRate_t z_feedrate = fr_mm_s ?: homing_feedrate(Z_AXIS); #endif + #if HAS_I_AXIS + const feedRate_t i_feedrate = fr_mm_s ?: homing_feedrate(I_AXIS); + #endif + #if HAS_J_AXIS + const feedRate_t j_feedrate = fr_mm_s ?: homing_feedrate(J_AXIS); + #endif + #if HAS_K_AXIS + const feedRate_t k_feedrate = fr_mm_s ?: homing_feedrate(K_AXIS); + #endif #if IS_KINEMATIC if (!position_is_reachable(x, y)) return; @@ -502,8 +505,8 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s // when in the danger zone if (current_position.z > delta_clip_start_height) { - if (z > delta_clip_start_height) { // staying in the danger zone - destination.set(x, y, z); // move directly (uninterpolated) + if (z > delta_clip_start_height) { // staying in the danger zone + destination.set(x, y, z); // move directly (uninterpolated) prepare_internal_fast_move_to_destination(); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position); return; @@ -513,7 +516,7 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position); } - if (z > current_position.z) { // raising? + if (z > current_position.z) { // raising? destination.z = z; prepare_internal_fast_move_to_destination(z_feedrate); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position); @@ -523,7 +526,7 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s prepare_internal_move_to_destination(); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position); - if (z < current_position.z) { // lowering? + if (z < current_position.z) { // lowering? destination.z = z; prepare_internal_fast_move_to_destination(z_feedrate); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position); @@ -532,39 +535,32 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s #elif IS_SCARA // If Z needs to raise, do it before moving XY - if (destination.z < z) { - destination.z = z; - prepare_internal_fast_move_to_destination(z_feedrate); - } + if (destination.z < z) { destination.z = z; prepare_internal_fast_move_to_destination(z_feedrate); } - destination.set(x, y); - prepare_internal_fast_move_to_destination(xy_feedrate); + destination.set(x, y); prepare_internal_fast_move_to_destination(xy_feedrate); // If Z needs to lower, do it after moving XY - if (destination.z > z) { - destination.z = z; - prepare_internal_fast_move_to_destination(z_feedrate); - } + if (destination.z > z) { destination.z = z; prepare_internal_fast_move_to_destination(z_feedrate); } #else - #if HAS_Z_AXIS - // If Z needs to raise, do it before moving XY - if (current_position.z < z) { - current_position.z = z; - line_to_current_position(z_feedrate); - } + #if HAS_Z_AXIS // If Z needs to raise, do it before moving XY + if (current_position.z < z) { current_position.z = z; line_to_current_position(z_feedrate); } #endif - current_position.set(x, y); - line_to_current_position(xy_feedrate); + current_position.set(x, y); line_to_current_position(xy_feedrate); - #if HAS_Z_AXIS - // If Z needs to lower, do it after moving XY - if (current_position.z > z) { - current_position.z = z; - line_to_current_position(z_feedrate); - } + #if HAS_I_AXIS + current_position.i = i; line_to_current_position(i_feedrate); + #endif + #if HAS_J_AXIS + current_position.j = j; line_to_current_position(j_feedrate); + #endif + #if HAS_K_AXIS + current_position.k = k; line_to_current_position(k_feedrate); + #endif + #if HAS_Z_AXIS // If Z needs to lower, do it after moving XY... + if (current_position.z > z) { current_position.z = z; line_to_current_position(z_feedrate); } #endif #endif @@ -603,7 +599,7 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS void do_blocking_move_to_i(const_float_t ri, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyz_i(current_position, ri, fr_mm_s); } @@ -615,7 +611,7 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS void do_blocking_move_to_j(const_float_t rj, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyzi_j(current_position, rj, fr_mm_s); } @@ -627,7 +623,7 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS void do_blocking_move_to_k(const_float_t rk, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyzij_k(current_position, rk, fr_mm_s); } @@ -745,7 +741,7 @@ void restore_feedrate_and_scaling() { delta_max_radius_2 = sq(delta_max_radius); break; case Z_AXIS: - delta_clip_start_height = soft_endstop.max[axis] - delta_safe_distance_from_top(); + refresh_delta_clip_start_height(); default: break; } @@ -839,7 +835,7 @@ void restore_feedrate_and_scaling() { #endif } #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS if (axis_was_homed(I_AXIS)) { #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_I) NOLESS(target.i, soft_endstop.min.i); @@ -849,7 +845,7 @@ void restore_feedrate_and_scaling() { #endif } #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS if (axis_was_homed(J_AXIS)) { #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_J) NOLESS(target.j, soft_endstop.min.j); @@ -859,7 +855,7 @@ void restore_feedrate_and_scaling() { #endif } #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS if (axis_was_homed(K_AXIS)) { #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_K) NOLESS(target.k, soft_endstop.min.k); @@ -1118,16 +1114,15 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { bool idex_mirrored_mode = false; // Used in mode 3 float x_home_pos(const uint8_t extruder) { - if (extruder == 0) - return X_HOME_POS; - else - /** - * In dual carriage mode the extruder offset provides an override of the - * second X-carriage position when homed - otherwise X2_HOME_POS is used. - * This allows soft recalibration of the second extruder home position - * without firmware reflash (through the M218 command). - */ - return hotend_offset[1].x > 0 ? hotend_offset[1].x : X2_HOME_POS; + if (extruder == 0) return X_HOME_POS; + + /** + * In dual carriage mode the extruder offset provides an override of the + * second X-carriage position when homed - otherwise X2_HOME_POS is used. + * This allows soft recalibration of the second extruder home position + * (with M218 T1 Xn) without firmware reflash. + */ + return hotend_offset[1].x > 0 ? hotend_offset[1].x : X2_HOME_POS; } void idex_set_mirrored_mode(const bool mirr) { @@ -1323,9 +1318,9 @@ void prepare_line_to_destination() { TEST(axis_bits, X_AXIS) ? "X" : "", TEST(axis_bits, Y_AXIS) ? "Y" : "", TEST(axis_bits, Z_AXIS) ? "Z" : "", - TEST(axis_bits, I_AXIS) ? AXIS4_STR : "", - TEST(axis_bits, J_AXIS) ? AXIS5_STR : "", - TEST(axis_bits, K_AXIS) ? AXIS6_STR : "" + TEST(axis_bits, I_AXIS) ? STR_I : "", + TEST(axis_bits, J_AXIS) ? STR_J : "", + TEST(axis_bits, K_AXIS) ? STR_K : "" ) ); SERIAL_ECHO_START(); @@ -1367,7 +1362,7 @@ void prepare_line_to_destination() { #if AXIS_HAS_STALLGUARD(X2) stealth_states.x2 = tmc_enable_stallguard(stepperX2); #endif - #if EITHER(CORE_IS_XY, MARKFORGED_XY) && Y_SENSORLESS + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS stealth_states.y = tmc_enable_stallguard(stepperY); #elif CORE_IS_XZ && Z_SENSORLESS stealth_states.z = tmc_enable_stallguard(stepperZ); @@ -1380,7 +1375,7 @@ void prepare_line_to_destination() { #if AXIS_HAS_STALLGUARD(Y2) stealth_states.y2 = tmc_enable_stallguard(stepperY2); #endif - #if EITHER(CORE_IS_XY, MARKFORGED_XY) && X_SENSORLESS + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS stealth_states.x = tmc_enable_stallguard(stepperX); #elif CORE_IS_YZ && Z_SENSORLESS stealth_states.z = tmc_enable_stallguard(stepperZ); @@ -1406,6 +1401,15 @@ void prepare_line_to_destination() { #endif break; #endif + #if I_SENSORLESS + case I_AXIS: stealth_states.i = tmc_enable_stallguard(stepperI); break; + #endif + #if J_SENSORLESS + case J_AXIS: stealth_states.j = tmc_enable_stallguard(stepperJ); break; + #endif + #if K_SENSORLESS + case K_AXIS: stealth_states.k = tmc_enable_stallguard(stepperK); break; + #endif } #if ENABLED(SPI_ENDSTOPS) @@ -1417,13 +1421,13 @@ void prepare_line_to_destination() { #if HAS_Z_AXIS case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = true; break; #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = true; break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = true; break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = true; break; #endif default: break; @@ -1444,7 +1448,7 @@ void prepare_line_to_destination() { #if AXIS_HAS_STALLGUARD(X2) tmc_disable_stallguard(stepperX2, enable_stealth.x2); #endif - #if EITHER(CORE_IS_XY, MARKFORGED_XY) && Y_SENSORLESS + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS tmc_disable_stallguard(stepperY, enable_stealth.y); #elif CORE_IS_XZ && Z_SENSORLESS tmc_disable_stallguard(stepperZ, enable_stealth.z); @@ -1457,7 +1461,7 @@ void prepare_line_to_destination() { #if AXIS_HAS_STALLGUARD(Y2) tmc_disable_stallguard(stepperY2, enable_stealth.y2); #endif - #if EITHER(CORE_IS_XY, MARKFORGED_XY) && X_SENSORLESS + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS tmc_disable_stallguard(stepperX, enable_stealth.x); #elif CORE_IS_YZ && Z_SENSORLESS tmc_disable_stallguard(stepperZ, enable_stealth.z); @@ -1483,6 +1487,15 @@ void prepare_line_to_destination() { #endif break; #endif + #if I_SENSORLESS + case I_AXIS: tmc_disable_stallguard(stepperI, enable_stealth.i); break; + #endif + #if J_SENSORLESS + case J_AXIS: tmc_disable_stallguard(stepperJ, enable_stealth.j); break; + #endif + #if K_SENSORLESS + case K_AXIS: tmc_disable_stallguard(stepperK, enable_stealth.k); break; + #endif } #if ENABLED(SPI_ENDSTOPS) @@ -1494,13 +1507,13 @@ void prepare_line_to_destination() { #if HAS_Z_AXIS case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = false; break; #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = false; break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = false; break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = false; break; #endif default: break; @@ -1803,8 +1816,8 @@ void prepare_line_to_destination() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home Fast: ", move_length, "mm"); do_homing_move(axis, move_length, 0.0, !use_probe_bump); - #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) - if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) + #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) + if (axis == Z_AXIS && !bltouch.high_speed_mode) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif // If a second homing move is configured... @@ -1819,15 +1832,19 @@ void prepare_line_to_destination() { switch (axis) { default: case X_AXIS: es = X_ENDSTOP; break; - case Y_AXIS: es = Y_ENDSTOP; break; - case Z_AXIS: es = Z_ENDSTOP; break; - #if LINEAR_AXES >= 4 + #if HAS_Y_AXIS + case Y_AXIS: es = Y_ENDSTOP; break; + #endif + #if HAS_Z_AXIS + case Z_AXIS: es = Z_ENDSTOP; break; + #endif + #if HAS_I_AXIS case I_AXIS: es = I_ENDSTOP; break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: es = J_ENDSTOP; break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: es = K_ENDSTOP; break; #endif } @@ -1837,8 +1854,9 @@ void prepare_line_to_destination() { } #endif - #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) - if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) + #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) + if (axis == Z_AXIS && !bltouch.high_speed_mode && bltouch.deploy()) + return; // Intermediate DEPLOY (in LOW SPEED MODE) #endif // Slow move towards endstop until triggered @@ -2011,7 +2029,7 @@ void prepare_line_to_destination() { do_homing_move(axis, adjDistance, get_homing_bump_feedrate(axis)); } - #else // CARTESIAN / CORE / MARKFORGED_XY + #else // CARTESIAN / CORE / MARKFORGED_XY / MARKFORGED_YX set_axis_is_at_home(axis); sync_plan_position(); @@ -2041,7 +2059,7 @@ void prepare_line_to_destination() { #if ENABLED(SENSORLESS_HOMING) planner.synchronize(); if (false - #if EITHER(IS_CORE, MARKFORGED_XY) + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) || axis != NORMAL_AXIS #endif ) safe_delay(200); // Short delay to allow belts to spring back diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 50df5675e6c8..1dd6d8c4ede2 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -180,19 +180,19 @@ inline float home_bump_mm(const AxisEnum axis) { TERN_(MAX_SOFTWARE_ENDSTOP_Z, amax = max.z); break; #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case I_AXIS: TERN_(MIN_SOFTWARE_ENDSTOP_I, amin = min.i); TERN_(MIN_SOFTWARE_ENDSTOP_I, amax = max.i); break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: TERN_(MIN_SOFTWARE_ENDSTOP_J, amin = min.j); TERN_(MIN_SOFTWARE_ENDSTOP_J, amax = max.j); break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: TERN_(MIN_SOFTWARE_ENDSTOP_K, amin = min.k); TERN_(MIN_SOFTWARE_ENDSTOP_K, amax = max.k); @@ -265,9 +265,11 @@ void report_current_position_projected(); void report_current_position_moving(); #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) - inline void set_and_report_grblstate(const M_StateEnum state) { - M_State_grbl = state; - report_current_grblstate_moving(); + inline void set_and_report_grblstate(const M_StateEnum state, const bool force=true) { + if (force || M_State_grbl != state) { + M_State_grbl = state; + report_current_grblstate_moving(); + } } #endif @@ -333,15 +335,15 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s=0.0f); #if HAS_Z_AXIS void do_blocking_move_to_z(const_float_t rz, const_feedRate_t fr_mm_s=0.0f); #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS void do_blocking_move_to_i(const_float_t ri, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to_xyz_i(const xyze_pos_t &raw, const_float_t i, const_feedRate_t fr_mm_s=0.0f); #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS void do_blocking_move_to_j(const_float_t rj, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to_xyzi_j(const xyze_pos_t &raw, const_float_t j, const_feedRate_t fr_mm_s=0.0f); #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS void do_blocking_move_to_k(const_float_t rk, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to_xyzij_k(const xyze_pos_t &raw, const_float_t k, const_feedRate_t fr_mm_s=0.0f); #endif @@ -402,7 +404,7 @@ void set_axis_is_at_home(const AxisEnum axis); constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted inline void homeaxis(const AxisEnum axis) {} inline void set_axis_never_homed(const AxisEnum) {} - inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; } + inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return 0; } inline bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; } inline void set_axis_unhomed(const AxisEnum axis) {} inline void set_axis_untrusted(const AxisEnum axis) {} @@ -476,15 +478,15 @@ void home_if_needed(const bool keeplev=false); #define LOGICAL_Z_POSITION(POS) NATIVE_TO_LOGICAL(POS, Z_AXIS) #define RAW_Z_POSITION(POS) LOGICAL_TO_NATIVE(POS, Z_AXIS) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define LOGICAL_I_POSITION(POS) NATIVE_TO_LOGICAL(POS, I_AXIS) #define RAW_I_POSITION(POS) LOGICAL_TO_NATIVE(POS, I_AXIS) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define LOGICAL_J_POSITION(POS) NATIVE_TO_LOGICAL(POS, J_AXIS) #define RAW_J_POSITION(POS) LOGICAL_TO_NATIVE(POS, J_AXIS) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define LOGICAL_K_POSITION(POS) NATIVE_TO_LOGICAL(POS, K_AXIS) #define RAW_K_POSITION(POS) LOGICAL_TO_NATIVE(POS, K_AXIS) #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 11460fa67a24..51440aac262e 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -91,10 +91,6 @@ #include "../feature/power.h" #endif -#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) - #include "../feature/closedloop.h" -#endif - #if ENABLED(BACKLASH_COMPENSATION) #include "../feature/backlash.h" #endif @@ -707,7 +703,7 @@ void Planner::init() { // All other 32-bit MPUs can easily do inverse using hardware division, // so we don't need to reduce precision or to use assembly language at all. // This routine, for all other archs, returns 0x100000000 / d ~= 0xFFFFFFFF / d - static FORCE_INLINE uint32_t get_period_inverse(const uint32_t d) { + FORCE_INLINE static uint32_t get_period_inverse(const uint32_t d) { return d ? 0xFFFFFFFF / d : 0xFFFFFFFF; } #endif @@ -1248,10 +1244,6 @@ void Planner::recalculate() { recalculate_trapezoids(); } -#if HAS_FAN && DISABLED(LASER_SYNCHRONOUS_M106_M107) - #define HAS_TAIL_FAN_SPEED 1 -#endif - /** * Apply fan speeds */ @@ -1267,10 +1259,8 @@ void Planner::recalculate() { #if ENABLED(FAN_SOFT_PWM) #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F); - #elif ENABLED(FAST_PWM_FAN) - #define _FAN_SET(F) set_pwm_duty(FAN##F##_PIN, CALC_FAN_SPEED(F)); #else - #define _FAN_SET(F) set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); + #define _FAN_SET(F) hal.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) @@ -1314,8 +1304,10 @@ void Planner::check_axes_activity() { xyze_bool_t axis_active = { false }; #endif - #if HAS_TAIL_FAN_SPEED - uint8_t tail_fan_speed[FAN_COUNT]; + #if HAS_FAN && DISABLED(LASER_SYNCHRONOUS_M106_M107) + #define HAS_TAIL_FAN_SPEED 1 + static uint8_t tail_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, 128); + bool fans_need_update = false; #endif #if ENABLED(BARICUDA) @@ -1334,7 +1326,13 @@ void Planner::check_axes_activity() { #endif #if HAS_TAIL_FAN_SPEED - FANS_LOOP(i) tail_fan_speed[i] = thermalManager.scaledFanSpeed(i, block->fan_speed[i]); + FANS_LOOP(i) { + const uint8_t spd = thermalManager.scaledFanSpeed(i, block->fan_speed[i]); + if (tail_fan_speed[i] != spd) { + fans_need_update = true; + tail_fan_speed[i] = spd; + } + } #endif #if ENABLED(BARICUDA) @@ -1362,7 +1360,13 @@ void Planner::check_axes_activity() { TERN_(HAS_CUTTER, cutter.refresh()); #if HAS_TAIL_FAN_SPEED - FANS_LOOP(i) tail_fan_speed[i] = thermalManager.scaledFanSpeed(i); + FANS_LOOP(i) { + const uint8_t spd = thermalManager.scaledFanSpeed(i); + if (tail_fan_speed[i] != spd) { + fans_need_update = true; + tail_fan_speed[i] = spd; + } + } #endif #if ENABLED(BARICUDA) @@ -1388,13 +1392,13 @@ void Planner::check_axes_activity() { // Update Fan speeds // Only if synchronous M106/M107 is disabled // - TERN_(HAS_TAIL_FAN_SPEED, sync_fan_speeds(tail_fan_speed)); + TERN_(HAS_TAIL_FAN_SPEED, if (fans_need_update) sync_fan_speeds(tail_fan_speed)); TERN_(AUTOTEMP, autotemp_task()); #if ENABLED(BARICUDA) - 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)); + TERN_(HAS_HEATER_1, hal.set_pwm_duty(pin_t(HEATER_1_PIN), tail_valve_pressure)); + TERN_(HAS_HEATER_2, hal.set_pwm_duty(pin_t(HEATER_2_PIN), tail_e_to_p_pressure)); #endif } @@ -1702,7 +1706,8 @@ void Planner::endstop_triggered(const AxisEnum axis) { } float Planner::triggered_position_mm(const AxisEnum axis) { - return stepper.triggered_position(axis) * mm_per_step[axis]; + const float result = DIFF_TERN(BACKLASH_COMPENSATION, stepper.triggered_position(axis), backlash.get_applied_steps(axis)); + return result * mm_per_step[axis]; } void Planner::finish_and_disable() { @@ -1724,8 +1729,8 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { // Protect the access to the position. const bool was_enabled = stepper.suspend(); - const int32_t p1 = stepper.position(CORE_AXIS_1), - p2 = stepper.position(CORE_AXIS_2); + const int32_t p1 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_1), backlash.get_applied_steps(CORE_AXIS_1)), + p2 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_2), backlash.get_applied_steps(CORE_AXIS_2)); if (was_enabled) stepper.wake_up(); @@ -1734,9 +1739,9 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { axis_steps = (axis == CORE_AXIS_2 ? CORESIGN(p1 - p2) : p1 + p2) * 0.5f; } else - axis_steps = stepper.position(axis); + axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.get_applied_steps(axis)); - #elif ENABLED(MARKFORGED_XY) + #elif EITHER(MARKFORGED_XY, MARKFORGED_YX) // Requesting one of the joined axes? if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) { @@ -1751,11 +1756,12 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { axis_steps = ((axis == CORE_AXIS_1) ? p1 - p2 : p2); } else - axis_steps = stepper.position(axis); + axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.get_applied_steps(axis)); #else axis_steps = stepper.position(axis); + TERN_(BACKLASH_COMPENSATION, axis_steps -= backlash.get_applied_steps(axis)); #endif @@ -1763,13 +1769,9 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { } /** - * Block until all buffered steps are executed / cleaned + * Block until the planner is finished processing */ -void Planner::synchronize() { - while (has_blocks_queued() || cleaning_buffer_counter - || TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING()) - ) idle(); -} +void Planner::synchronize() { while (busy()) idle(); } /** * Planner::_buffer_steps @@ -1863,14 +1865,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move, " A:", target.a, " (", da, " steps)" " B:", target.b, " (", db, " steps)" " C:", target.c, " (", dc, " steps)" - #if LINEAR_AXES >= 4 - " " AXIS4_STR ":", target.i, " (", di, " steps)" + #if HAS_I_AXIS + " " STR_I ":", target.i, " (", di, " steps)" #endif - #if LINEAR_AXES >= 5 - " " AXIS5_STR ":", target.j, " (", dj, " steps)" + #if HAS_J_AXIS + " " STR_J ":", target.j, " (", dj, " steps)" #endif - #if LINEAR_AXES >= 6 - " " AXIS6_STR ":", target.k, " (", dk, " steps)" + #if HAS_K_AXIS + " " STR_K ":", target.k, " (", dk, " steps)" #endif #if HAS_EXTRUDERS " E:", target.e, " (", de, " steps)" @@ -1914,30 +1916,43 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Compute direction bit-mask for this block axis_bits_t dm = 0; - #if CORE_IS_XY - if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X - if (db < 0) SBI(dm, Y_HEAD); // ...and Y + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X + if (db < 0) SBI(dm, Y_HEAD); // ...and Y if (dc < 0) SBI(dm, Z_AXIS); - if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction - if (CORESIGN(da - db) < 0) SBI(dm, B_AXIS); // Motor B direction - #elif CORE_IS_XZ - if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X - if (db < 0) SBI(dm, Y_AXIS); - if (dc < 0) SBI(dm, Z_HEAD); // ...and Z - if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction - if (CORESIGN(da - dc) < 0) SBI(dm, C_AXIS); // Motor C direction - #elif CORE_IS_YZ - if (da < 0) SBI(dm, X_AXIS); - if (db < 0) SBI(dm, Y_HEAD); // Save the toolhead's true direction in Y - if (dc < 0) SBI(dm, Z_HEAD); // ...and Z - if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction - if (CORESIGN(db - dc) < 0) SBI(dm, C_AXIS); // Motor C direction + #endif + #if IS_CORE + #if CORE_IS_XY + if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction + if (CORESIGN(da - db) < 0) SBI(dm, B_AXIS); // Motor B direction + #elif CORE_IS_XZ + if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X + if (db < 0) SBI(dm, Y_AXIS); + if (dc < 0) SBI(dm, Z_HEAD); // ...and Z + if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction + if (CORESIGN(da - dc) < 0) SBI(dm, C_AXIS); // Motor C direction + #elif CORE_IS_YZ + if (da < 0) SBI(dm, X_AXIS); + if (db < 0) SBI(dm, Y_HEAD); // Save the toolhead's true direction in Y + if (dc < 0) SBI(dm, Z_HEAD); // ...and Z + if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction + if (CORESIGN(db - dc) < 0) SBI(dm, C_AXIS); // Motor C direction + #endif + #if HAS_I_AXIS + if (di < 0) SBI(dm, I_AXIS); + #endif + #if HAS_J_AXIS + if (dj < 0) SBI(dm, J_AXIS); + #endif + #if HAS_K_AXIS + if (dk < 0) SBI(dm, K_AXIS); + #endif #elif ENABLED(MARKFORGED_XY) - if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X - if (db < 0) SBI(dm, Y_HEAD); // ...and Y - if (dc < 0) SBI(dm, Z_AXIS); - if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction - if (db < 0) SBI(dm, B_AXIS); // Motor B direction + if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction + if (db < 0) SBI(dm, B_AXIS); // Motor B direction + #elif ENABLED(MARKFORGED_YX) + if (da < 0) SBI(dm, A_AXIS); // Motor A direction + if (db + da < 0) SBI(dm, B_AXIS); // Motor B direction #else LINEAR_AXIS_CODE( if (da < 0) SBI(dm, X_AXIS), @@ -1949,21 +1964,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, ); #endif - #if IS_CORE - #if LINEAR_AXES >= 4 - if (di < 0) SBI(dm, I_AXIS); - #endif - #if LINEAR_AXES >= 5 - if (dj < 0) SBI(dm, J_AXIS); - #endif - #if LINEAR_AXES >= 6 - if (dk < 0) SBI(dm, K_AXIS); - #endif - #endif - - TERN_(HAS_EXTRUDERS, if (de < 0) SBI(dm, E_AXIS)); - #if HAS_EXTRUDERS + if (de < 0) SBI(dm, E_AXIS); const float esteps_float = de * e_factor[extruder]; const uint32_t esteps = ABS(esteps_float) + 0.5f; #else @@ -1993,6 +1995,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db + dc), ABS(db - dc), ABS(di), ABS(dj), ABS(dk))); #elif ENABLED(MARKFORGED_XY) block->steps.set(LINEAR_AXIS_LIST(ABS(da + db), ABS(db), ABS(dc), ABS(di), ABS(dj), ABS(dk))); + #elif ENABLED(MARKFORGED_YX) + block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db + da), ABS(dc), ABS(di), ABS(dj), ABS(dk))); #elif IS_SCARA block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db), ABS(dc), ABS(di), ABS(dj), ABS(dk))); #else @@ -2009,15 +2013,18 @@ bool Planner::_populate_block(block_t * const block, bool split_move, * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed. */ struct DistanceMM : abce_float_t { - #if EITHER(IS_CORE, MARKFORGED_XY) + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) struct { float x, y, z; } head; #endif } steps_dist_mm; + + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + steps_dist_mm.head.x = da * mm_per_step[A_AXIS]; + steps_dist_mm.head.y = db * mm_per_step[B_AXIS]; + steps_dist_mm.z = dc * mm_per_step[Z_AXIS]; + #endif #if IS_CORE #if CORE_IS_XY - steps_dist_mm.head.x = da * mm_per_step[A_AXIS]; - steps_dist_mm.head.y = db * mm_per_step[B_AXIS]; - steps_dist_mm.z = dc * mm_per_step[Z_AXIS]; steps_dist_mm.a = (da + db) * mm_per_step[A_AXIS]; steps_dist_mm.b = CORESIGN(da - db) * mm_per_step[B_AXIS]; #elif CORE_IS_XZ @@ -2033,21 +2040,15 @@ bool Planner::_populate_block(block_t * const block, bool split_move, steps_dist_mm.b = (db + dc) * mm_per_step[B_AXIS]; steps_dist_mm.c = CORESIGN(db - dc) * mm_per_step[C_AXIS]; #endif - #if LINEAR_AXES >= 4 - steps_dist_mm.i = di * mm_per_step[I_AXIS]; - #endif - #if LINEAR_AXES >= 5 - steps_dist_mm.j = dj * mm_per_step[J_AXIS]; - #endif - #if LINEAR_AXES >= 6 - steps_dist_mm.k = dk * mm_per_step[K_AXIS]; - #endif + TERN_(HAS_I_AXIS, steps_dist_mm.i = di * mm_per_step[I_AXIS]); + TERN_(HAS_J_AXIS, steps_dist_mm.j = dj * mm_per_step[J_AXIS]); + TERN_(HAS_K_AXIS, steps_dist_mm.k = dk * mm_per_step[K_AXIS]); #elif ENABLED(MARKFORGED_XY) - steps_dist_mm.head.x = da * mm_per_step[A_AXIS]; - steps_dist_mm.head.y = db * mm_per_step[B_AXIS]; - steps_dist_mm.z = dc * mm_per_step[Z_AXIS]; steps_dist_mm.a = (da - db) * mm_per_step[A_AXIS]; steps_dist_mm.b = db * mm_per_step[B_AXIS]; + #elif ENABLED(MARKFORGED_YX) + steps_dist_mm.a = da * mm_per_step[A_AXIS]; + steps_dist_mm.b = (db - da) * mm_per_step[B_AXIS]; #else LINEAR_AXIS_CODE( steps_dist_mm.a = da * mm_per_step[A_AXIS], @@ -2079,7 +2080,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->millimeters = millimeters; else { block->millimeters = SQRT( - #if EITHER(CORE_IS_XY, MARKFORGED_XY) + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) LINEAR_AXIS_GANG( sq(steps_dist_mm.head.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.z), + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k) @@ -2096,7 +2097,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, ) #elif ENABLED(FOAMCUTTER_XYUV) // Return the largest distance move from either X/Y or I/J plane - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j)) #else sq(steps_dist_mm.x) + sq(steps_dist_mm.y) @@ -2158,7 +2159,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif // Enable active axes - #if EITHER(CORE_IS_XY, MARKFORGED_XY) + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) if (block->steps.a || block->steps.b) { stepper.enable_axis(X_AXIS); stepper.enable_axis(Y_AXIS); @@ -2188,16 +2189,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (block->steps.k) stepper.enable_axis(K_AXIS) ); #endif - #if EITHER(IS_CORE, MARKFORGED_XY) - #if LINEAR_AXES >= 4 - if (block->steps.i) stepper.enable_axis(I_AXIS); - #endif - #if LINEAR_AXES >= 5 - if (block->steps.j) stepper.enable_axis(J_AXIS); - #endif - #if LINEAR_AXES >= 6 - if (block->steps.k) stepper.enable_axis(K_AXIS); - #endif + #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + TERN_(HAS_I_AXIS, if (block->steps.i) stepper.enable_axis(I_AXIS)); + TERN_(HAS_J_AXIS, if (block->steps.j) stepper.enable_axis(J_AXIS)); + TERN_(HAS_K_AXIS, if (block->steps.k) stepper.enable_axis(K_AXIS)); #endif // Enable extruder(s) @@ -2252,7 +2247,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill #if EITHER(SLOWDOWN, HAS_WIRED_LCD) || defined(XY_FREQUENCY_LIMIT) - // Segment time im micro seconds + // Segment time in microseconds int32_t segment_time_us = LROUND(1000000.0f / inverse_secs); #endif @@ -2411,7 +2406,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, accel = CEIL((esteps ? settings.acceleration : settings.travel_acceleration) * steps_per_mm); #if ENABLED(LIN_ADVANCE) - + // Linear advance is currently not ready for HAS_I_AXIS #define MAX_E_JERK(N) TERN(HAS_LINEAR_E_JERK, max_e_jerk[E_INDEX_N(N)], max_jerk.e) /** @@ -2546,7 +2541,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, * => normalize the complete junction vector. * Elsewise, when needed JD will factor-in the E component */ - if (EITHER(IS_CORE, MARKFORGED_XY) || esteps > 0) + if (ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) || esteps > 0) normalize_junction_vector(unit_vec); // Normalize with XYZE components else unit_vec *= inverse_millimeters; // Use pre-calculated (1 / SQRT(x^2 + y^2 + z^2)) @@ -2816,9 +2811,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move, position = target; // Update the position + #if ENABLED(POWER_LOSS_RECOVERY) + block->sdpos = recovery.command_sdpos(); + block->start_position = position_float.asLogical(); + #endif + TERN_(HAS_POSITION_FLOAT, position_float = target_float); TERN_(GRADIENT_MIX, mixer.gradient_control(target_float.z)); - TERN_(POWER_LOSS_RECOVERY, block->sdpos = recovery.command_sdpos()); return true; // Movement was accepted @@ -2844,6 +2843,9 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ block->flag = sync_flag; block->position = position; + #if ENABLED(BACKLASH_COMPENSATION) + LOOP_LINEAR_AXES(axis) block->position[axis] += backlash.get_applied_steps((AxisEnum)axis); + #endif #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107) FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; @@ -2931,7 +2933,7 @@ bool Planner::buffer_segment(const abce_pos_t &abce SERIAL_ECHOPGM_P(SP_Y_LBL, abce.b); #endif SERIAL_ECHOPGM(" (", position.y, "->", target.y); - #if LINEAR_AXES >= ABC + #if HAS_Z_AXIS #if ENABLED(DELTA) SERIAL_ECHOPGM(") C:", abce.c); #else @@ -2941,17 +2943,17 @@ bool Planner::buffer_segment(const abce_pos_t &abce SERIAL_ECHOPGM(" (", position.z, "->", target.z); SERIAL_CHAR(')'); #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS SERIAL_ECHOPGM_P(SP_I_LBL, abce.i); SERIAL_ECHOPGM(" (", position.i, "->", target.i); SERIAL_CHAR(')'); #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS SERIAL_ECHOPGM_P(SP_J_LBL, abce.j); SERIAL_ECHOPGM(" (", position.j, "->", target.j); SERIAL_CHAR(')'); #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS SERIAL_ECHOPGM_P(SP_K_LBL, abce.k); SERIAL_ECHOPGM(" (", position.k, "->", target.k); SERIAL_CHAR(')'); @@ -3111,13 +3113,21 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS]) ) ); + if (has_blocks_queued()) { //previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest. //previous_speed.reset(); buffer_sync_block(); } - else - stepper.set_position(position); + else { + #if ENABLED(BACKLASH_COMPENSATION) + abce_long_t stepper_pos = position; + LOOP_LINEAR_AXES(axis) stepper_pos[axis] += backlash.get_applied_steps((AxisEnum)axis); + stepper.set_position(stepper_pos); + #else + stepper.set_position(position); + #endif + } } void Planner::set_position_mm(const xyze_pos_t &xyze) { diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 16d136be454f..f29604bea86a 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -75,6 +75,10 @@ #define IS_PAGE(B) false #endif +#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) + #include "../feature/closedloop.h" +#endif + // Feedrate for manual moves #ifdef MANUAL_FEEDRATE constexpr xyze_feedrate_t _mf = MANUAL_FEEDRATE, @@ -240,6 +244,7 @@ typedef struct block_t { #if ENABLED(POWER_LOSS_RECOVERY) uint32_t sdpos; + xyze_pos_t start_position; #endif #if ENABLED(LASER_POWER_INLINE) @@ -248,7 +253,7 @@ typedef struct block_t { } block_t; -#if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL) +#if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL, POWER_LOSS_RECOVERY) #define HAS_POSITION_FLOAT 1 #endif @@ -427,15 +432,15 @@ class Planner { static int8_t xy_freq_limit_hz; // Minimum XY frequency setting static float xy_freq_min_speed_factor; // Minimum speed factor setting static int32_t xy_freq_min_interval_us; // Minimum segment time based on xy_freq_limit_hz - static inline void refresh_frequency_limit() { + static void refresh_frequency_limit() { //xy_freq_min_interval_us = xy_freq_limit_hz ?: LROUND(1000000.0f / xy_freq_limit_hz); if (xy_freq_limit_hz) xy_freq_min_interval_us = LROUND(1000000.0f / xy_freq_limit_hz); } - static inline void set_min_speed_factor_u8(const uint8_t v255) { + static void set_min_speed_factor_u8(const uint8_t v255) { xy_freq_min_speed_factor = float(ui8_to_percent(v255)) / 100; } - static inline void set_frequency_limit(const uint8_t hz) { + static void set_frequency_limit(const uint8_t hz) { xy_freq_limit_hz = constrain(hz, 0, 100); refresh_frequency_limit(); } @@ -504,7 +509,7 @@ class Planner { #if HAS_CLASSIC_JERK static void set_max_jerk(const AxisEnum axis, float inMaxJerkMMS); #else - static inline void set_max_jerk(const AxisEnum, const_float_t) {} + static void set_max_jerk(const AxisEnum, const_float_t) {} #endif #if HAS_EXTRUDERS @@ -512,7 +517,7 @@ class Planner { e_factor[e] = flow_percentage[e] * 0.01f * TERN(NO_VOLUMETRICS, 1.0f, volumetric_multiplier[e]); } - static inline void set_flow(const uint8_t e, const int16_t flow) { + static void set_flow(const uint8_t e, const int16_t flow) { flow_percentage[e] = flow; refresh_e_factor(e); } @@ -535,7 +540,7 @@ class Planner { #if ENABLED(FILAMENT_WIDTH_SENSOR) void apply_filament_width_sensor(const int8_t encoded_ratio); - static inline float volumetric_percent(const bool vol) { + static float volumetric_percent(const bool vol) { return 100.0f * (vol ? volumetric_area_nominal / volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] : volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] @@ -584,7 +589,7 @@ class Planner { * Returns 1.0 if planner.z_fade_height is 0.0. * Returns 0.0 if Z is past the specified 'Fade Height'. */ - static inline float fade_scaling_factor_for_z(const_float_t rz) { + static float fade_scaling_factor_for_z(const_float_t rz) { static float z_fade_factor = 1; if (!z_fade_height) return 1; if (rz >= z_fade_height) return 0; @@ -834,7 +839,7 @@ class Planner { */ static float get_axis_position_mm(const AxisEnum axis); - static inline abce_pos_t get_axis_positions_mm() { + static abce_pos_t get_axis_positions_mm() { const abce_pos_t out = LOGICAL_AXIS_ARRAY( get_axis_position_mm(E_AXIS), get_axis_position_mm(A_AXIS), get_axis_position_mm(B_AXIS), get_axis_position_mm(C_AXIS), @@ -865,6 +870,13 @@ class Planner { // Triggered position of an axis in mm (not core-savvy) static float triggered_position_mm(const AxisEnum axis); + // Blocks are queued, or we're running out moves, or the closed loop controller is waiting + static bool busy() { + return (has_blocks_queued() || cleaning_buffer_counter + || TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING()) + ); + } + // Block until all buffered steps are executed / cleaned static void synchronize(); @@ -927,7 +939,7 @@ class Planner { #if ENABLED(AUTOTEMP_PROPORTIONAL) static void _autotemp_update_from_hotend(); #else - static inline void _autotemp_update_from_hotend() {} + static void _autotemp_update_from_hotend() {} #endif #endif diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index 27dee76715d4..c35b722cf4c6 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -43,7 +43,6 @@ Stopwatch print_job_timer; // Global Print Job Timer instance #if PRINTCOUNTER_SYNC #include "../module/planner.h" - #warning "To prevent step loss, motion will pause for PRINTCOUNTER auto-save." #endif // Service intervals @@ -152,7 +151,7 @@ void PrintCounter::loadStats() { if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3)); #endif #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 - if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) BUZZ(200, 404); + if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) { BUZZ(200, 404); BUZZ(10, 0); } #else UNUSED(doBuzz); #endif diff --git a/Marlin/src/module/printcounter.h b/Marlin/src/module/printcounter.h index 4deae45a656d..931d14ded6da 100644 --- a/Marlin/src/module/printcounter.h +++ b/Marlin/src/module/printcounter.h @@ -112,7 +112,7 @@ class PrintCounter: public Stopwatch { /** * @brief Initialize the print counter */ - static inline void init() { + static void init() { super::init(); loadStats(); } @@ -176,8 +176,8 @@ class PrintCounter: public Stopwatch { */ static bool start(); static bool _stop(const bool completed); - static inline bool stop() { return _stop(true); } - static inline bool abort() { return _stop(false); } + static bool stop() { return _stop(true); } + static bool abort() { return _stop(false); } static void reset(); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 984a3aabb505..ee6323518a2f 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -77,10 +77,18 @@ #include "servo.h" #endif +#if HAS_PTC + #include "../feature/probe_temp_comp.h" +#endif + +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + #include "../feature/x_twist.h" +#endif + #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) @@ -121,6 +129,17 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif } +#elif ENABLED(MAGLEV4) + + // Write trigger pin to release the probe + inline void maglev_deploy() { + WRITE(MAGLEV_TRIGGER_PIN, HIGH); + delay(MAGLEV_TRIGGER_DELAY); + WRITE(MAGLEV_TRIGGER_PIN, LOW); + } + + inline void maglev_idle() { do_blocking_move_to_z(10); } + #elif ENABLED(TOUCH_MI_PROBE) // Move to the magnet to unlock the probe @@ -287,8 +306,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { if (deploy != PROBE_TRIGGERED()) break; #endif - BUZZ(100, 659); - BUZZ(100, 698); + OKAY_BUZZ(); FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW); ui.return_to_status(); // To display the new status message @@ -297,7 +315,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe"))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR))); + TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.reset_status(); @@ -311,6 +329,10 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { WRITE(SOL1_PIN, deploy); #endif + #elif ENABLED(MAGLEV4) + + deploy ? maglev_deploy() : maglev_idle(); + #elif ENABLED(Z_PROBE_SLED) dock_sled(!deploy); @@ -489,17 +511,19 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if BOTH(HAS_TEMP_HOTEND, WAIT_FOR_HOTEND) thermalManager.wait_for_hotend_heating(active_extruder); #endif - - if (TERN0(BLTOUCH_SLOW_MODE, bltouch.deploy())) return true; // Deploy in LOW SPEED MODE on every probe action + #if ENABLED(BLTOUCH) + if (!bltouch.high_speed_mode && bltouch.deploy()) + return true; // Deploy in LOW SPEED MODE on every probe action + #endif // Disable stealthChop if used. Enable diag1 pin on driver. #if ENABLED(SENSORLESS_PROBING) sensorless_t stealth_states { false }; #if HAS_DELTA_SENSORLESS_PROBING - if (probe.test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall - if (probe.test_sensitivity.y) stealth_states.y = tmc_enable_stallguard(stepperY); + if (test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall + if (test_sensitivity.y) stealth_states.y = tmc_enable_stallguard(stepperY); #endif - if (probe.test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall + if (test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall endstops.enable(true); set_homing_current(true); // The "homing" current also applies to probing #endif @@ -524,15 +548,17 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if ENABLED(SENSORLESS_PROBING) endstops.not_homing(); #if HAS_DELTA_SENSORLESS_PROBING - if (probe.test_sensitivity.x) tmc_disable_stallguard(stepperX, stealth_states.x); - if (probe.test_sensitivity.y) tmc_disable_stallguard(stepperY, stealth_states.y); + if (test_sensitivity.x) tmc_disable_stallguard(stepperX, stealth_states.x); + if (test_sensitivity.y) tmc_disable_stallguard(stepperY, stealth_states.y); #endif - if (probe.test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); + if (test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); set_homing_current(false); #endif - if (probe_triggered && TERN0(BLTOUCH_SLOW_MODE, bltouch.stow())) // Stow in LOW SPEED MODE on every trigger - return true; + #if ENABLED(BLTOUCH) + if (probe_triggered && !bltouch.high_speed_mode && bltouch.stow()) + return true; // Stow in LOW SPEED MODE on every trigger + #endif // Clear endstop flags endstops.hit_on_purpose(); @@ -762,26 +788,31 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai DEBUG_POS("", current_position); } - #if BOTH(BLTOUCH, BLTOUCH_HS_MODE) - if (bltouch.triggered()) bltouch._reset(); + #if ENABLED(BLTOUCH) + if (bltouch.high_speed_mode && bltouch.triggered()) + bltouch._reset(); #endif // On delta keep Z below clip height or do_blocking_move_to will abort - xyz_pos_t npos = { rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, current_position.z), current_position.z) }; - if (probe_relative) { // The given position is in terms of the probe - if (!can_reach(npos)) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable"); - return NAN; - } - npos -= offset_xy; // Get the nozzle position + xyz_pos_t npos = LINEAR_AXIS_ARRAY( + rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, current_position.z), current_position.z), + current_position.i, current_position.j, current_position.k + ); + if (!can_reach(npos, probe_relative)) { + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable"); + return NAN; } - else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle + if (probe_relative) npos -= offset_xy; // Get the nozzle position // Move the probe to the starting XYZ do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S)); float measured_z = NAN; - if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z; + if (!deploy()) { + measured_z = run_z_probe(sanity_check) + offset.z; + TERN_(HAS_PTC, ptc.apply_compensation(measured_z)); + TERN_(X_AXIS_TWIST_COMPENSATION, measured_z += xatc.compensation(npos + offset_xy)); + } if (!isnan(measured_z)) { const bool big_raise = raise_after == PROBE_PT_BIG_RAISE; if (big_raise || raise_after == PROBE_PT_RAISE) diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index f9275ba9fdc4..752e83f46785 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -45,6 +45,14 @@ #define PROBE_TRIGGERED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) #endif +#ifdef Z_AFTER_HOMING + #define Z_POST_CLEARANCE Z_AFTER_HOMING +#elif defined(Z_HOMING_HEIGHT) + #define Z_POST_CLEARANCE Z_HOMING_HEIGHT +#else + #define Z_POST_CLEARANCE 10 +#endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) #ifndef LEVELING_NOZZLE_TEMP #define LEVELING_NOZZLE_TEMP 0 @@ -77,13 +85,20 @@ class Probe { #if HAS_PROBE_XY_OFFSET // Return true if the both nozzle and the probe can reach the given point. // Note: This won't work on SCARA since the probe offset rotates with the arm. - static bool can_reach(const_float_t rx, const_float_t ry) { - return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) // The nozzle can go where it needs to go? - && position_is_reachable(rx, ry, ABS(PROBING_MARGIN)); // Can the nozzle also go near there? + static bool can_reach(const_float_t rx, const_float_t ry, const bool probe_relative=true) { + if (probe_relative) { + return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) // The nozzle can go where it needs to go? + && position_is_reachable(rx, ry, PROBING_MARGIN); // Can the probe also go near there? + } + else { + return position_is_reachable(rx, ry) + && position_is_reachable(rx + offset_xy.x, ry + offset_xy.y, PROBING_MARGIN); + } } #else - static bool can_reach(const_float_t rx, const_float_t ry) { - return position_is_reachable(rx, ry, PROBING_MARGIN); + static bool can_reach(const_float_t rx, const_float_t ry, const bool=true) { + return position_is_reachable(rx, ry) + && position_is_reachable(rx, ry, PROBING_MARGIN); } #endif @@ -96,10 +111,17 @@ class Probe { * Example: For a probe offset of -10,+10, then for the probe to reach 0,0 the * nozzle must be be able to reach +10,-10. */ - static bool can_reach(const_float_t rx, const_float_t ry) { - return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) - && COORDINATE_OKAY(rx, min_x() - fslop, max_x() + fslop) - && COORDINATE_OKAY(ry, min_y() - fslop, max_y() + fslop); + static bool can_reach(const_float_t rx, const_float_t ry, const bool probe_relative=true) { + if (probe_relative) { + return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) + && COORDINATE_OKAY(rx, min_x() - fslop, max_x() + fslop) + && COORDINATE_OKAY(ry, min_y() - fslop, max_y() + fslop); + } + else { + return position_is_reachable(rx, ry) + && COORDINATE_OKAY(rx + offset_xy.x, min_x() - fslop, max_x() + fslop) + && COORDINATE_OKAY(ry + offset_xy.y, min_y() - fslop, max_y() + fslop); + } } #endif @@ -120,7 +142,7 @@ class Probe { static bool set_deployed(const bool) { return false; } - static bool can_reach(const_float_t rx, const_float_t ry) { return position_is_reachable(rx, ry); } + static bool can_reach(const_float_t rx, const_float_t ry, const bool=true) { return position_is_reachable(rx, ry); } #endif @@ -132,7 +154,7 @@ class Probe { #endif } - static bool can_reach(const xy_pos_t &pos) { return can_reach(pos.x, pos.y); } + static bool can_reach(const xy_pos_t &pos, const bool probe_relative=true) { return can_reach(pos.x, pos.y, probe_relative); } static bool good_bounds(const xy_pos_t &lf, const xy_pos_t &rb) { return ( @@ -161,30 +183,30 @@ class Probe { TERN_(DELTA, DELTA_PRINTABLE_RADIUS) TERN_(IS_SCARA, SCARA_PRINTABLE_RADIUS) ); - static constexpr float probe_radius(const xy_pos_t &probe_offset_xy = offset_xy) { + static constexpr float probe_radius(const xy_pos_t &probe_offset_xy=offset_xy) { return printable_radius - _MAX(PROBING_MARGIN, HYPOT(probe_offset_xy.x, probe_offset_xy.y)); } #endif - static constexpr float _min_x(const xy_pos_t &probe_offset_xy = offset_xy) { + static constexpr float _min_x(const xy_pos_t &probe_offset_xy=offset_xy) { return TERN(IS_KINEMATIC, (X_CENTER) - probe_radius(probe_offset_xy), _MAX((X_MIN_BED) + (PROBING_MARGIN_LEFT), (X_MIN_POS) + probe_offset_xy.x) ); } - static constexpr float _max_x(const xy_pos_t &probe_offset_xy = offset_xy) { + static constexpr float _max_x(const xy_pos_t &probe_offset_xy=offset_xy) { return TERN(IS_KINEMATIC, (X_CENTER) + probe_radius(probe_offset_xy), _MIN((X_MAX_BED) - (PROBING_MARGIN_RIGHT), (X_MAX_POS) + probe_offset_xy.x) ); } - static constexpr float _min_y(const xy_pos_t &probe_offset_xy = offset_xy) { + static constexpr float _min_y(const xy_pos_t &probe_offset_xy=offset_xy) { return TERN(IS_KINEMATIC, (Y_CENTER) - probe_radius(probe_offset_xy), _MAX((Y_MIN_BED) + (PROBING_MARGIN_FRONT), (Y_MIN_POS) + probe_offset_xy.y) ); } - static constexpr float _max_y(const xy_pos_t &probe_offset_xy = offset_xy) { + static constexpr float _max_y(const xy_pos_t &probe_offset_xy=offset_xy) { return TERN(IS_KINEMATIC, (Y_CENTER) + probe_radius(probe_offset_xy), _MIN((Y_MAX_BED) - (PROBING_MARGIN_BACK), (Y_MAX_POS) + probe_offset_xy.y) @@ -198,14 +220,14 @@ class Probe { // constexpr helpers used in build-time static_asserts, relying on default probe offsets. class build_time { - static constexpr xyz_pos_t default_probe_xyz_offset = + static constexpr xyz_pos_t default_probe_xyz_offset = xyz_pos_t( #if HAS_BED_PROBE NOZZLE_TO_PROBE_OFFSET #else { 0 } #endif - ; - static constexpr xy_pos_t default_probe_xy_offset = { default_probe_xyz_offset.x, default_probe_xyz_offset.y }; + ); + static constexpr xy_pos_t default_probe_xy_offset = xy_pos_t({ default_probe_xyz_offset.x, default_probe_xyz_offset.y }); public: static constexpr bool can_reach(float x, float y) { diff --git a/Marlin/src/module/servo.cpp b/Marlin/src/module/servo.cpp index 231efe84e1f2..96d5ba9da837 100644 --- a/Marlin/src/module/servo.cpp +++ b/Marlin/src/module/servo.cpp @@ -30,7 +30,7 @@ #include "servo.h" -HAL_SERVO_LIB servo[NUM_SERVOS]; +hal_servo_t servo[NUM_SERVOS]; #if ENABLED(EDITABLE_SERVO_ANGLES) uint16_t servo_angles[NUM_SERVOS][2]; diff --git a/Marlin/src/module/servo.h b/Marlin/src/module/servo.h index 73dbbdddb729..cd55a317a275 100644 --- a/Marlin/src/module/servo.h +++ b/Marlin/src/module/servo.h @@ -112,5 +112,5 @@ #define MOVE_SERVO(I, P) servo[I].move(P) #define DETACH_SERVO(I) servo[I].detach() -extern HAL_SERVO_LIB servo[NUM_SERVOS]; +extern hal_servo_t servo[NUM_SERVOS]; void servo_init(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 0cb29f29e0f1..63bb93765ba8 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V85" +#define EEPROM_VERSION "V86" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -63,6 +63,9 @@ #if HAS_LEVELING #include "../feature/bedlevel/bedlevel.h" + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + #include "../feature/x_twist.h" + #endif #endif #if ENABLED(Z_STEPPER_AUTO_ALIGN) @@ -71,12 +74,16 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../lcd/e3v2/jyersui/dwin.h" #endif +#if ENABLED(HOST_PROMPT_SUPPORT) + #include "../feature/host_actions.h" +#endif + #if HAS_SERVOS #include "servo.h" #endif @@ -154,6 +161,10 @@ #include "../libs/buzzer.h" #endif +#if HAS_FANCHECK + #include "../feature/fancheck.h" +#endif + #if ENABLED(DGUS_LCD_UI_MKS) #include "../lcd/extui/dgus/DGUSScreenHandler.h" #include "../lcd/extui/dgus/DGUSDisplayDef.h" @@ -191,20 +202,32 @@ static const feedRate_t _DMF[] PROGMEM = DEFAULT_MAX_FEEDRATE; */ typedef struct SettingsDataStruct { char version[4]; // Vnn\0 + #if ENABLED(EEPROM_INIT_NOW) + uint32_t build_hash; // Unique build hash + #endif uint16_t crc; // Data Checksum // // DISTINCT_E_FACTORS // - uint8_t esteppers; // DISTINCT_AXES - LINEAR_AXES + uint8_t e_factors; // DISTINCT_AXES - LINEAR_AXES + // + // Planner settings + // planner_settings_t planner_settings; xyze_float_t planner_max_jerk; // M205 XYZE planner.max_jerk float planner_junction_deviation_mm; // M205 J planner.junction_deviation_mm + // + // Home Offset + // xyz_pos_t home_offset; // M206 XYZ / M665 TPZ + // + // Hotend Offset + // #if HAS_HOTEND_OFFSET xyz_pos_t hotend_offset[HOTENDS - 1]; // M218 XYZ #endif @@ -250,6 +273,15 @@ typedef struct SettingsDataStruct { float z_values[3][3]; #endif + // + // X_AXIS_TWIST_COMPENSATION + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + float xatc_spacing; // M423 X Z + float xatc_start; + xatc_array_t xatc_z_offset; + #endif + // // AUTO_BED_LEVELING_UBL // @@ -272,14 +304,17 @@ typedef struct SettingsDataStruct { 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 + int16_t z_offsets_hotend[COUNT(ptc.z_offsets_hotend)]; // M871 E I V #endif #endif // // BLTOUCH // - bool bltouch_last_written_mode; + bool bltouch_od_5v_mode; + #ifdef BLTOUCH_HS_MODE + bool bltouch_high_speed_mode; // M401 S + #endif // // Kinematic Settings @@ -308,11 +343,11 @@ typedef struct SettingsDataStruct { #endif // - // Z_STEPPER_AUTO_ALIGN, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS + // Z_STEPPER_AUTO_ALIGN, HAS_Z_STEPPER_ALIGN_STEPPER_XY // #if ENABLED(Z_STEPPER_AUTO_ALIGN) xy_pos_t z_stepper_align_xy[NUM_Z_STEPPER_DRIVERS]; // M422 S X Y - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY xy_pos_t z_stepper_align_stepper_xy[NUM_Z_STEPPER_DRIVERS]; // M422 W X Y #endif #endif @@ -362,6 +397,13 @@ typedef struct SettingsDataStruct { // uint8_t lcd_brightness; // M256 B + // + // LCD_BACKLIGHT_TIMEOUT + // + #if LCD_BACKLIGHT_TIMEOUT + uint16_t lcd_backlight_timeout; // (G-code needed) + #endif + // // Controller fan settings // @@ -447,7 +489,7 @@ typedef struct SettingsDataStruct { // // Ender-3 V2 DWIN // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) uint8_t dwin_data[eeprom_data_size]; #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) uint8_t dwin_settings[CrealityDWIN.eeprom_data_size]; @@ -491,6 +533,13 @@ typedef struct SettingsDataStruct { bool buzzer_enabled; #endif + // + // Fan tachometer check + // + #if HAS_FANCHECK + bool fan_check_enabled; + #endif + // // MKS UI controller // @@ -567,6 +616,14 @@ void MarlinSettings::postprocess() { // Various factors can change the current position if (oldpos != current_position) report_current_position(); + + // Moved as last update due to interference with Neopixel init + TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast()); + TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness()); + + #if LCD_BACKLIGHT_TIMEOUT + ui.refresh_backlight_timeout(); + #endif } #if BOTH(PRINTCOUNTER, EEPROM_SETTINGS) @@ -616,6 +673,10 @@ void MarlinSettings::postprocess() { #define DEBUG_OUT EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) #include "../core/debug_out.h" +#if BOTH(EEPROM_CHITCHAT, HOST_PROMPT_SUPPORT) + #define HOST_EEPROM_CHITCHAT 1 +#endif + #if ENABLED(EEPROM_SETTINGS) #define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_ERROR_MSG(ERR); eeprom_error = true; } }while(0) @@ -632,13 +693,24 @@ void MarlinSettings::postprocess() { const char version[4] = EEPROM_VERSION; + #if ENABLED(EEPROM_INIT_NOW) + constexpr uint32_t strhash32(const char *s, const uint32_t h=0) { + return *s ? strhash32(s + 1, ((h + *s) << (*s & 3)) ^ *s) : h; + } + constexpr uint32_t build_hash = strhash32(__DATE__ __TIME__); + #endif + bool MarlinSettings::eeprom_error, MarlinSettings::validating; int MarlinSettings::eeprom_index; uint16_t MarlinSettings::working_crc; bool MarlinSettings::size_error(const uint16_t size) { if (size != datasize()) { - DEBUG_ERROR_MSG("EEPROM datasize error."); + DEBUG_ERROR_MSG("EEPROM datasize error." + #if ENABLED(MARLIN_DEV_MODE) + " (Actual:", size, " Expected:", datasize(), ")" + #endif + ); return true; } return false; @@ -658,13 +730,17 @@ void MarlinSettings::postprocess() { // Write or Skip version. (Flash doesn't allow rewrite without erase.) TERN(FLASH_EEPROM_EMULATION, EEPROM_SKIP, EEPROM_WRITE)(ver); - EEPROM_SKIP(working_crc); // Skip the checksum slot + #if ENABLED(EEPROM_INIT_NOW) + EEPROM_SKIP(build_hash); // Skip the hash slot + #endif + + EEPROM_SKIP(working_crc); // Skip the checksum slot working_crc = 0; // clear before first "real data" - const uint8_t esteppers = COUNT(planner.settings.axis_steps_per_mm) - LINEAR_AXES; - _FIELD_TEST(esteppers); - EEPROM_WRITE(esteppers); + const uint8_t e_factors = DISTINCT_AXES - (LINEAR_AXES); + _FIELD_TEST(e_factors); + EEPROM_WRITE(e_factors); // // Planner Motion @@ -822,6 +898,16 @@ void MarlinSettings::postprocess() { #endif } + // + // X Axis Twist Compensation + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + _FIELD_TEST(xatc_spacing); + EEPROM_WRITE(xatc.spacing); + EEPROM_WRITE(xatc.start); + EEPROM_WRITE(xatc.z_offset); + #endif + // // Unified Bed Leveling // @@ -865,9 +951,15 @@ void MarlinSettings::postprocess() { // BLTOUCH // { - _FIELD_TEST(bltouch_last_written_mode); - const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false); - EEPROM_WRITE(bltouch_last_written_mode); + _FIELD_TEST(bltouch_od_5v_mode); + const bool bltouch_od_5v_mode = TERN0(BLTOUCH, bltouch.od_5v_mode); + EEPROM_WRITE(bltouch_od_5v_mode); + + #ifdef BLTOUCH_HS_MODE + _FIELD_TEST(bltouch_high_speed_mode); + const bool bltouch_high_speed_mode = TERN0(BLTOUCH, bltouch.high_speed_mode); + EEPROM_WRITE(bltouch_high_speed_mode); + #endif } // @@ -917,7 +1009,7 @@ void MarlinSettings::postprocess() { #if ENABLED(Z_STEPPER_AUTO_ALIGN) EEPROM_WRITE(z_stepper_align.xy); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY EEPROM_WRITE(z_stepper_align.stepper_xy); #endif #endif @@ -1037,6 +1129,13 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(lcd_brightness); } + // + // LCD Backlight Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + EEPROM_WRITE(ui.lcd_backlight_timeout); + #endif + // // Controller Fan // @@ -1337,14 +1436,15 @@ void MarlinSettings::postprocess() { // { #if ENABLED(BACKLASH_GCODE) - const xyz_float_t &backlash_distance_mm = backlash.distance_mm; - const uint8_t &backlash_correction = backlash.correction; + xyz_float_t backlash_distance_mm; + LOOP_LINEAR_AXES(axis) backlash_distance_mm[axis] = backlash.get_distance_mm((AxisEnum)axis); + const uint8_t backlash_correction = backlash.get_correction_uint8(); #else const xyz_float_t backlash_distance_mm{0}; const uint8_t backlash_correction = 0; #endif #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - const float &backlash_smoothing_mm = backlash.smoothing_mm; + const float backlash_smoothing_mm = backlash.get_smoothing_mm(); #else const float backlash_smoothing_mm = 3; #endif @@ -1369,18 +1469,20 @@ void MarlinSettings::postprocess() { // // Creality DWIN User Data // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) { + _FIELD_TEST(dwin_data); char dwin_data[eeprom_data_size] = { 0 }; DWIN_StoreSettings(dwin_data); - _FIELD_TEST(dwin_data); EEPROM_WRITE(dwin_data); } - #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #endif + + #if ENABLED(DWIN_CREALITY_LCD_JYERSUI) { + _FIELD_TEST(dwin_settings); char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 }; CrealityDWIN.Save_Settings(dwin_settings); - _FIELD_TEST(dwin_settings); EEPROM_WRITE(dwin_settings); } #endif @@ -1433,6 +1535,13 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(ui.buzzer_enabled); #endif + // + // Fan tachometer check + // + #if HAS_FANCHECK + EEPROM_WRITE(fan_check.enabled); + #endif + // // MKS UI controller // @@ -1461,6 +1570,9 @@ void MarlinSettings::postprocess() { eeprom_index = EEPROM_OFFSET; EEPROM_WRITE(version); + #if ENABLED(EEPROM_INIT_NOW) + EEPROM_WRITE(build_hash); + #endif EEPROM_WRITE(final_crc); // Report storage size @@ -1478,7 +1590,10 @@ void MarlinSettings::postprocess() { store_mesh(ubl.storage_slot); #endif - if (!eeprom_error) LCD_MESSAGE(MSG_SETTINGS_STORED); + if (!eeprom_error) { + LCD_MESSAGE(MSG_SETTINGS_STORED); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_SETTINGS_STORED))); + } TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreWritten(!eeprom_error)); @@ -1494,9 +1609,6 @@ void MarlinSettings::postprocess() { char stored_ver[4]; EEPROM_READ_ALWAYS(stored_ver); - uint16_t stored_crc; - EEPROM_READ_ALWAYS(stored_crc); - // Version has to match or defaults are used if (strncmp(version, stored_ver, 3) != 0) { if (stored_ver[3] != '\0') { @@ -1504,20 +1616,32 @@ void MarlinSettings::postprocess() { stored_ver[1] = '\0'; } DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_VERSION)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_ERR_EEPROM_VERSION)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_VERSION))); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version()); eeprom_error = true; } else { + + // Optionally reset on the first boot after flashing + #if ENABLED(EEPROM_INIT_NOW) + uint32_t stored_hash; + EEPROM_READ_ALWAYS(stored_hash); + if (stored_hash != build_hash) { EEPROM_FINISH(); return false; } + #endif + + uint16_t stored_crc; + EEPROM_READ_ALWAYS(stored_crc); + float dummyf = 0; working_crc = 0; // Init to 0. Accumulated by EEPROM_READ - _FIELD_TEST(esteppers); + _FIELD_TEST(e_factors); - // Number of esteppers may change - uint8_t esteppers; - EEPROM_READ_ALWAYS(esteppers); + // Number of e_factors may change + uint8_t e_factors; + EEPROM_READ_ALWAYS(e_factors); // // Planner Motion @@ -1525,16 +1649,16 @@ void MarlinSettings::postprocess() { { // Get only the number of E stepper parameters previously stored // Any steppers added later are set to their defaults - uint32_t tmp1[LINEAR_AXES + esteppers]; - float tmp2[LINEAR_AXES + esteppers]; - feedRate_t tmp3[LINEAR_AXES + esteppers]; + uint32_t tmp1[LINEAR_AXES + e_factors]; + float tmp2[LINEAR_AXES + e_factors]; + feedRate_t tmp3[LINEAR_AXES + e_factors]; EEPROM_READ((uint8_t *)tmp1, sizeof(tmp1)); // max_acceleration_mm_per_s2 EEPROM_READ(planner.settings.min_segment_time_us); EEPROM_READ((uint8_t *)tmp2, sizeof(tmp2)); // axis_steps_per_mm EEPROM_READ((uint8_t *)tmp3, sizeof(tmp3)); // max_feedrate_mm_s if (!validating) LOOP_DISTINCT_AXES(i) { - const bool in = (i < esteppers + LINEAR_AXES); + const bool in = (i < e_factors + LINEAR_AXES); planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : pgm_read_dword(&_DMA[ALIM(i, _DMA)]); planner.settings.axis_steps_per_mm[i] = in ? tmp2[i] : pgm_read_float(&_DASU[ALIM(i, _DASU)]); planner.settings.max_feedrate_mm_s[i] = in ? tmp3[i] : pgm_read_float(&_DMF[ALIM(i, _DMF)]); @@ -1685,6 +1809,16 @@ void MarlinSettings::postprocess() { } } + // + // X Axis Twist Compensation + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + _FIELD_TEST(xatc_spacing); + EEPROM_READ(xatc.spacing); + EEPROM_READ(xatc.start); + EEPROM_READ(xatc.z_offset); + #endif + // // Unified Bed Leveling active state // @@ -1736,13 +1870,23 @@ void MarlinSettings::postprocess() { // BLTOUCH // { - _FIELD_TEST(bltouch_last_written_mode); + _FIELD_TEST(bltouch_od_5v_mode); #if ENABLED(BLTOUCH) - const bool &bltouch_last_written_mode = bltouch.last_written_mode; + const bool &bltouch_od_5v_mode = bltouch.od_5v_mode; #else - bool bltouch_last_written_mode; + bool bltouch_od_5v_mode; + #endif + EEPROM_READ(bltouch_od_5v_mode); + + #ifdef BLTOUCH_HS_MODE + _FIELD_TEST(bltouch_high_speed_mode); + #if ENABLED(BLTOUCH) + const bool &bltouch_high_speed_mode = bltouch.high_speed_mode; + #else + bool bltouch_high_speed_mode; + #endif + EEPROM_READ(bltouch_high_speed_mode); #endif - EEPROM_READ(bltouch_last_written_mode); } // @@ -1789,7 +1933,7 @@ void MarlinSettings::postprocess() { #if ENABLED(Z_STEPPER_AUTO_ALIGN) EEPROM_READ(z_stepper_align.xy); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY EEPROM_READ(z_stepper_align.stepper_xy); #endif #endif @@ -1872,8 +2016,10 @@ void MarlinSettings::postprocess() { // #if HAS_USER_THERMISTORS { + user_thermistor_t user_thermistor[USER_THERMISTORS]; _FIELD_TEST(user_thermistor); - EEPROM_READ(thermalManager.user_thermistor); + EEPROM_READ(user_thermistor); + if (!validating) COPY(thermalManager.user_thermistor, user_thermistor); } #endif @@ -1881,80 +2027,74 @@ void MarlinSettings::postprocess() { // Power monitor // { - #if HAS_POWER_MONITOR - uint8_t &power_monitor_flags = power_monitor.flags; - #else - uint8_t power_monitor_flags; - #endif + uint8_t power_monitor_flags; _FIELD_TEST(power_monitor_flags); EEPROM_READ(power_monitor_flags); + TERN_(HAS_POWER_MONITOR, if (!validating) power_monitor.flags = power_monitor_flags); } // // LCD Contrast // { - _FIELD_TEST(lcd_contrast); uint8_t lcd_contrast; + _FIELD_TEST(lcd_contrast); EEPROM_READ(lcd_contrast); - if (!validating) { - TERN_(HAS_LCD_CONTRAST, ui.set_contrast(lcd_contrast)); - } + TERN_(HAS_LCD_CONTRAST, if (!validating) ui.contrast = lcd_contrast); } // // LCD Brightness // { - _FIELD_TEST(lcd_brightness); uint8_t lcd_brightness; + _FIELD_TEST(lcd_brightness); EEPROM_READ(lcd_brightness); - TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.set_brightness(lcd_brightness)); + TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.brightness = lcd_brightness); } + // + // LCD Backlight Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + EEPROM_READ(ui.lcd_backlight_timeout); + #endif + // // Controller Fan // { + controllerFan_settings_t cfs = { 0 }; _FIELD_TEST(controllerFan_settings); - #if ENABLED(CONTROLLER_FAN_EDITABLE) - const controllerFan_settings_t &cfs = controllerFan.settings; - #else - controllerFan_settings_t cfs = { 0 }; - #endif EEPROM_READ(cfs); + TERN_(CONTROLLER_FAN_EDITABLE, if (!validating) controllerFan.settings = cfs); } // // Power-Loss Recovery // { + bool recovery_enabled; _FIELD_TEST(recovery_enabled); - #if ENABLED(POWER_LOSS_RECOVERY) - const bool &recovery_enabled = recovery.enabled; - #else - bool recovery_enabled; - #endif EEPROM_READ(recovery_enabled); + TERN_(POWER_LOSS_RECOVERY, if (!validating) recovery.enabled = recovery_enabled); } // // Firmware Retraction // { + fwretract_settings_t fwretract_settings; + bool autoretract_enabled; _FIELD_TEST(fwretract_settings); + EEPROM_READ(fwretract_settings); + EEPROM_READ(autoretract_enabled); #if ENABLED(FWRETRACT) - EEPROM_READ(fwretract.settings); - #else - fwretract_settings_t fwretract_settings; - EEPROM_READ(fwretract_settings); - #endif - #if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT) - EEPROM_READ(fwretract.autoretract_enabled); - #else - bool autoretract_enabled; - EEPROM_READ(autoretract_enabled); + if (!validating) { + fwretract.settings = fwretract_settings; + TERN_(FWRETRACT_AUTORETRACT, fwretract.autoretract_enabled = autoretract_enabled); + } #endif } @@ -2244,22 +2384,22 @@ void MarlinSettings::postprocess() { // Backlash Compensation // { - #if ENABLED(BACKLASH_GCODE) - const xyz_float_t &backlash_distance_mm = backlash.distance_mm; - const uint8_t &backlash_correction = backlash.correction; - #else - xyz_float_t backlash_distance_mm; - uint8_t backlash_correction; - #endif - #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - const float &backlash_smoothing_mm = backlash.smoothing_mm; - #else - float backlash_smoothing_mm; - #endif + xyz_float_t backlash_distance_mm; + uint8_t backlash_correction; + float backlash_smoothing_mm; + _FIELD_TEST(backlash_distance_mm); EEPROM_READ(backlash_distance_mm); EEPROM_READ(backlash_correction); EEPROM_READ(backlash_smoothing_mm); + + #if ENABLED(BACKLASH_GCODE) + LOOP_LINEAR_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, backlash_distance_mm[axis]); + backlash.set_correction_uint8(backlash_correction); + #ifdef BACKLASH_SMOOTHING_MM + backlash.set_smoothing_mm(backlash_smoothing_mm); + #endif + #endif } // @@ -2277,7 +2417,7 @@ void MarlinSettings::postprocess() { // // Creality DWIN User Data // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) { const char dwin_data[eeprom_data_size] = { 0 }; _FIELD_TEST(dwin_data); @@ -2339,6 +2479,14 @@ void MarlinSettings::postprocess() { EEPROM_READ(ui.buzzer_enabled); #endif + // + // Fan tachometer check + // + #if HAS_FANCHECK + _FIELD_TEST(fan_check_enabled); + EEPROM_READ(fan_check.enabled); + #endif + // // MKS UI controller // @@ -2373,13 +2521,15 @@ void MarlinSettings::postprocess() { else if (working_crc != stored_crc) { eeprom_error = true; DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_CRC)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_ERR_EEPROM_CRC)); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_CRC))); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc()); } else if (!validating) { DEBUG_ECHO_START(); DEBUG_ECHO(version); DEBUG_ECHOLNPGM(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)working_crc, ")"); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(F("Stored settings retrieved"))); } if (!validating && !eeprom_error) postprocess(); @@ -2452,7 +2602,7 @@ void MarlinSettings::postprocess() { return success; } reset(); - #if ENABLED(EEPROM_AUTO_INIT) + #if EITHER(EEPROM_AUTO_INIT, EEPROM_INIT_NOW) (void)save(); SERIAL_ECHO_MSG("EEPROM Initialized"); #endif @@ -2611,13 +2761,13 @@ void MarlinSettings::reset() { #if HAS_Z_AXIS && !defined(DEFAULT_ZJERK) #define DEFAULT_ZJERK 0 #endif - #if LINEAR_AXES >= 4 && !defined(DEFAULT_IJERK) + #if HAS_I_AXIS && !defined(DEFAULT_IJERK) #define DEFAULT_IJERK 0 #endif - #if LINEAR_AXES >= 5 && !defined(DEFAULT_JJERK) + #if HAS_J_AXIS && !defined(DEFAULT_JJERK) #define DEFAULT_JJERK 0 #endif - #if LINEAR_AXES >= 6 && !defined(DEFAULT_KJERK) + #if HAS_K_AXIS && !defined(DEFAULT_KJERK) #define DEFAULT_KJERK 0 #endif planner.max_jerk.set( @@ -2681,16 +2831,15 @@ void MarlinSettings::reset() { #endif #if ENABLED(BACKLASH_GCODE) - backlash.correction = (BACKLASH_CORRECTION) * 255; + backlash.set_correction(BACKLASH_CORRECTION); constexpr xyz_float_t tmp = BACKLASH_DISTANCE_MM; - backlash.distance_mm = tmp; + LOOP_LINEAR_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, tmp[axis]); #ifdef BACKLASH_SMOOTHING_MM - backlash.smoothing_mm = BACKLASH_SMOOTHING_MM; + backlash.set_smoothing_mm(BACKLASH_SMOOTHING_MM); #endif #endif - TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_SetDataDefaults()); + TERN_(DWIN_LCD_PROUI, DWIN_SetDataDefaults()); TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Reset_Settings()); // @@ -2719,6 +2868,14 @@ void MarlinSettings::reset() { TERN_(ENABLE_LEVELING_FADE_HEIGHT, new_z_fade_height = (DEFAULT_LEVELING_FADE_HEIGHT)); TERN_(HAS_LEVELING, reset_bed_level()); + // + // X Axis Twist Compensation + // + TERN_(X_AXIS_TWIST_COMPENSATION, xatc.reset()); + + // + // Nozzle-to-probe Offset + // #if HAS_BED_PROBE constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET; static_assert(COUNT(dpo) == LINEAR_AXES, "NOZZLE_TO_PROBE_OFFSET must contain offsets for each linear axis X, Y, Z...."); @@ -2745,11 +2902,11 @@ void MarlinSettings::reset() { TERN_(HAS_PTC, ptc.reset()); // - // BLTOUCH + // BLTouch // - //#if ENABLED(BLTOUCH) - // bltouch.last_written_mode; - //#endif + #ifdef BLTOUCH_HS_MODE + bltouch.high_speed_mode = ENABLED(BLTOUCH_HS_MODE); + #endif // // Kinematic settings @@ -2929,12 +3086,19 @@ void MarlinSettings::reset() { // // LCD Contrast // - TERN_(HAS_LCD_CONTRAST, ui.set_contrast(DEFAULT_LCD_CONTRAST)); + TERN_(HAS_LCD_CONTRAST, ui.contrast = LCD_CONTRAST_DEFAULT); // // LCD Brightness // - TERN_(HAS_LCD_BRIGHTNESS, ui.set_brightness(DEFAULT_LCD_BRIGHTNESS)); + TERN_(HAS_LCD_BRIGHTNESS, ui.brightness = LCD_BRIGHTNESS_DEFAULT); + + // + // LCD Backlight Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + ui.lcd_backlight_timeout = LCD_BACKLIGHT_TIMEOUT; + #endif // // Controller Fan @@ -3036,6 +3200,11 @@ void MarlinSettings::reset() { #endif #endif + // + // Fan tachometer check + // + TERN_(HAS_FANCHECK, fan_check.enabled = true); + // // MKS UI controller // @@ -3043,7 +3212,13 @@ void MarlinSettings::reset() { postprocess(); - DEBUG_ECHO_MSG("Hardcoded Default Settings Loaded"); + #if EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) + FSTR_P const hdsl = F("Hardcoded Default Settings Loaded"); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(hdsl)); + DEBUG_ECHO_START(); DEBUG_ECHOLNF(hdsl); + #endif + + TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); } #if DISABLED(DISABLE_M503) @@ -3065,12 +3240,13 @@ void MarlinSettings::reset() { // Announce current units, in case inches are being displayed // CONFIG_ECHO_HEADING("Linear Units"); + CONFIG_ECHO_START(); #if ENABLED(INCH_MODE_SUPPORT) - SERIAL_ECHO_MSG(" G2", AS_DIGIT(parser.linear_unit_factor == 1.0), " ;"); + SERIAL_ECHOPGM(" G2", AS_DIGIT(parser.linear_unit_factor == 1.0), " ;"); #else - SERIAL_ECHO_MSG(" G21 ;"); + SERIAL_ECHOPGM(" G21 ;"); #endif - gcode.say_units(); + gcode.say_units(); // " (in/mm)" // // M149 Temperature units @@ -3170,6 +3346,11 @@ void MarlinSettings::reset() { #endif // HAS_LEVELING + // + // X Axis Twist Compensation + // + TERN_(X_AXIS_TWIST_COMPENSATION, gcode.M423_report(forReplay)); + // // Editable Servo Angles // diff --git a/Marlin/src/module/settings.h b/Marlin/src/module/settings.h index 967d49c0738e..a8fca60baa12 100644 --- a/Marlin/src/module/settings.h +++ b/Marlin/src/module/settings.h @@ -59,7 +59,7 @@ class MarlinSettings { static bool load(); // Return 'true' if data was loaded ok static bool validate(); // Return 'true' if EEPROM data is ok - static inline void first_load() { + static void first_load() { static bool loaded = false; if (!loaded && load()) loaded = true; } diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 2c8933266fa3..f83104fe9c47 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -435,15 +435,15 @@ xyze_int8_t Stepper::count_direction{0}; #define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define I_APPLY_DIR(v,Q) I_DIR_WRITE(v) #define I_APPLY_STEP(v,Q) I_STEP_WRITE(v) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define J_APPLY_DIR(v,Q) J_DIR_WRITE(v) #define J_APPLY_STEP(v,Q) J_STEP_WRITE(v) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define K_APPLY_DIR(v,Q) K_DIR_WRITE(v) #define K_APPLY_STEP(v,Q) K_STEP_WRITE(v) #endif @@ -464,8 +464,8 @@ xyze_int8_t Stepper::count_direction{0}; #define PULSE_LOW_TICK_COUNT hal_timer_t(NS_TO_PULSE_TIMER_TICKS(_MIN_PULSE_LOW_NS - _MIN(_MIN_PULSE_LOW_NS, TIMER_SETUP_NS))) #define USING_TIMED_PULSE() hal_timer_t start_pulse_count = 0 -#define START_TIMED_PULSE(DIR) (start_pulse_count = HAL_timer_get_count(PULSE_TIMER_NUM)) -#define AWAIT_TIMED_PULSE(DIR) while (PULSE_##DIR##_TICK_COUNT > HAL_timer_get_count(PULSE_TIMER_NUM) - start_pulse_count) { } +#define START_TIMED_PULSE(DIR) (start_pulse_count = HAL_timer_get_count(MF_TIMER_PULSE)) +#define AWAIT_TIMED_PULSE(DIR) while (PULSE_##DIR##_TICK_COUNT > HAL_timer_get_count(MF_TIMER_PULSE) - start_pulse_count) { } #define START_HIGH_PULSE() START_TIMED_PULSE(HIGH) #define AWAIT_HIGH_PULSE() AWAIT_TIMED_PULSE(HIGH) #define START_LOW_PULSE() START_TIMED_PULSE(LOW) @@ -497,6 +497,9 @@ void Stepper::enable_axis(const AxisEnum axis) { bool Stepper::disable_axis(const AxisEnum axis) { mark_axis_disabled(axis); + + TERN_(DWIN_LCD_PROUI, set_axis_untrusted(axis)); // MRISCOC workaround: https://github.com/MarlinFirmware/Marlin/issues/23095 + // If all the axes that share the enabled bit are disabled const bool can_disable = can_axis_disable(axis); if (can_disable) { @@ -522,7 +525,7 @@ bool Stepper::disable_axis(const AxisEnum axis) { } } - bool Stepper::disable_extruder(E_TERN_(const uint8_t eindex)) { + bool Stepper::disable_extruder(E_TERN_(const uint8_t eindex/*=0*/)) { IF_DISABLED(HAS_MULTI_EXTRUDER, constexpr uint8_t eindex = 0); mark_axis_disabled(E_AXIS E_OPTARG(eindex)); const bool can_disable = can_axis_disable(E_AXIS E_OPTARG(eindex)); @@ -1380,7 +1383,7 @@ void Stepper::set_directions() { } FORCE_INLINE int32_t Stepper::_eval_bezier_curve(const uint32_t curr_step) { - #if defined(__arm__) || defined(__thumb__) + #if (defined(__arm__) || defined(__thumb__)) && !defined(STM32G0B1xx) // TODO: Test define STM32G0xx versus STM32G0B1xx // For ARM Cortex M3/M4 CPUs, we have the optimized assembler version, that takes 43 cycles to execute uint32_t flo = 0; @@ -1454,11 +1457,11 @@ void Stepper::set_directions() { */ HAL_STEP_TIMER_ISR() { - HAL_timer_isr_prologue(STEP_TIMER_NUM); + HAL_timer_isr_prologue(MF_TIMER_STEP); Stepper::isr(); - HAL_timer_isr_epilogue(STEP_TIMER_NUM); + HAL_timer_isr_epilogue(MF_TIMER_STEP); } #ifdef CPU_32_BIT @@ -1474,13 +1477,13 @@ void Stepper::isr() { #ifndef __AVR__ // Disable interrupts, to avoid ISR preemption while we reprogram the period // (AVR enters the ISR with global interrupts disabled, so no need to do it here) - DISABLE_ISRS(); + hal.isr_off(); #endif // Program timer compare for the maximum period, so it does NOT // flag an interrupt while this ISR is running - So changes from small // periods to big periods are respected and the timer does not reset to 0 - HAL_timer_set_compare(STEP_TIMER_NUM, hal_timer_t(HAL_TIMER_TYPE_MAX)); + HAL_timer_set_compare(MF_TIMER_STEP, hal_timer_t(HAL_TIMER_TYPE_MAX)); // Count of ticks for the next ISR hal_timer_t next_isr_ticks = 0; @@ -1492,7 +1495,7 @@ void Stepper::isr() { hal_timer_t min_ticks; do { // Enable ISRs to reduce USART processing latency - ENABLE_ISRS(); + hal.isr_on(); if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses @@ -1576,7 +1579,7 @@ void Stepper::isr() { * is less than the current count due to something preempting between the * read and the write of the new period value). */ - DISABLE_ISRS(); + hal.isr_off(); /** * Get the current tick value + margin @@ -1584,7 +1587,7 @@ void Stepper::isr() { * On AVR the ISR epilogue+prologue is estimated at 100 instructions - Give 8µs as margin * On ARM the ISR epilogue+prologue is estimated at 20 instructions - Give 1µs as margin */ - min_ticks = HAL_timer_get_count(STEP_TIMER_NUM) + hal_timer_t( + min_ticks = HAL_timer_get_count(MF_TIMER_STEP) + hal_timer_t( #ifdef __AVR__ 8 #else @@ -1608,10 +1611,10 @@ void Stepper::isr() { // sure that the time has not arrived yet - Warrantied by the scheduler // Set the next ISR to fire at the proper time - HAL_timer_set_compare(STEP_TIMER_NUM, hal_timer_t(next_isr_ticks)); + HAL_timer_set_compare(MF_TIMER_STEP, hal_timer_t(next_isr_ticks)); // Don't forget to finally reenable interrupts - ENABLE_ISRS(); + hal.isr_on(); } #if MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE @@ -1688,7 +1691,7 @@ void Stepper::pulse_phase_isr() { const bool is_page = IS_PAGE(current_block); #if ENABLED(DIRECT_STEPPING) - // TODO (DerAndere): Add support for LINEAR_AXES >= 4 + // Direct stepping is currently not ready for HAS_I_AXIS if (is_page) { #if STEPPER_PAGE_FORMAT == SP_4x4D_128 @@ -1929,7 +1932,7 @@ uint32_t Stepper::block_phase_isr() { // If current block is finished, reset pointer and finalize state if (step_events_completed >= step_event_count) { #if ENABLED(DIRECT_STEPPING) - // TODO (DerAndere): Add support for LINEAR_AXES >= 4 + // Direct stepping is currently not ready for HAS_I_AXIS #if STEPPER_PAGE_FORMAT == SP_4x4D_128 #define PAGE_SEGMENT_UPDATE_POS(AXIS) \ count_position[_AXIS(AXIS)] += page_step_state.bd[_AXIS(AXIS)] - 128 * 7; @@ -2151,7 +2154,10 @@ uint32_t Stepper::block_phase_isr() { cutter.apply_power(current_block->cutter_power); #endif - TERN_(POWER_LOSS_RECOVERY, recovery.info.sdpos = current_block->sdpos); + #if ENABLED(POWER_LOSS_RECOVERY) + recovery.info.sdpos = current_block->sdpos; + recovery.info.current_position = current_block->start_position; + #endif #if ENABLED(DIRECT_STEPPING) if (IS_PAGE(current_block)) { @@ -2212,6 +2218,8 @@ uint32_t Stepper::block_phase_isr() { #define Y_CMP(A,B) ((A)!=(B)) #endif #define Y_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && Y_CMP(D_(1),D_(2))) ) + #elif ENABLED(MARKFORGED_YX) + #define Y_MOVE_TEST (current_block->steps.a != current_block->steps.b) #else #define Y_MOVE_TEST !!current_block->steps.b #endif @@ -2344,13 +2352,9 @@ uint32_t Stepper::block_phase_isr() { #endif #endif // LASER_POWER_INLINE - // At this point, we must ensure the movement about to execute isn't - // trying to force the head against a limit switch. If using interrupt- - // driven change detection, and already against a limit then no call to - // the endstop_triggered method will be done and the movement will be - // done against the endstop. So, check the limits here: If the movement - // is against the limits, the block will be marked as to be killed, and - // on the next call to this ISR, will be discarded. + // If the endstop is already pressed, endstop interrupts won't invoke + // endstop_triggered and the move will grind. So check here for a + // triggered endstop, which marks the block for discard on the next ISR. endstops.update(); #if ENABLED(Z_LATE_ENABLE) @@ -2767,7 +2771,7 @@ void Stepper::init() { #endif #if DISABLED(I2S_STEPPER_STREAM) - HAL_timer_start(STEP_TIMER_NUM, 122); // Init Stepper ISR to 122 Hz for quick starting + HAL_timer_start(MF_TIMER_STEP, 122); // Init Stepper ISR to 122 Hz for quick starting wake_up(); sei(); #endif @@ -2800,7 +2804,7 @@ void Stepper::init() { * derive the current XYZE position later on. */ void Stepper::_set_position(const abce_long_t &spos) { - #if EITHER(IS_CORE, MARKFORGED_XY) + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) #if CORE_IS_XY // corexy positioning // these equations follow the form of the dA and dB equations on https://www.corexy.com/theory.html @@ -2813,6 +2817,8 @@ void Stepper::_set_position(const abce_long_t &spos) { count_position.set(spos.a, spos.b + spos.c, CORESIGN(spos.b - spos.c)); #elif ENABLED(MARKFORGED_XY) count_position.set(spos.a - spos.b, spos.b, spos.c); + #elif ENABLED(MARKFORGED_YX) + count_position.set(spos.a, spos.b - spos.a, spos.c); #endif TERN_(HAS_EXTRUDERS, count_position.e = spos.e); #else @@ -2884,6 +2890,10 @@ void Stepper::endstop_triggered(const AxisEnum axis) { axis == CORE_AXIS_1 ? count_position[CORE_AXIS_1] - count_position[CORE_AXIS_2] : count_position[CORE_AXIS_2] + #elif ENABLED(MARKFORGED_YX) + axis == CORE_AXIS_1 + ? count_position[CORE_AXIS_1] + : count_position[CORE_AXIS_2] - count_position[CORE_AXIS_1] #else // !IS_CORE count_position[axis] #endif @@ -2912,10 +2922,10 @@ int32_t Stepper::triggered_position(const AxisEnum axis) { return v; } -#if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, IS_SCARA, DELTA) +#if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX, IS_SCARA, DELTA) #define SAYS_A 1 #endif -#if ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY, IS_SCARA, DELTA) +#if ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY, MARKFORGED_YX, IS_SCARA, DELTA) #define SAYS_B 1 #endif #if ANY(CORE_IS_XZ, CORE_IS_YZ, DELTA) @@ -2972,8 +2982,8 @@ void Stepper::report_positions() { #define EXTRA_CYCLES_BABYSTEP (STEP_PULSE_CYCLES - (CYCLES_EATEN_BABYSTEP)) #if EXTRA_CYCLES_BABYSTEP > 20 - #define _SAVE_START() const hal_timer_t pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM) - #define _PULSE_WAIT() while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } + #define _SAVE_START() const hal_timer_t pulse_start = HAL_timer_get_count(MF_TIMER_PULSE) + #define _PULSE_WAIT() while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_count(MF_TIMER_PULSE) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } #else #define _SAVE_START() NOOP #if EXTRA_CYCLES_BABYSTEP > 0 @@ -3176,13 +3186,13 @@ void Stepper::report_positions() { } break; - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case I_AXIS: BABYSTEP_AXIS(I, 0, direction); break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: BABYSTEP_AXIS(J, 0, direction); break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: BABYSTEP_AXIS(K, 0, direction); break; #endif @@ -3253,7 +3263,7 @@ void Stepper::report_positions() { #elif HAS_MOTOR_CURRENT_PWM - #define _WRITE_CURRENT_PWM(P) set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) + #define _WRITE_CURRENT_PWM(P) hal.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) @@ -3298,34 +3308,37 @@ void Stepper::report_positions() { #elif HAS_MOTOR_CURRENT_PWM + #ifdef __SAM3X8E__ + #define _RESET_CURRENT_PWM_FREQ(P) NOOP + #else + #define _RESET_CURRENT_PWM_FREQ(P) hal.set_pwm_frequency(pin_t(P), MOTOR_CURRENT_PWM_FREQUENCY) + #endif + #define INIT_CURRENT_PWM(P) do{ SET_PWM(MOTOR_CURRENT_PWM_## P ##_PIN); _RESET_CURRENT_PWM_FREQ(MOTOR_CURRENT_PWM_## P ##_PIN); }while(0) + #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) - SET_PWM(MOTOR_CURRENT_PWM_X_PIN); + INIT_CURRENT_PWM(X); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) - SET_PWM(MOTOR_CURRENT_PWM_Y_PIN); + INIT_CURRENT_PWM(Y); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - SET_PWM(MOTOR_CURRENT_PWM_XY_PIN); + INIT_CURRENT_PWM(XY); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - SET_PWM(MOTOR_CURRENT_PWM_Z_PIN); + INIT_CURRENT_PWM(Z); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - SET_PWM(MOTOR_CURRENT_PWM_E_PIN); + INIT_CURRENT_PWM(E); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) - SET_PWM(MOTOR_CURRENT_PWM_E0_PIN); + INIT_CURRENT_PWM(E0); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) - SET_PWM(MOTOR_CURRENT_PWM_E1_PIN); + INIT_CURRENT_PWM(E1); #endif refresh_motor_power(); - // Set Timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise) - #ifdef __AVR__ - SET_CS5(PRESCALER_1); - #endif #endif } @@ -3345,113 +3358,115 @@ void Stepper::report_positions() { void Stepper::microstep_init() { #if HAS_X_MS_PINS - SET_OUTPUT(X_MS1_PIN); - SET_OUTPUT(X_MS2_PIN); + SET_OUTPUT(X_MS1_PIN); SET_OUTPUT(X_MS2_PIN); #if PIN_EXISTS(X_MS3) SET_OUTPUT(X_MS3_PIN); #endif #endif #if HAS_X2_MS_PINS - SET_OUTPUT(X2_MS1_PIN); - SET_OUTPUT(X2_MS2_PIN); + SET_OUTPUT(X2_MS1_PIN); SET_OUTPUT(X2_MS2_PIN); #if PIN_EXISTS(X2_MS3) SET_OUTPUT(X2_MS3_PIN); #endif #endif #if HAS_Y_MS_PINS - SET_OUTPUT(Y_MS1_PIN); - SET_OUTPUT(Y_MS2_PIN); + SET_OUTPUT(Y_MS1_PIN); SET_OUTPUT(Y_MS2_PIN); #if PIN_EXISTS(Y_MS3) SET_OUTPUT(Y_MS3_PIN); #endif #endif #if HAS_Y2_MS_PINS - SET_OUTPUT(Y2_MS1_PIN); - SET_OUTPUT(Y2_MS2_PIN); + SET_OUTPUT(Y2_MS1_PIN); SET_OUTPUT(Y2_MS2_PIN); #if PIN_EXISTS(Y2_MS3) SET_OUTPUT(Y2_MS3_PIN); #endif #endif #if HAS_Z_MS_PINS - SET_OUTPUT(Z_MS1_PIN); - SET_OUTPUT(Z_MS2_PIN); + SET_OUTPUT(Z_MS1_PIN); SET_OUTPUT(Z_MS2_PIN); #if PIN_EXISTS(Z_MS3) SET_OUTPUT(Z_MS3_PIN); #endif #endif #if HAS_Z2_MS_PINS - SET_OUTPUT(Z2_MS1_PIN); - SET_OUTPUT(Z2_MS2_PIN); + SET_OUTPUT(Z2_MS1_PIN); SET_OUTPUT(Z2_MS2_PIN); #if PIN_EXISTS(Z2_MS3) SET_OUTPUT(Z2_MS3_PIN); #endif #endif #if HAS_Z3_MS_PINS - SET_OUTPUT(Z3_MS1_PIN); - SET_OUTPUT(Z3_MS2_PIN); + SET_OUTPUT(Z3_MS1_PIN); SET_OUTPUT(Z3_MS2_PIN); #if PIN_EXISTS(Z3_MS3) SET_OUTPUT(Z3_MS3_PIN); #endif #endif #if HAS_Z4_MS_PINS - SET_OUTPUT(Z4_MS1_PIN); - SET_OUTPUT(Z4_MS2_PIN); + SET_OUTPUT(Z4_MS1_PIN); SET_OUTPUT(Z4_MS2_PIN); #if PIN_EXISTS(Z4_MS3) SET_OUTPUT(Z4_MS3_PIN); #endif #endif + #if HAS_I_MS_PINS + SET_OUTPUT(I_MS1_PIN); SET_OUTPUT(I_MS2_PIN); + #if PIN_EXISTS(I_MS3) + SET_OUTPUT(I_MS3_PIN); + #endif + #endif + #if HAS_J_MS_PINS + SET_OUTPUT(J_MS1_PIN); SET_OUTPUT(J_MS2_PIN); + #if PIN_EXISTS(J_MS3) + SET_OUTPUT(J_MS3_PIN); + #endif + #endif + #if HAS_K_MS_PINS + SET_OUTPUT(K_MS1_PIN); SET_OUTPUT(K_MS2_PIN); + #if PIN_EXISTS(K_MS3) + SET_OUTPUT(K_MS3_PIN); + #endif + #endif #if HAS_E0_MS_PINS - SET_OUTPUT(E0_MS1_PIN); - SET_OUTPUT(E0_MS2_PIN); + SET_OUTPUT(E0_MS1_PIN); SET_OUTPUT(E0_MS2_PIN); #if PIN_EXISTS(E0_MS3) SET_OUTPUT(E0_MS3_PIN); #endif #endif #if HAS_E1_MS_PINS - SET_OUTPUT(E1_MS1_PIN); - SET_OUTPUT(E1_MS2_PIN); + SET_OUTPUT(E1_MS1_PIN); SET_OUTPUT(E1_MS2_PIN); #if PIN_EXISTS(E1_MS3) SET_OUTPUT(E1_MS3_PIN); #endif #endif #if HAS_E2_MS_PINS - SET_OUTPUT(E2_MS1_PIN); - SET_OUTPUT(E2_MS2_PIN); + SET_OUTPUT(E2_MS1_PIN); SET_OUTPUT(E2_MS2_PIN); #if PIN_EXISTS(E2_MS3) SET_OUTPUT(E2_MS3_PIN); #endif #endif #if HAS_E3_MS_PINS - SET_OUTPUT(E3_MS1_PIN); - SET_OUTPUT(E3_MS2_PIN); + SET_OUTPUT(E3_MS1_PIN); SET_OUTPUT(E3_MS2_PIN); #if PIN_EXISTS(E3_MS3) SET_OUTPUT(E3_MS3_PIN); #endif #endif #if HAS_E4_MS_PINS - SET_OUTPUT(E4_MS1_PIN); - SET_OUTPUT(E4_MS2_PIN); + SET_OUTPUT(E4_MS1_PIN); SET_OUTPUT(E4_MS2_PIN); #if PIN_EXISTS(E4_MS3) SET_OUTPUT(E4_MS3_PIN); #endif #endif #if HAS_E5_MS_PINS - SET_OUTPUT(E5_MS1_PIN); - SET_OUTPUT(E5_MS2_PIN); + SET_OUTPUT(E5_MS1_PIN); SET_OUTPUT(E5_MS2_PIN); #if PIN_EXISTS(E5_MS3) SET_OUTPUT(E5_MS3_PIN); #endif #endif #if HAS_E6_MS_PINS - SET_OUTPUT(E6_MS1_PIN); - SET_OUTPUT(E6_MS2_PIN); + SET_OUTPUT(E6_MS1_PIN); SET_OUTPUT(E6_MS2_PIN); #if PIN_EXISTS(E6_MS3) SET_OUTPUT(E6_MS3_PIN); #endif #endif #if HAS_E7_MS_PINS - SET_OUTPUT(E7_MS1_PIN); - SET_OUTPUT(E7_MS2_PIN); + SET_OUTPUT(E7_MS1_PIN); SET_OUTPUT(E7_MS2_PIN); #if PIN_EXISTS(E7_MS3) SET_OUTPUT(E7_MS3_PIN); #endif @@ -3524,13 +3539,13 @@ void Stepper::report_positions() { #if HAS_E7_MS_PINS case 10: WRITE(E7_MS1_PIN, ms1); break; #endif - #if HAS_I_MICROSTEPS + #if HAS_I_MS_PINS case 11: WRITE(I_MS1_PIN, ms1); break #endif - #if HAS_J_MICROSTEPS + #if HAS_J_MS_PINS case 12: WRITE(J_MS1_PIN, ms1); break #endif - #if HAS_K_MICROSTEPS + #if HAS_K_MS_PINS case 13: WRITE(K_MS1_PIN, ms1); break #endif } @@ -3595,13 +3610,13 @@ void Stepper::report_positions() { #if HAS_E7_MS_PINS case 10: WRITE(E7_MS2_PIN, ms2); break; #endif - #if HAS_I_M_PINS + #if HAS_I_MS_PINS case 11: WRITE(I_MS2_PIN, ms2); break #endif - #if HAS_J_M_PINS + #if HAS_J_MS_PINS case 12: WRITE(J_MS2_PIN, ms2); break #endif - #if HAS_K_M_PINS + #if HAS_K_MS_PINS case 13: WRITE(K_MS2_PIN, ms2); break #endif } diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index f170dd410458..99aa714ca095 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -317,6 +317,9 @@ class Stepper { #ifndef PWM_MOTOR_CURRENT #define PWM_MOTOR_CURRENT DEFAULT_PWM_MOTOR_CURRENT #endif + #ifndef MOTOR_CURRENT_PWM_FREQUENCY + #define MOTOR_CURRENT_PWM_FREQUENCY 31400 + #endif #define MOTOR_CURRENT_COUNT LINEAR_AXES #elif HAS_MOTOR_CURRENT_SPI static constexpr uint32_t digipot_count[] = DIGIPOT_MOTOR_CURRENT; @@ -457,11 +460,11 @@ class Stepper { // The stepper subsystem goes to sleep when it runs out of things to execute. // Call this to notify the subsystem that it is time to go to work. - static inline void wake_up() { ENABLE_STEPPER_DRIVER_INTERRUPT(); } + static void wake_up() { ENABLE_STEPPER_DRIVER_INTERRUPT(); } - static inline bool is_awake() { return STEPPER_ISR_ENABLED(); } + static bool is_awake() { return STEPPER_ISR_ENABLED(); } - static inline bool suspend() { + static bool suspend() { const bool awake = is_awake(); if (awake) DISABLE_STEPPER_DRIVER_INTERRUPT(); return awake; @@ -564,7 +567,7 @@ class Stepper { FORCE_INLINE static void set_z4_lock(const bool state) { locked_Z4_motor = state; } #endif #endif - static inline void set_all_z_lock(const bool lock, const int8_t except=-1) { + static void set_all_z_lock(const bool lock, const int8_t except=-1) { set_z1_lock(lock ^ (except == 0)); set_z2_lock(lock ^ (except == 1)); #if NUM_Z_STEPPER_DRIVERS >= 3 @@ -586,16 +589,16 @@ class Stepper { static axis_flags_t axis_enabled; // Axis stepper(s) ENABLED states - static inline bool axis_is_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { + static bool axis_is_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { return TEST(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex)); } - static inline void mark_axis_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { + static void mark_axis_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { SBI(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex)); } - static inline void mark_axis_disabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { + static void mark_axis_disabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { CBI(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex)); } - static inline bool can_axis_disable(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { + static bool can_axis_disable(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { return !any_enable_overlap() || !(axis_enabled.bits & enable_overlap[INDEX_OF_AXIS(axis, eindex)]); } @@ -608,10 +611,10 @@ class Stepper { static void enable_e_steppers(); static void disable_e_steppers(); #else - static inline void enable_extruder() {} - static inline bool disable_extruder() { return true; } - static inline void enable_e_steppers() {} - static inline void disable_e_steppers() {} + static void enable_extruder() {} + static bool disable_extruder() { return true; } + static void enable_e_steppers() {} + static void disable_e_steppers() {} #endif #define ENABLE_EXTRUDER(N) enable_extruder(E_TERN_(N)) diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 93b765d7a52e..7aea67753403 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -206,7 +206,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif // I Stepper -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #ifndef I_ENABLE_INIT #define I_ENABLE_INIT() SET_OUTPUT(I_ENABLE_PIN) #define I_ENABLE_WRITE(STATE) WRITE(I_ENABLE_PIN,STATE) @@ -225,7 +225,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif // J Stepper -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #ifndef J_ENABLE_INIT #define J_ENABLE_INIT() SET_OUTPUT(J_ENABLE_PIN) #define J_ENABLE_WRITE(STATE) WRITE(J_ENABLE_PIN,STATE) @@ -244,7 +244,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif // K Stepper -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #ifndef K_ENABLE_INIT #define K_ENABLE_INIT() SET_OUTPUT(K_ENABLE_PIN) #define K_ENABLE_WRITE(STATE) WRITE(K_ENABLE_PIN,STATE) @@ -895,21 +895,21 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Z_RESET() #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define ENABLE_AXIS_I() if (SHOULD_ENABLE(i)) { ENABLE_STEPPER_I(); AFTER_CHANGE(i, true); } #define DISABLE_AXIS_I() if (SHOULD_DISABLE(i)) { DISABLE_STEPPER_I(); AFTER_CHANGE(i, false); set_axis_untrusted(I_AXIS); } #else #define ENABLE_AXIS_I() NOOP #define DISABLE_AXIS_I() NOOP #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define ENABLE_AXIS_J() if (SHOULD_ENABLE(j)) { ENABLE_STEPPER_J(); AFTER_CHANGE(j, true); } #define DISABLE_AXIS_J() if (SHOULD_DISABLE(j)) { DISABLE_STEPPER_J(); AFTER_CHANGE(j, false); set_axis_untrusted(J_AXIS); } #else #define ENABLE_AXIS_J() NOOP #define DISABLE_AXIS_J() NOOP #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define ENABLE_AXIS_K() if (SHOULD_ENABLE(k)) { ENABLE_STEPPER_K(); AFTER_CHANGE(k, true); } #define DISABLE_AXIS_K() if (SHOULD_DISABLE(k)) { DISABLE_STEPPER_K(); AFTER_CHANGE(k, false); set_axis_untrusted(K_AXIS); } #else diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index e8ecbf1c762a..7baa2108f06a 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -38,7 +38,7 @@ enum StealthIndex : uint8_t { LOGICAL_AXIS_LIST(STEALTH_AXIS_E, STEALTH_AXIS_X, STEALTH_AXIS_Y, STEALTH_AXIS_Z, STEALTH_AXIS_I, STEALTH_AXIS_J, STEALTH_AXIS_K) }; -#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE) +#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE, ST##_HOLD_MULTIPLIER) // IC = TMC model number // ST = Stepper object letter @@ -200,7 +200,7 @@ enum StealthIndex : uint8_t { #if HAS_DRIVER(TMC2130) template - void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) { + void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) { st.begin(); CHOPCONF_t chopconf{0}; @@ -212,7 +212,7 @@ enum StealthIndex : uint8_t { TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true); st.CHOPCONF(chopconf.sr); - st.rms_current(mA, HOLD_MULTIPLIER); + st.rms_current(mA, hold_multiplier); st.microsteps(microsteps); st.iholddelay(10); st.TPOWERDOWN(128); // ~2s until driver lowers to hold current @@ -235,7 +235,7 @@ enum StealthIndex : uint8_t { #if HAS_DRIVER(TMC2160) template - void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) { + void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) { st.begin(); CHOPCONF_t chopconf{0}; @@ -247,7 +247,7 @@ enum StealthIndex : uint8_t { TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true); st.CHOPCONF(chopconf.sr); - st.rms_current(mA, HOLD_MULTIPLIER); + st.rms_current(mA, hold_multiplier); st.microsteps(microsteps); st.iholddelay(10); st.TPOWERDOWN(128); // ~2s until driver lowers to hold current @@ -604,7 +604,7 @@ enum StealthIndex : uint8_t { #if HAS_DRIVER(TMC2208) template - void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) { + void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) { TMC2208_n::GCONF_t gconf{0}; gconf.pdn_disable = true; // Use UART gconf.mstep_reg_select = true; // Select microsteps with UART @@ -622,7 +622,7 @@ enum StealthIndex : uint8_t { TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true); st.CHOPCONF(chopconf.sr); - st.rms_current(mA, HOLD_MULTIPLIER); + st.rms_current(mA, hold_multiplier); st.microsteps(microsteps); st.iholddelay(10); st.TPOWERDOWN(128); // ~2s until driver lowers to hold current @@ -646,7 +646,7 @@ enum StealthIndex : uint8_t { #if HAS_DRIVER(TMC2209) template - void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) { + void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) { TMC2208_n::GCONF_t gconf{0}; gconf.pdn_disable = true; // Use UART gconf.mstep_reg_select = true; // Select microsteps with UART @@ -664,7 +664,7 @@ enum StealthIndex : uint8_t { TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true); st.CHOPCONF(chopconf.sr); - st.rms_current(mA, HOLD_MULTIPLIER); + st.rms_current(mA, hold_multiplier); st.microsteps(microsteps); st.iholddelay(10); st.TPOWERDOWN(128); // ~2s until driver lowers to hold current @@ -688,7 +688,7 @@ enum StealthIndex : uint8_t { #if HAS_DRIVER(TMC2660) template - void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool, const chopper_timing_t &chop_init, const bool interpolate) { + void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) { st.begin(); TMC2660_n::CHOPCONF_t chopconf{0}; @@ -710,7 +710,7 @@ enum StealthIndex : uint8_t { #if HAS_DRIVER(TMC5130) template - void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) { + void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) { st.begin(); CHOPCONF_t chopconf{0}; @@ -722,7 +722,7 @@ enum StealthIndex : uint8_t { TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true); st.CHOPCONF(chopconf.sr); - st.rms_current(mA, HOLD_MULTIPLIER); + st.rms_current(mA, hold_multiplier); st.microsteps(microsteps); st.iholddelay(10); st.TPOWERDOWN(128); // ~2s until driver lowers to hold current @@ -745,7 +745,7 @@ enum StealthIndex : uint8_t { #if HAS_DRIVER(TMC5160) template - void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) { + void tmc_init(TMCMarlin &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) { st.begin(); CHOPCONF_t chopconf{0}; @@ -757,7 +757,7 @@ enum StealthIndex : uint8_t { TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true); st.CHOPCONF(chopconf.sr); - st.rms_current(mA, HOLD_MULTIPLIER); + st.rms_current(mA, hold_multiplier); st.microsteps(microsteps); st.iholddelay(10); st.TPOWERDOWN(128); // ~2s until driver lowers to hold current diff --git a/Marlin/src/module/stepper/trinamic.h b/Marlin/src/module/stepper/trinamic.h index 0a956a70b360..dd3a64240f20 100644 --- a/Marlin/src/module/stepper/trinamic.h +++ b/Marlin/src/module/stepper/trinamic.h @@ -74,12 +74,6 @@ #define TMC_CLASS_E(N) TMC_CLASS(E##N, E) #endif -typedef struct { - uint8_t toff; - int8_t hend; - uint8_t hstrt; -} chopper_timing_t; - #ifndef CHOPPER_TIMING_X #define CHOPPER_TIMING_X CHOPPER_TIMING #endif @@ -89,13 +83,13 @@ typedef struct { #if HAS_Z_AXIS && !defined(CHOPPER_TIMING_Z) #define CHOPPER_TIMING_Z CHOPPER_TIMING #endif -#if LINEAR_AXES >= 4 && !defined(CHOPPER_TIMING_I) +#if HAS_I_AXIS && !defined(CHOPPER_TIMING_I) #define CHOPPER_TIMING_I CHOPPER_TIMING #endif -#if LINEAR_AXES >= 5 && !defined(CHOPPER_TIMING_J) +#if HAS_J_AXIS && !defined(CHOPPER_TIMING_J) #define CHOPPER_TIMING_J CHOPPER_TIMING #endif -#if LINEAR_AXES >= 6 && !defined(CHOPPER_TIMING_K) +#if HAS_K_AXIS && !defined(CHOPPER_TIMING_K) #define CHOPPER_TIMING_K CHOPPER_TIMING #endif #if HAS_EXTRUDERS && !defined(CHOPPER_TIMING_E) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 48941532c8a0..a983275b8aff 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -41,14 +41,18 @@ #include "../feature/spindle_laser.h" #endif +#if ENABLED(USE_CONTROLLER_FAN) + #include "../feature/controllerfan.h" +#endif + #if ENABLED(EMERGENCY_PARSER) #include "motion.h" #endif #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -63,6 +67,10 @@ #include "../gcode/gcode.h" #endif +#if ENABLED(NOZZLE_PARK_FEATURE) + #include "../libs/nozzle.h" +#endif + // MAX TC related macros #define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_MAX##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX##M) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) #define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) @@ -188,6 +196,7 @@ Temperature thermalManager; PGMSTR(str_t_thermal_runaway, STR_T_THERMAL_RUNAWAY); +PGMSTR(str_t_temp_malfunction, STR_T_MALFUNCTION); PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); /** @@ -210,8 +219,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #else #define _COOLER_FSTR(h) #endif -#define _E_FSTR(h,N) ((HOTENDS) > N && (h) == N) ? F(LCD_STR_E##N) : -#define HEATER_FSTR(h) _BED_FSTR(h) _CHAMBER_FSTR(h) _COOLER_FSTR(h) _E_FSTR(h,1) _E_FSTR(h,2) _E_FSTR(h,3) _E_FSTR(h,4) _E_FSTR(h,5) F(LCD_STR_E0) +#define _E_FSTR(h,N) ((HOTENDS) > N && (h) == N) ? F(STR_E##N) : +#define HEATER_FSTR(h) _BED_FSTR(h) _CHAMBER_FSTR(h) _COOLER_FSTR(h) _E_FSTR(h,1) _E_FSTR(h,2) _E_FSTR(h,3) _E_FSTR(h,4) _E_FSTR(h,5) _E_FSTR(h,6) _E_FSTR(h,7) F(STR_E0) // // Initialize MAX TC objects/SPI @@ -290,7 +299,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); redundant_info_t Temperature::temp_redundant; #endif -#if ENABLED(AUTO_POWER_E_FANS) +#if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK) uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 } #endif @@ -302,6 +311,10 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); uint8_t Temperature::coolerfan_speed; // = 0 #endif +#if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN) + uint8_t Temperature::soft_pwm_controller_speed; +#endif + // Init fans according to whether they're native PWM or Software PWM #ifdef BOARD_OPENDRAIN_MOSFETS #define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH) @@ -314,7 +327,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #define _INIT_FAN_PIN(P) do{ if (PWM_PIN(P)) SET_PWM(P); else _INIT_SOFT_FAN(P); }while(0) #endif #if ENABLED(FAST_PWM_FAN) - #define SET_FAST_PWM_FREQ(P) set_pwm_frequency(P, FAST_PWM_FAN_FREQUENCY) + #define SET_FAST_PWM_FREQ(P) hal.set_pwm_frequency(pin_t(P), FAST_PWM_FAN_FREQUENCY) #else #define SET_FAST_PWM_FREQ(P) NOOP #endif @@ -424,8 +437,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_HEATED_BED bed_info_t Temperature::temp_bed; // = { 0 } // Init min and max temp with extreme values to prevent false errors during startup - int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, - Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, + Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); #endif @@ -435,8 +448,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_HEATED_CHAMBER millis_t next_cool_check_ms_2 = 0; celsius_float_t old_temp = 9999; - int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, - Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, + Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0}); IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms); #endif @@ -448,8 +461,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); bool flag_cooler_state; //bool flag_cooler_excess = false; celsius_float_t previous_temp = 9999; - int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, - Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, + Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; #if WATCH_COOLER cooler_watch_t Temperature::watch_cooler{0}; #endif @@ -464,8 +477,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_TEMP_BOARD board_info_t Temperature::temp_board; // = { 0 } #if ENABLED(THERMAL_PROTECTION_BOARD) - int16_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, - Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, + Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; #endif #endif @@ -495,6 +508,7 @@ volatile bool Temperature::raw_temps_ready = false; #endif #define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1) +#define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) #if HAS_HOTEND // Init mintemp and maxtemp with extreme values to prevent false errors during startup @@ -518,8 +532,9 @@ volatile bool Temperature::raw_temps_ready = false; millis_t Temperature::preheat_end_time[HOTENDS] = { 0 }; #endif -#if HAS_AUTO_FAN - millis_t Temperature::next_auto_fan_check_ms = 0; +#if HAS_FAN_LOGIC + constexpr millis_t Temperature::fan_update_interval_ms; + millis_t Temperature::fan_update_ms = 0; #endif #if ENABLED(FAN_SOFT_PWM) @@ -584,7 +599,7 @@ volatile bool Temperature::raw_temps_ready = false; #define ONHEATINGSTART() C_TERN(ischamber, printerEventLEDs.onChamberHeatingStart(), B_TERN(isbed, printerEventLEDs.onBedHeatingStart(), printerEventLEDs.onHotendHeatingStart())) #define ONHEATING(S,C,T) C_TERN(ischamber, printerEventLEDs.onChamberHeating(S,C,T), B_TERN(isbed, printerEventLEDs.onBedHeating(S,C,T), printerEventLEDs.onHotendHeating(S,C,T))) - #define WATCH_PID BOTH(WATCH_CHAMBER, PIDTEMPCHAMBER) || BOTH(WATCH_BED, PIDTEMPBED) || BOTH(WATCH_HOTENDS, PIDTEMP) + #define WATCH_PID DISABLED(NO_WATCH_PID_TUNING) && (BOTH(WATCH_CHAMBER, PIDTEMPCHAMBER) || BOTH(WATCH_BED, PIDTEMPBED) || BOTH(WATCH_HOTENDS, PIDTEMP)) #if WATCH_PID #if BOTH(THERMAL_PROTECTION_CHAMBER, PIDTEMPCHAMBER) @@ -606,15 +621,16 @@ volatile bool Temperature::raw_temps_ready = false; bool heated = false; #endif - TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL); + TERN_(HAS_FAN_LOGIC, fan_update_ms = next_temp_ms + fan_update_interval_ms); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); return; } @@ -651,12 +667,7 @@ volatile bool Temperature::raw_temps_ready = false; ONHEATING(start_temp, current_temp, target); #endif - #if HAS_AUTO_FAN - if (ELAPSED(ms, next_auto_fan_check_ms)) { - checkExtruderAutoFans(); - next_auto_fan_check_ms = ms + 2500UL; - } - #endif + TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); if (heating && current_temp > target && ELAPSED(ms, t2 + 5000UL)) { heating = false; @@ -680,8 +691,8 @@ volatile bool Temperature::raw_temps_ready = false; if (cycles > 2) { const float Ku = (4.0f * d) / (float(M_PI) * (maxT - minT) * 0.5f), Tu = float(t_low + t_high) * 0.001f, - pf = ischamber ? 0.2f : (isbed ? 0.2f : 0.6f), - df = ischamber ? 1.0f / 3.0f : (isbed ? 1.0f / 3.0f : 1.0f / 8.0f); + pf = (ischamber || isbed) ? 0.2f : 0.6f, + df = (ischamber || isbed) ? 1.0f / 3.0f : 1.0f / 8.0f; tune_pid.Kp = Ku * pf; tune_pid.Ki = tune_pid.Kp * 2.0f / Tu; @@ -709,7 +720,8 @@ volatile bool Temperature::raw_temps_ready = false; if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) { SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); break; } @@ -727,7 +739,7 @@ volatile bool Temperature::raw_temps_ready = false; if (!heated) { // If not yet reached target... if (current_temp > next_watch_temp) { // Over the watch temp? next_watch_temp = current_temp + watch_temp_increase; // - set the next temp to watch for - temp_change_ms = ms + SEC_TO_MS(watch_temp_period); // - move the expiration timer up + temp_change_ms = ms + SEC_TO_MS(watch_temp_period); // - move the expiration timer up if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached } else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired @@ -745,14 +757,16 @@ volatile bool Temperature::raw_temps_ready = false; #endif if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) { TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TUNING_TIMEOUT)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT))); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); break; } if (cycles > ncycles && cycles > 2) { SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE))); #if EITHER(PIDTEMPBED, PIDTEMPCHAMBER) FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR)); @@ -799,16 +813,16 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); goto EXIT_M303; } // Run HAL idle tasks - TERN_(HAL_IDLETASK, HAL_idletask()); + hal.idletask(); // Run UI update - TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update()); + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); } wait_for_heatup = false; @@ -817,7 +831,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); EXIT_M303: TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true); @@ -845,6 +859,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #define _EFANOVERLAP(A,B) _FANOVERLAP(E##A,B) #if HAS_AUTO_FAN + #if EXTRUDER_AUTO_FAN_SPEED != 255 #define INIT_E_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) #else @@ -856,9 +871,11 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #define INIT_CHAMBER_AUTO_FAN_PIN(P) SET_OUTPUT(P) #endif - #define CHAMBER_FAN_INDEX HOTENDS + #ifndef CHAMBER_FAN_INDEX + #define CHAMBER_FAN_INDEX HOTENDS + #endif - void Temperature::checkExtruderAutoFans() { + void Temperature::update_autofans() { #define _EFAN(B,A) _EFANOVERLAP(A,B) ? B : static const uint8_t fanBit[] PROGMEM = { 0 @@ -873,9 +890,11 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { }; uint8_t fanState = 0; - HOTEND_LOOP() - if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE) + HOTEND_LOOP() { + if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE) { SBI(fanState, pgm_read_byte(&fanBit[e])); + } + } #if HAS_AUTO_CHAMBER_FAN if (temp_chamber.celsius >= CHAMBER_AUTO_FAN_TEMPERATURE) @@ -889,7 +908,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #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); \ + hal.set_pwm_duty(pin_t(P##_AUTO_FAN_PIN), D ? A : 0); \ else \ WRITE(P##_AUTO_FAN_PIN, D); \ }while(0) @@ -906,36 +925,43 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { break; #endif default: - #if ENABLED(AUTO_POWER_E_FANS) + #if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK) autofan_speed[realFan] = fan_on ? EXTRUDER_AUTO_FAN_SPEED : 0; #endif break; } + #if BOTH(HAS_FANCHECK, HAS_PWMFANCHECK) + #define _AUTOFAN_SPEED() fan_check.is_measuring() ? 255 : EXTRUDER_AUTO_FAN_SPEED + #else + #define _AUTOFAN_SPEED() EXTRUDER_AUTO_FAN_SPEED + #endif + #define _AUTOFAN_CASE(N) case N: _UPDATE_AUTO_FAN(E##N, fan_on, _AUTOFAN_SPEED()); break + switch (f) { #if HAS_AUTO_FAN_0 - case 0: _UPDATE_AUTO_FAN(E0, fan_on, EXTRUDER_AUTO_FAN_SPEED); break; + _AUTOFAN_CASE(0); #endif #if HAS_AUTO_FAN_1 - case 1: _UPDATE_AUTO_FAN(E1, fan_on, EXTRUDER_AUTO_FAN_SPEED); break; + _AUTOFAN_CASE(1); #endif #if HAS_AUTO_FAN_2 - case 2: _UPDATE_AUTO_FAN(E2, fan_on, EXTRUDER_AUTO_FAN_SPEED); break; + _AUTOFAN_CASE(2); #endif #if HAS_AUTO_FAN_3 - case 3: _UPDATE_AUTO_FAN(E3, fan_on, EXTRUDER_AUTO_FAN_SPEED); break; + _AUTOFAN_CASE(3); #endif #if HAS_AUTO_FAN_4 - case 4: _UPDATE_AUTO_FAN(E4, fan_on, EXTRUDER_AUTO_FAN_SPEED); break; + _AUTOFAN_CASE(4); #endif #if HAS_AUTO_FAN_5 - case 5: _UPDATE_AUTO_FAN(E5, fan_on, EXTRUDER_AUTO_FAN_SPEED); break; + _AUTOFAN_CASE(5); #endif #if HAS_AUTO_FAN_6 - case 6: _UPDATE_AUTO_FAN(E6, fan_on, EXTRUDER_AUTO_FAN_SPEED); break; + _AUTOFAN_CASE(6); #endif #if HAS_AUTO_FAN_7 - case 7: _UPDATE_AUTO_FAN(E7, fan_on, EXTRUDER_AUTO_FAN_SPEED); break; + _AUTOFAN_CASE(7); #endif #if HAS_AUTO_CHAMBER_FAN && !AUTO_CHAMBER_IS_E case CHAMBER_FAN_INDEX: _UPDATE_AUTO_FAN(CHAMBER, fan_on, CHAMBER_AUTO_FAN_SPEED); break; @@ -953,8 +979,8 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) { marlin_state = MF_KILLED; + thermalManager.disable_all_heaters(); #if USE_BEEPER - thermalManager.disable_all_heaters(); for (uint8_t i = 20; i--;) { WRITE(BEEPER_PIN, HIGH); delay(25); @@ -967,6 +993,12 @@ inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) { } WRITE(BEEPER_PIN, HIGH); #endif + #if ENABLED(NOZZLE_PARK_FEATURE) + if (!homing_needed_error()) { + nozzle.park(0); + planner.synchronize(); + } + #endif kill(lcd_msg, HEATER_FSTR(heater_id)); } @@ -1317,6 +1349,8 @@ void Temperature::manage_heater() { if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT); if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT); #endif + #else + #warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!" #endif millis_t ms = millis(); @@ -1359,20 +1393,14 @@ void Temperature::manage_heater() { _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), F(STR_REDUNDANCY), GET_TEXT_F(MSG_ERR_REDUNDANT_TEMP)); #endif - #if HAS_AUTO_FAN - if (ELAPSED(ms, next_auto_fan_check_ms)) { // only need to check fan state very infrequently - checkExtruderAutoFans(); - next_auto_fan_check_ms = ms + 2500UL; - } - #endif + // Manage extruder auto fans and/or read fan tachometers + TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); - #if ENABLED(FILAMENT_WIDTH_SENSOR) - /** - * Dynamically set the volumetric multiplier based - * on the delayed Filament Width measurement. - */ - filwidth.update_volumetric(); - #endif + /** + * Dynamically set the volumetric multiplier based + * on the delayed Filament Width measurement. + */ + TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_volumetric()); #if HAS_HEATED_BED @@ -1412,7 +1440,7 @@ void Temperature::manage_heater() { TERN_(HEATER_IDLE_HANDLER, heater_idle[IDLE_INDEX_BED].update(ms)); - #if HAS_THERMALLY_PROTECTED_BED + #if ENABLED(THERMAL_PROTECTION_BED) tr_state_machine[RUNAWAY_IND_BED].run(temp_bed.celsius, temp_bed.target, H_BED, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS); #endif @@ -1662,8 +1690,8 @@ void Temperature::manage_heater() { m = (l + r) >> 1; \ if (!m) return celsius_t(pgm_read_word(&TBL[0].celsius)); \ if (m == l || m == r) return celsius_t(pgm_read_word(&TBL[LEN-1].celsius)); \ - int16_t v00 = pgm_read_word(&TBL[m-1].value), \ - v10 = pgm_read_word(&TBL[m-0].value); \ + raw_adc_t v00 = pgm_read_word(&TBL[m-1].value), \ + v10 = pgm_read_word(&TBL[m-0].value); \ if (raw < v00) r = m; \ else if (raw > v10) l = m; \ else { \ @@ -1757,7 +1785,7 @@ void Temperature::manage_heater() { SERIAL_EOL(); } - celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw) { + celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const raw_adc_t raw) { if (!WITHIN(t_index, 0, COUNT(user_thermistor) - 1)) return 25; @@ -1772,8 +1800,8 @@ void Temperature::manage_heater() { } // maximum adc value .. take into account the over sampling - const int adc_max = MAX_RAW_THERMISTOR_VALUE, - adc_raw = constrain(raw, 1, adc_max - 1); // constrain to prevent divide-by-zero + constexpr raw_adc_t adc_max = MAX_RAW_THERMISTOR_VALUE; + const raw_adc_t adc_raw = constrain(raw, 1, adc_max - 1); // constrain to prevent divide-by-zero const float adc_inverse = (adc_max - adc_raw) - 0.5f, resistance = t.series_res * (adc_raw + 0.5f) / adc_inverse, @@ -1793,7 +1821,7 @@ void Temperature::manage_heater() { #if HAS_HOTEND // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. - celsius_float_t Temperature::analog_to_celsius_hotend(const int16_t raw, const uint8_t e) { + celsius_float_t Temperature::analog_to_celsius_hotend(const raw_adc_t raw, const uint8_t e) { if (e >= HOTENDS) { SERIAL_ERROR_START(); SERIAL_ECHO(e); @@ -1809,11 +1837,11 @@ void Temperature::manage_heater() { #elif TEMP_SENSOR_0_IS_MAX_TC #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, - max31865_0.temperature((uint16_t)raw), + max31865_0.temperature(raw), max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) ); #else - return raw * 0.25; + return (int16_t)raw * 0.25; #endif #elif TEMP_SENSOR_0_IS_AD595 return TEMP_AD595(raw); @@ -1828,11 +1856,11 @@ void Temperature::manage_heater() { #elif TEMP_SENSOR_1_IS_MAX_TC #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, - max31865_1.temperature((uint16_t)raw), + max31865_1.temperature(raw), max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) ); #else - return raw * 0.25; + return (int16_t)raw * 0.25; #endif #elif TEMP_SENSOR_1_IS_AD595 return TEMP_AD595(raw); @@ -1916,7 +1944,7 @@ void Temperature::manage_heater() { #if HAS_HEATED_BED // For bed temperature measurement. - celsius_float_t Temperature::analog_to_celsius_bed(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_bed(const raw_adc_t raw) { #if TEMP_SENSOR_BED_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BED, raw); #elif TEMP_SENSOR_BED_IS_THERMISTOR @@ -1934,7 +1962,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_CHAMBER // For chamber temperature measurement. - celsius_float_t Temperature::analog_to_celsius_chamber(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_chamber(const raw_adc_t raw) { #if TEMP_SENSOR_CHAMBER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_CHAMBER, raw); #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR @@ -1952,7 +1980,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_COOLER // For cooler temperature measurement. - celsius_float_t Temperature::analog_to_celsius_cooler(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_cooler(const raw_adc_t raw) { #if TEMP_SENSOR_COOLER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_COOLER, raw); #elif TEMP_SENSOR_COOLER_IS_THERMISTOR @@ -1970,7 +1998,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_PROBE // For probe temperature measurement. - celsius_float_t Temperature::analog_to_celsius_probe(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_probe(const raw_adc_t raw) { #if TEMP_SENSOR_PROBE_IS_CUSTOM return user_thermistor_to_deg_c(CTI_PROBE, raw); #elif TEMP_SENSOR_PROBE_IS_THERMISTOR @@ -1988,7 +2016,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_BOARD // For motherboard temperature measurement. - celsius_float_t Temperature::analog_to_celsius_board(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_board(const raw_adc_t raw) { #if TEMP_SENSOR_BOARD_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BOARD, raw); #elif TEMP_SENSOR_BOARD_IS_THERMISTOR @@ -2006,13 +2034,13 @@ void Temperature::manage_heater() { #if HAS_TEMP_REDUNDANT // For redundant temperature measurement. - celsius_float_t Temperature::analog_to_celsius_redundant(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_redundant(const raw_adc_t raw) { #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM return user_thermistor_to_deg_c(CTI_REDUNDANT, raw); #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) - return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature((uint16_t)raw), raw * 0.25); + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) - return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature((uint16_t)raw), raw * 0.25); + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN); #elif TEMP_SENSOR_REDUNDANT_IS_AD595 @@ -2042,20 +2070,20 @@ void Temperature::updateTemperaturesFromRawValues() { watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt - TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0)); - TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1)); - TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE))); + TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].setraw(READ_MAX_TC(0))); + TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].setraw(READ_MAX_TC(1))); + TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE)))); #if HAS_HOTEND - HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); + HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].getraw(), e); #endif - TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw)); - TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw)); - TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.raw)); - TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw)); - TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.raw)); - TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.raw)); + TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.getraw())); + TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.getraw())); + TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.getraw())); + TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.getraw())); + TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.getraw())); + TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.getraw())); TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); @@ -2081,46 +2109,45 @@ void Temperature::updateTemperaturesFromRawValues() { }; LOOP_L_N(e, COUNT(temp_dir)) { - const int8_t tdir = temp_dir[e]; - if (tdir) { - const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp - if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e); - - const bool heater_on = temp_hotend[e].target > 0; - if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) { - #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 - if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) - #endif - min_temp_error((heater_id_t)e); - } + const raw_adc_t r = temp_hotend[e].getraw(); + const bool neg = temp_dir[e] < 0, pos = temp_dir[e] > 0; + if ((neg && r < temp_range[e].raw_max) || (pos && r > temp_range[e].raw_max)) + max_temp_error((heater_id_t)e); + + const bool heater_on = temp_hotend[e].target > 0; + if (heater_on && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) { #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 - else - consecutive_low_temperature_error[e] = 0; + if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) #endif + min_temp_error((heater_id_t)e); } + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 + else + consecutive_low_temperature_error[e] = 0; + #endif } #endif // HAS_HOTEND #define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) #if ENABLED(THERMAL_PROTECTION_BED) - if (TP_CMP(BED, temp_bed.raw, maxtemp_raw_BED)) max_temp_error(H_BED); - if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED); + if (TP_CMP(BED, temp_bed.getraw(), maxtemp_raw_BED)) max_temp_error(H_BED); + if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) min_temp_error(H_BED); #endif #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) - if (TP_CMP(CHAMBER, temp_chamber.raw, maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); - if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.raw)) min_temp_error(H_CHAMBER); + if (TP_CMP(CHAMBER, temp_chamber.getraw(), maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); + if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw())) min_temp_error(H_CHAMBER); #endif #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) - if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.raw, maxtemp_raw_COOLER)) max_temp_error(H_COOLER); - if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.raw)) min_temp_error(H_COOLER); + if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), maxtemp_raw_COOLER)) max_temp_error(H_COOLER); + if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.getraw())) min_temp_error(H_COOLER); #endif #if BOTH(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) - if (TP_CMP(BOARD, temp_board.raw, maxtemp_raw_BOARD)) max_temp_error(H_BOARD); - if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.raw)) min_temp_error(H_BOARD); + if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) max_temp_error(H_BOARD); + if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) min_temp_error(H_BOARD); #endif #undef TP_CMP @@ -2172,11 +2199,8 @@ void Temperature::init() { #elif TEMP_SENSOR_IS_MAX(0, 31865) max31865_0.begin( MAX31865_WIRES(MAX31865_SENSOR_WIRES_0) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) + OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0, MAX31865_WIRE_OHMS_0) ); - #if defined(LIB_INTERNAL_MAX31865) && ENABLED(MAX31865_50HZ_FILTER) - max31865_0.enable50HzFilter(1); - #endif #endif #if TEMP_SENSOR_IS_MAX(1, 6675) && HAS_MAX6675_LIBRARY @@ -2186,11 +2210,8 @@ void Temperature::init() { #elif TEMP_SENSOR_IS_MAX(1, 31865) max31865_1.begin( MAX31865_WIRES(MAX31865_SENSOR_WIRES_1) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) + OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1, MAX31865_WIRE_OHMS_1) ); - #if defined(LIB_INTERNAL_MAX31865) && ENABLED(MAX31865_50HZ_FILTER) - max31865_1.enable50HzFilter(1); - #endif #endif #undef MAX31865_WIRES #undef _MAX31865_WIRES @@ -2300,76 +2321,35 @@ void Temperature::init() { TERN_(HAS_MAXTC_SW_SPI, max_tc_spi.init()); - HAL_adc_init(); + hal.adc_init(); + + TERN_(HAS_TEMP_ADC_0, hal.adc_enable(TEMP_0_PIN)); + TERN_(HAS_TEMP_ADC_1, hal.adc_enable(TEMP_1_PIN)); + TERN_(HAS_TEMP_ADC_2, hal.adc_enable(TEMP_2_PIN)); + TERN_(HAS_TEMP_ADC_3, hal.adc_enable(TEMP_3_PIN)); + TERN_(HAS_TEMP_ADC_4, hal.adc_enable(TEMP_4_PIN)); + TERN_(HAS_TEMP_ADC_5, hal.adc_enable(TEMP_5_PIN)); + TERN_(HAS_TEMP_ADC_6, hal.adc_enable(TEMP_6_PIN)); + TERN_(HAS_TEMP_ADC_7, hal.adc_enable(TEMP_7_PIN)); + TERN_(HAS_JOY_ADC_X, hal.adc_enable(JOY_X_PIN)); + TERN_(HAS_JOY_ADC_Y, hal.adc_enable(JOY_Y_PIN)); + TERN_(HAS_JOY_ADC_Z, hal.adc_enable(JOY_Z_PIN)); + TERN_(HAS_TEMP_ADC_BED, hal.adc_enable(TEMP_BED_PIN)); + TERN_(HAS_TEMP_ADC_CHAMBER, hal.adc_enable(TEMP_CHAMBER_PIN)); + TERN_(HAS_TEMP_ADC_PROBE, hal.adc_enable(TEMP_PROBE_PIN)); + TERN_(HAS_TEMP_ADC_COOLER, hal.adc_enable(TEMP_COOLER_PIN)); + TERN_(HAS_TEMP_ADC_BOARD, hal.adc_enable(TEMP_BOARD_PIN)); + TERN_(HAS_TEMP_ADC_REDUNDANT, hal.adc_enable(TEMP_REDUNDANT_PIN)); + TERN_(FILAMENT_WIDTH_SENSOR, hal.adc_enable(FILWIDTH_PIN)); + TERN_(HAS_ADC_BUTTONS, hal.adc_enable(ADC_KEYPAD_PIN)); + TERN_(POWER_MONITOR_CURRENT, hal.adc_enable(POWER_MONITOR_CURRENT_PIN)); + TERN_(POWER_MONITOR_VOLTAGE, hal.adc_enable(POWER_MONITOR_VOLTAGE_PIN)); - #if HAS_TEMP_ADC_0 - HAL_ANALOG_SELECT(TEMP_0_PIN); - #endif - #if HAS_TEMP_ADC_1 - HAL_ANALOG_SELECT(TEMP_1_PIN); - #endif - #if HAS_TEMP_ADC_2 - HAL_ANALOG_SELECT(TEMP_2_PIN); - #endif - #if HAS_TEMP_ADC_3 - HAL_ANALOG_SELECT(TEMP_3_PIN); - #endif - #if HAS_TEMP_ADC_4 - HAL_ANALOG_SELECT(TEMP_4_PIN); - #endif - #if HAS_TEMP_ADC_5 - HAL_ANALOG_SELECT(TEMP_5_PIN); - #endif - #if HAS_TEMP_ADC_6 - HAL_ANALOG_SELECT(TEMP_6_PIN); - #endif - #if HAS_TEMP_ADC_7 - HAL_ANALOG_SELECT(TEMP_7_PIN); - #endif - #if HAS_JOY_ADC_X - HAL_ANALOG_SELECT(JOY_X_PIN); - #endif - #if HAS_JOY_ADC_Y - HAL_ANALOG_SELECT(JOY_Y_PIN); - #endif - #if HAS_JOY_ADC_Z - HAL_ANALOG_SELECT(JOY_Z_PIN); - #endif #if HAS_JOY_ADC_EN SET_INPUT_PULLUP(JOY_EN_PIN); #endif - #if HAS_TEMP_ADC_BED - HAL_ANALOG_SELECT(TEMP_BED_PIN); - #endif - #if HAS_TEMP_ADC_CHAMBER - HAL_ANALOG_SELECT(TEMP_CHAMBER_PIN); - #endif - #if HAS_TEMP_ADC_COOLER - HAL_ANALOG_SELECT(TEMP_COOLER_PIN); - #endif - #if HAS_TEMP_ADC_PROBE - HAL_ANALOG_SELECT(TEMP_PROBE_PIN); - #endif - #if HAS_TEMP_ADC_BOARD - HAL_ANALOG_SELECT(TEMP_BOARD_PIN); - #endif - #if HAS_TEMP_ADC_REDUNDANT - HAL_ANALOG_SELECT(TEMP_REDUNDANT_PIN); - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - HAL_ANALOG_SELECT(FILWIDTH_PIN); - #endif - #if HAS_ADC_BUTTONS - HAL_ANALOG_SELECT(ADC_KEYPAD_PIN); - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - HAL_ANALOG_SELECT(POWER_MONITOR_CURRENT_PIN); - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - HAL_ANALOG_SELECT(POWER_MONITOR_VOLTAGE_PIN); - #endif - HAL_timer_start(TEMP_TIMER_NUM, TEMP_TIMER_FREQUENCY); + HAL_timer_start(MF_TIMER_TEMP, TEMP_TIMER_FREQUENCY); ENABLE_TEMPERATURE_INTERRUPT(); #if HAS_AUTO_FAN_0 @@ -2544,19 +2524,29 @@ void Temperature::init() { ); */ - #if HEATER_IDLE_HANDLER + #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) + if (state == TRMalfunction) { // temperature invariance may continue, regardless of heater state + variance += ABS(current - last_temp); // no need for detection window now, a single change in variance is enough + last_temp = current; + if (!NEAR_ZERO(variance)) { + variance_timer = millis() + SEC_TO_MS(period_seconds); + variance = 0.0; + state = TRStable; // resume from where we detected the problem + } + } + #endif + + if (TERN1(THERMAL_PROTECTION_VARIANCE_MONITOR, state != TRMalfunction)) { // If the heater idle timeout expires, restart - if (heater_idle[idle_index].timed_out) { + if (TERN0(HEATER_IDLE_HANDLER, heater_idle[idle_index].timed_out)) { state = TRInactive; running_temp = 0; + TERN_(THERMAL_PROTECTION_VARIANCE_MONITOR, variance_timer = 0); } - else - #endif - { - // If the target temperature changes, restart - if (running_temp != target) { + else if (running_temp != target) { // If the target temperature changes, restart running_temp = target; state = target > 0 ? TRFirstHeating : TRInactive; + TERN_(THERMAL_PROTECTION_VARIANCE_MONITOR, variance_timer = 0); } } @@ -2570,7 +2560,7 @@ void Temperature::init() { state = TRStable; // While the temperature is stable watch for a bad temperature - case TRStable: + case TRStable: { #if ENABLED(ADAPTIVE_FAN_SLOWING) if (adaptive_fan_slowing && heater_id >= 0) { @@ -2588,16 +2578,42 @@ void Temperature::init() { } #endif + const millis_t now = millis(); + + #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) + if (PENDING(now, variance_timer)) { + variance += ABS(current - last_temp); + last_temp = current; + } + else { + if (NEAR_ZERO(variance) && variance_timer) { // valid variance monitoring window + state = TRMalfunction; + break; + } + variance_timer = now + SEC_TO_MS(period_seconds); + variance = 0.0; + last_temp = current; + } + #endif + if (current >= running_temp - hysteresis_degc) { - timer = millis() + SEC_TO_MS(period_seconds); + timer = now + SEC_TO_MS(period_seconds); break; } - else if (PENDING(millis(), timer)) break; + else if (PENDING(now, timer)) break; state = TRRunaway; + } // fall through + case TRRunaway: TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); _temp_error(heater_id, FPSTR(str_t_thermal_runaway), GET_TEXT_F(MSG_THERMAL_RUNAWAY)); + + #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) + case TRMalfunction: + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); + _temp_error(heater_id, FPSTR(str_t_temp_malfunction), GET_TEXT_F(MSG_TEMP_MALFUNCTION)); + #endif } } @@ -2715,7 +2731,7 @@ void Temperature::disable_all_heaters() { * @param hindex the hotend we're referencing (if MULTI_MAX_TC) * @return integer representing the board's buffer, to be converted later if needed */ - int16_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { + raw_adc_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { #define MAXTC_HEAT_INTERVAL 250UL #if HAS_MAX31855 @@ -2734,7 +2750,7 @@ void Temperature::disable_all_heaters() { #if HAS_MULTI_MAX_TC // Needed to return the correct temp when this is called between readings - static int16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; + static raw_adc_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; #define THERMO_TEMP(I) max_tc_temp_previous[I] #define THERMO_SEL(A,B) (hindex ? (B) : (A)) #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) @@ -2763,7 +2779,7 @@ void Temperature::disable_all_heaters() { // Return last-read value between readings millis_t ms = millis(); if (PENDING(ms, next_max_tc_ms[hindex])) - return (int16_t)THERMO_TEMP(hindex); + return THERMO_TEMP(hindex); next_max_tc_ms[hindex] = ms + MAXTC_HEAT_INTERVAL; @@ -2860,7 +2876,7 @@ void Temperature::disable_all_heaters() { THERMO_TEMP(hindex) = max_tc_temp; - return (int16_t)max_tc_temp; + return max_tc_temp; } #endif // HAS_MAX_TC @@ -2895,8 +2911,8 @@ void Temperature::update_raw_temperatures() { TERN_(HAS_TEMP_ADC_BED, temp_bed.update()); TERN_(HAS_TEMP_ADC_CHAMBER, temp_chamber.update()); TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); - TERN_(HAS_TEMP_ADC_BOARD, temp_board.update()); TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); + TERN_(HAS_TEMP_ADC_BOARD, temp_board.update()); TERN_(HAS_JOY_ADC_X, joystick.x.update()); TERN_(HAS_JOY_ADC_Y, joystick.y.update()); @@ -2950,11 +2966,11 @@ void Temperature::readings_ready() { * - Call planner.isr to count down its "ignore" time */ HAL_TEMP_TIMER_ISR() { - HAL_timer_isr_prologue(TEMP_TIMER_NUM); + HAL_timer_isr_prologue(MF_TIMER_TEMP); Temperature::isr(); - HAL_timer_isr_epilogue(TEMP_TIMER_NUM); + HAL_timer_isr_epilogue(MF_TIMER_TEMP); } #if ENABLED(SLOW_PWM_HEATERS) && !defined(MIN_STATE_TIME) @@ -2983,8 +2999,8 @@ class SoftPWM { }; /** - * Handle various ~1KHz tasks associated with temperature - * - Heater PWM (~1KHz with scaler) + * Handle various ~1kHz tasks associated with temperature + * - Heater PWM (~1kHz with scaler) * - LCD Button polling (~500Hz) * - Start / Read one ADC sensor * - Advance Babysteps @@ -3001,7 +3017,7 @@ void Temperature::isr() { uint8_t pwm_count_tmp = pwm_count; #if HAS_ADC_BUTTONS - static unsigned int raw_ADCKey_value = 0; + static raw_adc_t raw_ADCKey_value = 0; static bool ADCKey_pressed = false; #endif @@ -3021,6 +3037,10 @@ void Temperature::isr() { static SoftPWM soft_pwm_cooler; #endif + #if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN) + static SoftPWM soft_pwm_controller; + #endif + #define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ FAN_INVERTING) #if DISABLED(SLOW_PWM_HEATERS) @@ -3056,6 +3076,10 @@ void Temperature::isr() { _PWM_MOD(COOLER, soft_pwm_cooler, temp_cooler); #endif + #if BOTH(USE_CONTROLLER_FAN, FAN_SOFT_PWM) + WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed)); + #endif + #if ENABLED(FAN_SOFT_PWM) #define _FAN_PWM(N) do{ \ uint8_t &spcf = soft_pwm_count_fan[N]; \ @@ -3132,6 +3156,9 @@ void Temperature::isr() { #if HAS_FAN7 if (soft_pwm_count_fan[7] <= pwm_count_tmp) WRITE_FAN(7, LOW); #endif + #if ENABLED(USE_CONTROLLER_FAN) + if (soft_pwm_controller.count <= pwm_count_tmp) WRITE(CONTROLLER_FAN_PIN, LOW); + #endif #endif } @@ -3296,8 +3323,8 @@ void Temperature::isr() { * This gives each ADC 0.9765ms to charge up. */ #define ACCUMULATE_ADC(obj) do{ \ - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; \ - else obj.sample(HAL_READ_ADC()); \ + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; \ + else obj.sample(hal.adc_value()); \ }while(0) ADCSensorState next_sensor_state = adc_sensor_state < SensorsReady ? (ADCSensorState)(int(adc_sensor_state) + 1) : StartSampling; @@ -3329,115 +3356,115 @@ void Temperature::isr() { break; #if HAS_TEMP_ADC_0 - case PrepareTemp_0: HAL_START_ADC(TEMP_0_PIN); break; + case PrepareTemp_0: hal.adc_start(TEMP_0_PIN); break; case MeasureTemp_0: ACCUMULATE_ADC(temp_hotend[0]); break; #endif #if HAS_TEMP_ADC_BED - case PrepareTemp_BED: HAL_START_ADC(TEMP_BED_PIN); break; + case PrepareTemp_BED: hal.adc_start(TEMP_BED_PIN); break; case MeasureTemp_BED: ACCUMULATE_ADC(temp_bed); break; #endif #if HAS_TEMP_ADC_CHAMBER - case PrepareTemp_CHAMBER: HAL_START_ADC(TEMP_CHAMBER_PIN); break; + case PrepareTemp_CHAMBER: hal.adc_start(TEMP_CHAMBER_PIN); break; case MeasureTemp_CHAMBER: ACCUMULATE_ADC(temp_chamber); break; #endif #if HAS_TEMP_ADC_COOLER - case PrepareTemp_COOLER: HAL_START_ADC(TEMP_COOLER_PIN); break; + case PrepareTemp_COOLER: hal.adc_start(TEMP_COOLER_PIN); break; case MeasureTemp_COOLER: ACCUMULATE_ADC(temp_cooler); break; #endif #if HAS_TEMP_ADC_PROBE - case PrepareTemp_PROBE: HAL_START_ADC(TEMP_PROBE_PIN); break; + case PrepareTemp_PROBE: hal.adc_start(TEMP_PROBE_PIN); break; case MeasureTemp_PROBE: ACCUMULATE_ADC(temp_probe); break; #endif #if HAS_TEMP_ADC_BOARD - case PrepareTemp_BOARD: HAL_START_ADC(TEMP_BOARD_PIN); break; + case PrepareTemp_BOARD: hal.adc_start(TEMP_BOARD_PIN); break; case MeasureTemp_BOARD: ACCUMULATE_ADC(temp_board); break; #endif #if HAS_TEMP_ADC_REDUNDANT - case PrepareTemp_REDUNDANT: HAL_START_ADC(TEMP_REDUNDANT_PIN); break; + case PrepareTemp_REDUNDANT: hal.adc_start(TEMP_REDUNDANT_PIN); break; case MeasureTemp_REDUNDANT: ACCUMULATE_ADC(temp_redundant); break; #endif #if HAS_TEMP_ADC_1 - case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break; + case PrepareTemp_1: hal.adc_start(TEMP_1_PIN); break; case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break; #endif #if HAS_TEMP_ADC_2 - case PrepareTemp_2: HAL_START_ADC(TEMP_2_PIN); break; + case PrepareTemp_2: hal.adc_start(TEMP_2_PIN); break; case MeasureTemp_2: ACCUMULATE_ADC(temp_hotend[2]); break; #endif #if HAS_TEMP_ADC_3 - case PrepareTemp_3: HAL_START_ADC(TEMP_3_PIN); break; + case PrepareTemp_3: hal.adc_start(TEMP_3_PIN); break; case MeasureTemp_3: ACCUMULATE_ADC(temp_hotend[3]); break; #endif #if HAS_TEMP_ADC_4 - case PrepareTemp_4: HAL_START_ADC(TEMP_4_PIN); break; + case PrepareTemp_4: hal.adc_start(TEMP_4_PIN); break; case MeasureTemp_4: ACCUMULATE_ADC(temp_hotend[4]); break; #endif #if HAS_TEMP_ADC_5 - case PrepareTemp_5: HAL_START_ADC(TEMP_5_PIN); break; + case PrepareTemp_5: hal.adc_start(TEMP_5_PIN); break; case MeasureTemp_5: ACCUMULATE_ADC(temp_hotend[5]); break; #endif #if HAS_TEMP_ADC_6 - case PrepareTemp_6: HAL_START_ADC(TEMP_6_PIN); break; + case PrepareTemp_6: hal.adc_start(TEMP_6_PIN); break; case MeasureTemp_6: ACCUMULATE_ADC(temp_hotend[6]); break; #endif #if HAS_TEMP_ADC_7 - case PrepareTemp_7: HAL_START_ADC(TEMP_7_PIN); break; + case PrepareTemp_7: hal.adc_start(TEMP_7_PIN); break; case MeasureTemp_7: ACCUMULATE_ADC(temp_hotend[7]); break; #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) - case Prepare_FILWIDTH: HAL_START_ADC(FILWIDTH_PIN); break; + case Prepare_FILWIDTH: hal.adc_start(FILWIDTH_PIN); break; case Measure_FILWIDTH: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else filwidth.accumulate(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else filwidth.accumulate(hal.adc_value()); break; #endif #if ENABLED(POWER_MONITOR_CURRENT) case Prepare_POWER_MONITOR_CURRENT: - HAL_START_ADC(POWER_MONITOR_CURRENT_PIN); + hal.adc_start(POWER_MONITOR_CURRENT_PIN); break; case Measure_POWER_MONITOR_CURRENT: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else power_monitor.add_current_sample(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else power_monitor.add_current_sample(hal.adc_value()); break; #endif #if ENABLED(POWER_MONITOR_VOLTAGE) case Prepare_POWER_MONITOR_VOLTAGE: - HAL_START_ADC(POWER_MONITOR_VOLTAGE_PIN); + hal.adc_start(POWER_MONITOR_VOLTAGE_PIN); break; case Measure_POWER_MONITOR_VOLTAGE: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else power_monitor.add_voltage_sample(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else power_monitor.add_voltage_sample(hal.adc_value()); break; #endif #if HAS_JOY_ADC_X - case PrepareJoy_X: HAL_START_ADC(JOY_X_PIN); break; + case PrepareJoy_X: hal.adc_start(JOY_X_PIN); break; case MeasureJoy_X: ACCUMULATE_ADC(joystick.x); break; #endif #if HAS_JOY_ADC_Y - case PrepareJoy_Y: HAL_START_ADC(JOY_Y_PIN); break; + case PrepareJoy_Y: hal.adc_start(JOY_Y_PIN); break; case MeasureJoy_Y: ACCUMULATE_ADC(joystick.y); break; #endif #if HAS_JOY_ADC_Z - case PrepareJoy_Z: HAL_START_ADC(JOY_Z_PIN); break; + case PrepareJoy_Z: hal.adc_start(JOY_Z_PIN); break; case MeasureJoy_Z: ACCUMULATE_ADC(joystick.z); break; #endif @@ -3445,12 +3472,12 @@ void Temperature::isr() { #ifndef ADC_BUTTON_DEBOUNCE_DELAY #define ADC_BUTTON_DEBOUNCE_DELAY 16 #endif - case Prepare_ADC_KEY: HAL_START_ADC(ADC_KEYPAD_PIN); break; + case Prepare_ADC_KEY: hal.adc_start(ADC_KEYPAD_PIN); break; case Measure_ADC_KEY: - if (!HAL_ADC_READY()) + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // redo this state else if (ADCKey_count < ADC_BUTTON_DEBOUNCE_DELAY) { - raw_ADCKey_value = HAL_READ_ADC(); + raw_ADCKey_value = hal.adc_value(); if (raw_ADCKey_value <= 900UL * HAL_ADC_RANGE / 1024UL) { NOMORE(current_ADCKey_raw, raw_ADCKey_value); ADCKey_count++; @@ -3475,13 +3502,16 @@ void Temperature::isr() { adc_sensor_state = next_sensor_state; // - // Additional ~1KHz Tasks + // Additional ~1kHz Tasks // #if ENABLED(BABYSTEPPING) && DISABLED(INTEGRATED_BABYSTEPPING) babystep.task(); #endif + // Check fan tachometers + TERN_(HAS_FANCHECK, fan_check.update_tachometers()); + // Poll endstops state, if required endstops.poll(); @@ -3553,7 +3583,7 @@ void Temperature::isr() { OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/) ) { #if HAS_TEMP_HOTEND - print_heater_state(H_E0, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder))); + print_heater_state(H_NONE, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder))); #endif #if HAS_HEATED_BED print_heater_state(H_BED, degBed(), degTargetBed() OPTARG(SHOW_TEMP_ADC_VALUES, rawBedTemp())); @@ -3719,7 +3749,7 @@ void Temperature::isr() { #if G26_CLICK_CAN_CANCEL if (click_to_cancel && ui.use_click()) { wait_for_heatup = false; - TERN_(HAS_LCD_MENU, ui.quick_feedback()); + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); } #endif @@ -3853,7 +3883,7 @@ void Temperature::isr() { #if G26_CLICK_CAN_CANCEL if (click_to_cancel && ui.use_click()) { wait_for_heatup = false; - TERN_(HAS_LCD_MENU, ui.quick_feedback()); + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 0e66f2311012..cb84f7e395d4 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -37,6 +37,10 @@ #include "../libs/autoreport.h" #endif +#if HAS_FANCHECK + #include "../feature/fancheck.h" +#endif + #ifndef SOFT_PWM_SCALE #define SOFT_PWM_SCALE 0 #endif @@ -52,7 +56,8 @@ typedef enum : int8_t { H_BOARD = HID_BOARD, H_CHAMBER = HID_CHAMBER, H_BED = HID_BED, - H_E0 = HID_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7 + H_E0 = HID_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7, + H_NONE = -128 } heater_id_t; // PID storage @@ -181,18 +186,22 @@ enum ADCSensorState : char { #define unscalePID_d(d) ( float(d) * PID_dT ) #endif -#if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) +#if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) #define G26_CLICK_CAN_CANCEL 1 #endif // A temperature sensor typedef struct TempInfo { - uint16_t acc; - int16_t raw; +private: + raw_adc_t acc; + raw_adc_t raw; +public: celsius_float_t celsius; inline void reset() { acc = 0; } - inline void sample(const uint16_t s) { acc += s; } + inline void sample(const raw_adc_t s) { acc += s; } inline void update() { raw = acc; } + void setraw(const raw_adc_t r) { raw = r; } + raw_adc_t getraw() { return raw; } } temp_info_t; #if HAS_TEMP_REDUNDANT @@ -226,9 +235,6 @@ struct PIDHeaterInfo : public HeaterInfo { typedef heater_info_t bed_info_t; #endif #endif -#if HAS_TEMP_PROBE - typedef temp_info_t probe_info_t; -#endif #if HAS_HEATED_CHAMBER #if ENABLED(PIDTEMPCHAMBER) typedef struct PIDHeaterInfo chamber_info_t; @@ -238,12 +244,15 @@ struct PIDHeaterInfo : public HeaterInfo { #elif HAS_TEMP_CHAMBER typedef temp_info_t chamber_info_t; #endif -#if HAS_TEMP_BOARD - typedef temp_info_t board_info_t; +#if HAS_TEMP_PROBE + typedef temp_info_t probe_info_t; #endif #if EITHER(HAS_COOLER, HAS_TEMP_COOLER) typedef heater_info_t cooler_info_t; #endif +#if HAS_TEMP_BOARD + typedef temp_info_t board_info_t; +#endif // Heater watch handling template @@ -282,9 +291,7 @@ struct HeaterWatch { #endif // Temperature sensor read value ranges -typedef struct { int16_t raw_min, raw_max; } raw_range_t; -typedef struct { celsius_t mintemp, maxtemp; } celsius_range_t; -typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t; +typedef struct { raw_adc_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t; #define THERMISTOR_ABS_ZERO_C -273.15f // bbbbrrrrr cold ! #define THERMISTOR_RESISTANCE_NOMINAL_C 25.0f // mmmmm comfortable @@ -313,12 +320,12 @@ typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_ra #if TEMP_SENSOR_BED_IS_CUSTOM CTI_BED, #endif - #if TEMP_SENSOR_PROBE_IS_CUSTOM - CTI_PROBE, - #endif #if TEMP_SENSOR_CHAMBER_IS_CUSTOM CTI_CHAMBER, #endif + #if TEMP_SENSOR_PROBE_IS_CUSTOM + CTI_PROBE, + #endif #if TEMP_SENSOR_COOLER_IS_CUSTOM CTI_COOLER, #endif @@ -344,6 +351,10 @@ typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_ra #endif +#if HAS_AUTO_FAN || HAS_FANCHECK + #define HAS_FAN_LOGIC 1 +#endif + class Temperature { public: @@ -351,7 +362,7 @@ class Temperature { #if HAS_HOTEND static hotend_info_t temp_hotend[HOTENDS]; static const celsius_t hotend_maxtemp[HOTENDS]; - static inline celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } + static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif #if HAS_HEATED_BED static bed_info_t temp_bed; @@ -372,7 +383,7 @@ class Temperature { static redundant_info_t temp_redundant; #endif - #if ENABLED(AUTO_POWER_E_FANS) + #if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK) static uint8_t autofan_speed[HOTENDS]; #endif #if ENABLED(AUTO_POWER_CHAMBER_FAN) @@ -387,19 +398,23 @@ class Temperature { soft_pwm_count_fan[FAN_COUNT]; #endif + #if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN) + static uint8_t soft_pwm_controller_speed; + #endif + #if ENABLED(PREVENT_COLD_EXTRUSION) static bool allow_cold_extrude; static celsius_t extrude_min_temp; - static inline bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } - static inline bool tooColdToExtrude(const uint8_t E_NAME) { return tooCold(wholeDegHotend(HOTEND_INDEX)); } - static inline bool targetTooColdToExtrude(const uint8_t E_NAME) { return tooCold(degTargetHotend(HOTEND_INDEX)); } + static bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } + static bool tooColdToExtrude(const uint8_t E_NAME) { return tooCold(wholeDegHotend(HOTEND_INDEX)); } + static bool targetTooColdToExtrude(const uint8_t E_NAME) { return tooCold(degTargetHotend(HOTEND_INDEX)); } #else - static inline bool tooColdToExtrude(const uint8_t) { return false; } - static inline bool targetTooColdToExtrude(const uint8_t) { return false; } + static bool tooColdToExtrude(const uint8_t) { return false; } + static bool targetTooColdToExtrude(const uint8_t) { return false; } #endif - static inline bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } - static inline bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } + static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } + static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } #if EITHER(SINGLENOZZLE_STANDBY_TEMP, SINGLENOZZLE_STANDBY_FAN) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) @@ -437,7 +452,7 @@ class Temperature { }; // Convert the given heater_id_t to idle array index - static inline IdleIndex idle_index_for_id(const int8_t heater_id) { + static IdleIndex idle_index_for_id(const int8_t heater_id) { TERN_(HAS_HEATED_BED, if (heater_id == H_BED) return IDLE_INDEX_BED); return (IdleIndex)_MAX(heater_id, 0); } @@ -455,6 +470,10 @@ class Temperature { static int16_t lpq_len; #endif + #if HAS_FAN_LOGIC + static constexpr millis_t fan_update_interval_ms = TERN(HAS_PWMFANCHECK, 5000, TERN(HAS_FANCHECK, 1000, 2500)); + #endif + private: #if ENABLED(WATCH_HOTENDS) @@ -475,7 +494,7 @@ class Temperature { static bed_watch_t watch_bed; #endif IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); - static int16_t mintemp_raw_BED, maxtemp_raw_BED; + static raw_adc_t mintemp_raw_BED, maxtemp_raw_BED; #endif #if HAS_HEATED_CHAMBER @@ -483,7 +502,7 @@ class Temperature { static chamber_watch_t watch_chamber; #endif TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms); - static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; + static raw_adc_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; #endif #if HAS_COOLER @@ -491,11 +510,11 @@ class Temperature { static cooler_watch_t watch_cooler; #endif static millis_t next_cooler_check_ms, cooler_fan_flush_ms; - static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER; + static raw_adc_t mintemp_raw_COOLER, maxtemp_raw_COOLER; #endif #if HAS_TEMP_BOARD && ENABLED(THERMAL_PROTECTION_BOARD) - static int16_t mintemp_raw_BOARD, maxtemp_raw_BOARD; + static raw_adc_t mintemp_raw_BOARD, maxtemp_raw_BOARD; #endif #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 @@ -506,8 +525,28 @@ class Temperature { static millis_t preheat_end_time[HOTENDS]; #endif - #if HAS_AUTO_FAN - static millis_t next_auto_fan_check_ms; + #if HAS_FAN_LOGIC + static millis_t fan_update_ms; + + static void manage_extruder_fans(millis_t ms) { + if (ELAPSED(ms, fan_update_ms)) { // only need to check fan state very infrequently + const millis_t next_ms = ms + fan_update_interval_ms; + #if HAS_PWMFANCHECK + #define FAN_CHECK_DURATION 100 + if (fan_check.is_measuring()) { + fan_check.compute_speed(ms + FAN_CHECK_DURATION - fan_update_ms); + fan_update_ms = next_ms; + } + else + fan_update_ms = ms + FAN_CHECK_DURATION; + fan_check.toggle_measuring(); + #else + TERN_(HAS_FANCHECK, fan_check.compute_speed(next_ms - fan_update_ms)); + fan_update_ms = next_ms; + #endif + TERN_(HAS_AUTO_FAN, update_autofans()); // Needed as last when HAS_PWMFANCHECK to properly force fan speed + } + } #endif #if ENABLED(PROBING_HEATERS_OFF) @@ -529,26 +568,26 @@ class Temperature { static user_thermistor_t user_thermistor[USER_THERMISTORS]; static void M305_report(const uint8_t t_index, const bool forReplay=true); static void reset_user_thermistors(); - static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw); - static inline bool set_pull_up_res(int8_t t_index, float value) { + static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const raw_adc_t raw); + static bool set_pull_up_res(int8_t t_index, float value) { //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false; if (!WITHIN(value, 1, 1000000)) return false; user_thermistor[t_index].series_res = value; return true; } - static inline bool set_res25(int8_t t_index, float value) { + static bool set_res25(int8_t t_index, float value) { if (!WITHIN(value, 1, 10000000)) return false; user_thermistor[t_index].res_25 = value; user_thermistor[t_index].pre_calc = true; return true; } - static inline bool set_beta(int8_t t_index, float value) { + static bool set_beta(int8_t t_index, float value) { if (!WITHIN(value, 1, 1000000)) return false; user_thermistor[t_index].beta = value; user_thermistor[t_index].pre_calc = true; return true; } - static inline bool set_sh_coeff(int8_t t_index, float value) { + static bool set_sh_coeff(int8_t t_index, float value) { if (!WITHIN(value, -0.01f, 0.01f)) return false; user_thermistor[t_index].sh_c_coeff = value; user_thermistor[t_index].pre_calc = true; @@ -557,25 +596,25 @@ class Temperature { #endif #if HAS_HOTEND - static celsius_float_t analog_to_celsius_hotend(const int16_t raw, const uint8_t e); + static celsius_float_t analog_to_celsius_hotend(const raw_adc_t raw, const uint8_t e); #endif #if HAS_HEATED_BED - static celsius_float_t analog_to_celsius_bed(const int16_t raw); - #endif - #if HAS_TEMP_PROBE - static celsius_float_t analog_to_celsius_probe(const int16_t raw); + static celsius_float_t analog_to_celsius_bed(const raw_adc_t raw); #endif #if HAS_TEMP_CHAMBER - static celsius_float_t analog_to_celsius_chamber(const int16_t raw); + static celsius_float_t analog_to_celsius_chamber(const raw_adc_t raw); + #endif + #if HAS_TEMP_PROBE + static celsius_float_t analog_to_celsius_probe(const raw_adc_t raw); #endif #if HAS_TEMP_COOLER - static celsius_float_t analog_to_celsius_cooler(const int16_t raw); + static celsius_float_t analog_to_celsius_cooler(const raw_adc_t raw); #endif #if HAS_TEMP_BOARD - static celsius_float_t analog_to_celsius_board(const int16_t raw); + static celsius_float_t analog_to_celsius_board(const raw_adc_t raw); #endif #if HAS_TEMP_REDUNDANT - static celsius_float_t analog_to_celsius_redundant(const int16_t raw); + static celsius_float_t analog_to_celsius_redundant(const raw_adc_t raw); #endif #if HAS_FAN @@ -598,18 +637,18 @@ class Temperature { static uint8_t fan_speed_scaler[FAN_COUNT]; #endif - static inline uint8_t scaledFanSpeed(const uint8_t fan, const uint8_t fs) { + static uint8_t scaledFanSpeed(const uint8_t fan, const uint8_t fs) { UNUSED(fan); // Potentially unused! return (fs * uint16_t(TERN(ADAPTIVE_FAN_SLOWING, fan_speed_scaler[fan], 128))) >> 7; } - static inline uint8_t scaledFanSpeed(const uint8_t fan) { + static uint8_t scaledFanSpeed(const uint8_t fan) { return scaledFanSpeed(fan, fan_speed[fan]); } static constexpr inline uint8_t pwmToPercent(const uint8_t speed) { return ui8_to_percent(speed); } - static inline uint8_t fanSpeedPercent(const uint8_t fan) { return ui8_to_percent(fan_speed[fan]); } - static inline uint8_t scaledFanSpeedPercent(const uint8_t fan) { return ui8_to_percent(scaledFanSpeed(fan)); } + static uint8_t fanSpeedPercent(const uint8_t fan) { return ui8_to_percent(fan_speed[fan]); } + static uint8_t scaledFanSpeedPercent(const uint8_t fan) { return ui8_to_percent(scaledFanSpeed(fan)); } #if ENABLED(EXTRA_FAN_SPEED) typedef struct { uint8_t saved, speed; } extra_fan_t; @@ -623,7 +662,7 @@ class Temperature { #endif // HAS_FAN - static inline void zero_fan_speeds() { + static void zero_fan_speeds() { #if HAS_FAN FANS_LOOP(i) set_fan_speed(i, 0); #endif @@ -644,13 +683,13 @@ class Temperature { * Preheating hotends */ #if MILLISECONDS_PREHEAT_TIME > 0 - static inline bool is_preheating(const uint8_t E_NAME) { + static bool is_preheating(const uint8_t E_NAME) { return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]); } - static inline void start_preheat_time(const uint8_t E_NAME) { + static void start_preheat_time(const uint8_t E_NAME) { preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME; } - static inline void reset_preheat_time(const uint8_t E_NAME) { + static void reset_preheat_time(const uint8_t E_NAME) { preheat_end_time[HOTEND_INDEX] = 0; } #else @@ -661,21 +700,21 @@ class Temperature { //inline so that there is no performance decrease. //deg=degreeCelsius - static inline celsius_float_t degHotend(const uint8_t E_NAME) { + static celsius_float_t degHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius); } - static inline celsius_t wholeDegHotend(const uint8_t E_NAME) { + static celsius_t wholeDegHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, static_cast(temp_hotend[HOTEND_INDEX].celsius + 0.5f)); } #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawHotendTemp(const uint8_t E_NAME) { - return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw); + static raw_adc_t rawHotendTemp(const uint8_t E_NAME) { + return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].getraw()); } #endif - static inline celsius_t degTargetHotend(const uint8_t E_NAME) { + static celsius_t degTargetHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target); } @@ -694,11 +733,11 @@ class Temperature { start_watching_hotend(ee); } - static inline bool isHeatingHotend(const uint8_t E_NAME) { + static bool isHeatingHotend(const uint8_t E_NAME) { return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius; } - static inline bool isCoolingHotend(const uint8_t E_NAME) { + static bool isCoolingHotend(const uint8_t E_NAME) { return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius; } @@ -712,16 +751,16 @@ class Temperature { #endif #endif - static inline bool still_heating(const uint8_t e) { + static bool still_heating(const uint8_t e) { return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(wholeDegHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS; } - static inline bool degHotendNear(const uint8_t e, const celsius_t temp) { + static bool degHotendNear(const uint8_t e, const celsius_t temp) { return ABS(wholeDegHotend(e) - temp) < (TEMP_HYSTERESIS); } // Start watching a Hotend to make sure it's really heating up - static inline void start_watching_hotend(const uint8_t E_NAME) { + static void start_watching_hotend(const uint8_t E_NAME) { UNUSED(HOTEND_INDEX); #if WATCH_HOTENDS watch_hotend[HOTEND_INDEX].restart(degHotend(HOTEND_INDEX), degTargetHotend(HOTEND_INDEX)); @@ -733,16 +772,16 @@ class Temperature { #if HAS_HEATED_BED #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawBedTemp() { return temp_bed.raw; } + static raw_adc_t rawBedTemp() { return temp_bed.getraw(); } #endif - static inline celsius_float_t degBed() { return temp_bed.celsius; } - static inline celsius_t wholeDegBed() { return static_cast(degBed() + 0.5f); } - static inline celsius_t degTargetBed() { return temp_bed.target; } - static inline bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } - static inline bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } + static celsius_float_t degBed() { return temp_bed.celsius; } + static celsius_t wholeDegBed() { return static_cast(degBed() + 0.5f); } + static celsius_t degTargetBed() { return temp_bed.target; } + static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } + static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } // Start watching the Bed to make sure it's really heating up - static inline void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } + static void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } static void setTargetBed(const celsius_t celsius) { TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on()); @@ -756,7 +795,7 @@ class Temperature { static void wait_for_bed_heating(); - static inline bool degBedNear(const celsius_t temp) { + static bool degBedNear(const celsius_t temp) { return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); } @@ -764,25 +803,25 @@ class Temperature { #if HAS_TEMP_PROBE #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawProbeTemp() { return temp_probe.raw; } + static raw_adc_t rawProbeTemp() { return temp_probe.getraw(); } #endif - static inline celsius_float_t degProbe() { return temp_probe.celsius; } - static inline celsius_t wholeDegProbe() { return static_cast(degProbe() + 0.5f); } - static inline bool isProbeBelowTemp(const celsius_t target_temp) { return wholeDegProbe() < target_temp; } - static inline bool isProbeAboveTemp(const celsius_t target_temp) { return wholeDegProbe() > target_temp; } + static celsius_float_t degProbe() { return temp_probe.celsius; } + static celsius_t wholeDegProbe() { return static_cast(degProbe() + 0.5f); } + static bool isProbeBelowTemp(const celsius_t target_temp) { return wholeDegProbe() < target_temp; } + static bool isProbeAboveTemp(const celsius_t target_temp) { return wholeDegProbe() > target_temp; } static bool wait_for_probe(const celsius_t target_temp, bool no_wait_for_cooling=true); #endif #if HAS_TEMP_CHAMBER #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawChamberTemp() { return temp_chamber.raw; } + static raw_adc_t rawChamberTemp() { return temp_chamber.getraw(); } #endif - static inline celsius_float_t degChamber() { return temp_chamber.celsius; } - static inline celsius_t wholeDegChamber() { return static_cast(degChamber() + 0.5f); } + static celsius_float_t degChamber() { return temp_chamber.celsius; } + static celsius_t wholeDegChamber() { return static_cast(degChamber() + 0.5f); } #if HAS_HEATED_CHAMBER - static inline celsius_t degTargetChamber() { return temp_chamber.target; } - static inline bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } - static inline bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } + static celsius_t degTargetChamber() { return temp_chamber.target; } + static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } + static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } static bool wait_for_chamber(const bool no_wait_for_cooling=true); #endif #endif @@ -793,49 +832,48 @@ class Temperature { start_watching_chamber(); } // Start watching the Chamber to make sure it's really heating up - static inline void start_watching_chamber() { TERN_(WATCH_CHAMBER, watch_chamber.restart(degChamber(), degTargetChamber())); } + static void start_watching_chamber() { TERN_(WATCH_CHAMBER, watch_chamber.restart(degChamber(), degTargetChamber())); } #endif #if HAS_TEMP_COOLER #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawCoolerTemp() { return temp_cooler.raw; } + static raw_adc_t rawCoolerTemp() { return temp_cooler.getraw(); } #endif - static inline celsius_float_t degCooler() { return temp_cooler.celsius; } - static inline celsius_t wholeDegCooler() { return static_cast(temp_cooler.celsius + 0.5f); } + static celsius_float_t degCooler() { return temp_cooler.celsius; } + static celsius_t wholeDegCooler() { return static_cast(temp_cooler.celsius + 0.5f); } #if HAS_COOLER - static inline celsius_t degTargetCooler() { return temp_cooler.target; } - static inline bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } - static inline bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } + static celsius_t degTargetCooler() { return temp_cooler.target; } + static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } + static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } static bool wait_for_cooler(const bool no_wait_for_cooling=true); #endif #endif #if HAS_TEMP_BOARD #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawBoardTemp() { return temp_board.raw; } + static raw_adc_t rawBoardTemp() { return temp_board.getraw(); } #endif - static inline celsius_float_t degBoard() { return temp_board.celsius; } - static inline celsius_t wholeDegBoard() { return static_cast(temp_board.celsius + 0.5f); } + static celsius_float_t degBoard() { return temp_board.celsius; } + static celsius_t wholeDegBoard() { return static_cast(temp_board.celsius + 0.5f); } #endif #if HAS_TEMP_REDUNDANT #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawRedundantTemp() { return temp_redundant.raw; } - static inline int16_t rawRedundanTargetTemp() { return (*temp_redundant.target).raw; } + static raw_adc_t rawRedundantTemp() { return temp_redundant.getraw(); } #endif - static inline celsius_float_t degRedundant() { return temp_redundant.celsius; } - static inline celsius_float_t degRedundantTarget() { return (*temp_redundant.target).celsius; } - static inline celsius_t wholeDegRedundant() { return static_cast(temp_redundant.celsius + 0.5f); } - static inline celsius_t wholeDegRedundantTarget() { return static_cast((*temp_redundant.target).celsius + 0.5f); } + static celsius_float_t degRedundant() { return temp_redundant.celsius; } + static celsius_float_t degRedundantTarget() { return (*temp_redundant.target).celsius; } + static celsius_t wholeDegRedundant() { return static_cast(temp_redundant.celsius + 0.5f); } + static celsius_t wholeDegRedundantTarget() { return static_cast((*temp_redundant.target).celsius + 0.5f); } #endif #if HAS_COOLER - static inline void setTargetCooler(const celsius_t celsius) { + static void setTargetCooler(const celsius_t celsius) { temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET); start_watching_cooler(); } // Start watching the Cooler to make sure it's really cooling down - static inline void start_watching_cooler() { TERN_(WATCH_COOLER, watch_cooler.restart(degCooler(), degTargetCooler())); } + static void start_watching_cooler() { TERN_(WATCH_COOLER, watch_cooler.restart(degCooler(), degTargetCooler())); } #endif /** @@ -851,7 +889,7 @@ class Temperature { /** * Cooldown, as from the LCD. Disables all heaters and fans. */ - static inline void cooldown() { + static void cooldown() { zero_fan_speeds(); disable_all_heaters(); } @@ -885,7 +923,7 @@ class Temperature { * Update the temp manager when PID values change */ #if ENABLED(PIDTEMP) - static inline void updatePID() { + static void updatePID() { TERN_(PID_EXTRUSION_SCALING, last_e_position = 0); } #endif @@ -898,13 +936,13 @@ class Temperature { #if HEATER_IDLE_HANDLER - static inline void reset_hotend_idle_timer(const uint8_t E_NAME) { + static void reset_hotend_idle_timer(const uint8_t E_NAME) { heater_idle[HOTEND_INDEX].reset(); start_watching_hotend(HOTEND_INDEX); } #if HAS_HEATED_BED - static inline void reset_bed_idle_timer() { + static void reset_bed_idle_timer() { heater_idle[IDLE_INDEX_BED].reset(); start_watching_bed(); } @@ -925,10 +963,10 @@ class Temperature { #if HAS_HOTEND && HAS_STATUS_MESSAGE static void set_heating_message(const uint8_t e); #else - static inline void set_heating_message(const uint8_t) {} + static void set_heating_message(const uint8_t) {} #endif - #if HAS_LCD_MENU && HAS_TEMPERATURE + #if HAS_MARLINUI_MENU && HAS_TEMPERATURE static void lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb); #endif @@ -938,7 +976,7 @@ class Temperature { static volatile bool raw_temps_ready; static void update_raw_temperatures(); static void updateTemperaturesFromRawValues(); - static inline bool updateTemperaturesIfReady() { + static bool updateTemperaturesIfReady() { if (!raw_temps_ready) return false; updateTemperaturesFromRawValues(); raw_temps_ready = false; @@ -954,10 +992,15 @@ class Temperature { #else #define READ_MAX_TC(N) read_max_tc() #endif - static int16_t read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); + static raw_adc_t read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); #endif - static void checkExtruderAutoFans(); + #if HAS_AUTO_FAN + #if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + static bool autofans_on; + #endif + static void update_autofans(); + #endif #if HAS_HOTEND static float get_pid_output_hotend(const uint8_t e); @@ -973,7 +1016,7 @@ class Temperature { static void min_temp_error(const heater_id_t e); static void max_temp_error(const heater_id_t e); - #define HAS_THERMAL_PROTECTION ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, HAS_THERMALLY_PROTECTED_BED, THERMAL_PROTECTION_COOLER) + #define HAS_THERMAL_PROTECTION ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_COOLER) #if HAS_THERMAL_PROTECTION @@ -985,26 +1028,32 @@ class Temperature { REPEAT(HOTENDS, _RUNAWAY_IND_E) #undef _RUNAWAY_IND_E #endif - OPTARG(HAS_THERMALLY_PROTECTED_BED, RUNAWAY_IND_BED) + OPTARG(THERMAL_PROTECTION_BED, RUNAWAY_IND_BED) OPTARG(THERMAL_PROTECTION_CHAMBER, RUNAWAY_IND_CHAMBER) OPTARG(THERMAL_PROTECTION_COOLER, RUNAWAY_IND_COOLER) , NR_HEATER_RUNAWAY }; // Convert the given heater_id_t to runaway state array index - static inline RunawayIndex runaway_index_for_id(const int8_t heater_id) { - TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER); - TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER); - TERN_(HAS_THERMALLY_PROTECTED_BED, if (heater_id == H_BED) return RUNAWAY_IND_BED); + static RunawayIndex runaway_index_for_id(const int8_t heater_id) { + TERN_(THERMAL_PROTECTION_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER); + TERN_(THERMAL_PROTECTION_COOLER, if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER); + TERN_(THERMAL_PROTECTION_BED, if (heater_id == H_BED) return RUNAWAY_IND_BED); return (RunawayIndex)_MAX(heater_id, 0); } - enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway }; + enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway + OPTARG(THERMAL_PROTECTION_VARIANCE_MONITOR, TRMalfunction) + }; typedef struct { millis_t timer = 0; TRState state = TRInactive; float running_temp; + #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) + millis_t variance_timer = 0; + celsius_float_t last_temp = 0.0, variance = 0.0; + #endif void run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc); } tr_state_machine_t; diff --git a/Marlin/src/module/thermistor/thermistor_504.h b/Marlin/src/module/thermistor/thermistor_504.h new file mode 100644 index 000000000000..61ce3ae1358c --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_504.h @@ -0,0 +1,93 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2022 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 + +// QWG 104F B3950 thermistor +constexpr temp_entry_t temptable_504[] PROGMEM = { + { OV( 15), 330 }, + { OV( 17), 315 }, + { OV( 19), 300 }, + { OV( 20), 295 }, + { OV( 21), 290 }, + { OV( 23), 285 }, + { OV( 25), 280 }, + { OV( 27), 275 }, + { OV( 28), 270 }, + { OV( 31), 265 }, + { OV( 33), 260 }, + { OV( 35), 255 }, + { OV( 38), 250 }, + { OV( 41), 245 }, + { OV( 44), 240 }, + { OV( 48), 235 }, + { OV( 52), 230 }, + { OV( 56), 225 }, + { OV( 61), 220 }, + { OV( 66), 215 }, + { OV( 78), 210 }, + { OV( 92), 205 }, + { OV( 100), 200 }, + { OV( 109), 195 }, + { OV( 120), 190 }, + { OV( 143), 185 }, + { OV( 148), 180 }, + { OV( 156), 175 }, + { OV( 171), 170 }, + { OV( 187), 165 }, + { OV( 205), 160 }, + { OV( 224), 155 }, + { OV( 268), 150 }, + { OV( 293), 145 }, + { OV( 320), 140 }, + { OV( 348), 135 }, + { OV( 379), 130 }, + { OV( 411), 125 }, + { OV( 445), 120 }, + { OV( 480), 115 }, + { OV( 516), 110 }, + { OV( 553), 105 }, + { OV( 591), 100 }, + { OV( 628), 95 }, + { OV( 665), 90 }, + { OV( 702), 85 }, + { OV( 737), 80 }, + { OV( 770), 75 }, + { OV( 801), 70 }, + { OV( 830), 65 }, + { OV( 857), 60 }, + { OV( 881), 55 }, + { OV( 903), 50 }, + { OV( 922), 45 }, + { OV( 939), 40 }, + { OV( 954), 35 }, + { OV( 966), 30 }, + { OV( 977), 25 }, + { OV( 985), 23 }, + { OV( 993), 20 }, + { OV( 999), 18 }, + { OV(1004), 15 }, + { OV(1008), 12 }, + { OV(1012), 8 }, + { OV(1016), 5 }, + { OV(1020), 0 }, + { OV(1023), -5 } +}; diff --git a/Marlin/src/module/thermistor/thermistor_505.h b/Marlin/src/module/thermistor/thermistor_505.h new file mode 100644 index 000000000000..6c94b0e1b456 --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_505.h @@ -0,0 +1,82 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2022 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 + +// ZONESTAR hotbed QWG-104F-3950 thermistor +constexpr temp_entry_t temptable_505[] PROGMEM = { + { OV( 1), 938 }, + { OV( 8), 320 }, + { OV( 16), 300 }, + { OV( 27), 290 }, + { OV( 36), 272 }, + { OV( 47), 258 }, + { OV( 56), 248 }, + { OV( 68), 245 }, + { OV( 78), 237 }, + { OV( 89), 228 }, + { OV( 99), 221 }, + { OV( 110), 215 }, + { OV( 120), 209 }, + { OV( 131), 204 }, + { OV( 141), 199 }, + { OV( 151), 195 }, + { OV( 161), 190 }, + { OV( 171), 187 }, + { OV( 181), 183 }, + { OV( 201), 179 }, + { OV( 221), 170 }, + { OV( 251), 165 }, + { OV( 261), 160 }, + { OV( 321), 150 }, + { OV( 361), 144 }, + { OV( 401), 140 }, + { OV( 421), 133 }, + { OV( 451), 130 }, + { OV( 551), 120 }, + { OV( 571), 117 }, + { OV( 596), 110 }, + { OV( 626), 105 }, + { OV( 666), 100 }, + { OV( 677), 95 }, + { OV( 697), 90 }, + { OV( 717), 85 }, + { OV( 727), 79 }, + { OV( 750), 72 }, + { OV( 789), 69 }, + { OV( 819), 65 }, + { OV( 861), 57 }, + { OV( 870), 55 }, + { OV( 881), 51 }, + { OV( 911), 45 }, + { OV( 922), 39 }, + { OV( 968), 28 }, + { OV( 977), 25 }, + { OV( 985), 23 }, + { OV( 993), 20 }, + { OV( 999), 18 }, + { OV(1004), 15 }, + { OV(1008), 12 }, + { OV(1012), 8 }, + { OV(1016), 5 }, + { OV(1020), 0 }, + { OV(1023), -5 } +}; diff --git a/Marlin/src/module/thermistor/thermistor_66.h b/Marlin/src/module/thermistor/thermistor_66.h index 3b057ac6960e..07cb29767935 100644 --- a/Marlin/src/module/thermistor/thermistor_66.h +++ b/Marlin/src/module/thermistor/thermistor_66.h @@ -27,27 +27,94 @@ constexpr temp_entry_t temptable_66[] PROGMEM = { { OV( 17.9), 500 }, { OV( 21.7), 480 }, { OV( 26.6), 460 }, - { OV( 33.1), 440 }, - { OV( 41.0), 420 }, - { OV( 52.3), 400 }, - { OV( 67.7), 380 }, - { OV( 86.5), 360 }, - { OV( 112.0), 340 }, - { OV( 147.2), 320 }, - { OV( 194.0), 300 }, - { OV( 254.3), 280 }, - { OV( 330.2), 260 }, - { OV( 427.9), 240 }, - { OV( 533.4), 220 }, - { OV( 646.5), 200 }, - { OV( 754.4), 180 }, - { OV( 844.3), 160 }, - { OV( 911.7), 140 }, - { OV( 958.6), 120 }, - { OV( 988.8), 100 }, + { OV( 34.0), 430 }, + { OV( 36.0), 426 }, + { OV( 37.0), 422 }, + { OV( 38.0), 418 }, + { OV( 40.4), 414 }, + { OV( 43.0), 410 }, + { OV( 45.6), 406 }, + { OV( 48.0), 402 }, + { OV( 50.6), 398 }, + { OV( 53.0), 394 }, + { OV( 56.0), 390 }, + { OV( 58.0), 386 }, + { OV( 61.0), 382 }, + { OV( 64.0), 378 }, + { OV( 68.0), 374 }, + { OV( 72.0), 370 }, + { OV( 75.0), 366 }, + { OV( 79.0), 362 }, + { OV( 83.0), 358 }, + { OV( 88.0), 354 }, + { OV( 93.0), 350 }, + { OV( 97.0), 346 }, + { OV( 103.0), 342 }, + { OV( 109.0), 338 }, + { OV( 115.0), 334 }, + { OV( 121.0), 330 }, + { OV( 128.0), 326 }, + { OV( 135.0), 322 }, + { OV( 143.0), 318 }, + { OV( 151.0), 314 }, + { OV( 160.0), 310 }, + { OV( 168.0), 306 }, + { OV( 177.0), 302 }, + { OV( 188.0), 298 }, + { OV( 198.0), 294 }, + { OV( 209.0), 290 }, + { OV( 222.0), 286 }, + { OV( 235.0), 282 }, + { OV( 248.0), 278 }, + { OV( 262.0), 274 }, + { OV( 276.0), 270 }, + { OV( 291.0), 266 }, + { OV( 306.0), 262 }, + { OV( 323.0), 258 }, + { OV( 340.0), 254 }, + { OV( 357.0), 250 }, + { OV( 378.0), 246 }, + { OV( 397.0), 242 }, + { OV( 417.0), 238 }, + { OV( 437.0), 234 }, + { OV( 458.0), 230 }, + { OV( 481.0), 226 }, + { OV( 502.0), 222 }, + { OV( 525.0), 218 }, + { OV( 547.0), 214 }, + { OV( 570.0), 210 }, + { OV( 594.0), 206 }, + { OV( 615.0), 202 }, + { OV( 637.0), 198 }, + { OV( 660.0), 194 }, + { OV( 683.0), 190 }, + { OV( 705.0), 186 }, + { OV( 727.0), 182 }, + { OV( 747.0), 178 }, + { OV( 767.0), 174 }, + { OV( 787.0), 170 }, + { OV( 805.0), 166 }, + { OV( 822.0), 162 }, + { OV( 839.0), 158 }, + { OV( 854.0), 154 }, + { OV( 870.0), 150 }, + { OV( 883.0), 146 }, + { OV( 898.0), 142 }, + { OV( 909.0), 138 }, + { OV( 919.0), 134 }, + { OV( 931.0), 130 }, + { OV( 940.0), 126 }, + { OV( 949.0), 122 }, + { OV( 957.0), 118 }, + { OV( 964.0), 114 }, + { OV( 971.0), 110 }, + { OV( 977.0), 106 }, + { OV( 982.0), 102 }, + { OV( 997.0), 93 }, + { OV(1002.2), 86 }, { OV(1006.6), 80 }, { OV(1015.8), 60 }, - { OV(1021.3), 30 }, - { OV( 1022), 25 }, - { OV( 1023), 20 } + { OV(1019.8), 36 }, + { OV(1020.9), 23 }, + { OV(1022.0), -1 } }; diff --git a/Marlin/src/module/thermistor/thermistor_68.h b/Marlin/src/module/thermistor/thermistor_68.h new file mode 100644 index 000000000000..270456dcb59c --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_68.h @@ -0,0 +1,54 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define REVERSE_TEMP_SENSOR_RANGE_68 1 + +// PT100 amplifier board from Dyze Design +const temp_entry_t temptable_68[] PROGMEM = { + { OV(273), 0 }, + { OV(294), 20 }, + { OV(315), 40 }, + { OV(336), 60 }, + { OV(356), 80 }, + { OV(376), 100 }, + { OV(396), 120 }, + { OV(416), 140 }, + { OV(436), 160 }, + { OV(455), 180 }, + { OV(474), 200 }, + { OV(494), 220 }, + { OV(513), 240 }, + { OV(531), 260 }, + { OV(550), 280 }, + { OV(568), 300 }, + { OV(587), 320 }, + { OV(605), 340 }, + { OV(623), 360 }, + { OV(641), 380 }, + { OV(658), 400 }, + { OV(676), 420 }, + { OV(693), 440 }, + { OV(710), 460 }, + { OV(727), 480 }, + { OV(744), 500 } +}; diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 85f4449636e8..a38b7f381feb 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -27,22 +27,20 @@ #define THERMISTOR_TABLE_SCALE (HAL_ADC_RANGE / _BV(THERMISTOR_TABLE_ADC_RESOLUTION)) #if ENABLED(HAL_ADC_FILTERED) #define OVERSAMPLENR 1 -#elif HAL_ADC_RESOLUTION > 10 - #define OVERSAMPLENR (20 - HAL_ADC_RESOLUTION) #else #define OVERSAMPLENR 16 #endif -#define MAX_RAW_THERMISTOR_VALUE (HAL_ADC_RANGE * (OVERSAMPLENR) - 1) -// Currently Marlin stores all oversampled ADC values as int16_t, make sure the HAL settings do not overflow 15bit -#if MAX_RAW_THERMISTOR_VALUE > ((1 << 15) - 1) - #error "MAX_RAW_THERMISTOR_VALUE is too large for int16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION." +// Currently Marlin stores all oversampled ADC values as uint16_t, make sure the HAL settings do not overflow 16 bit +#if (HAL_ADC_RANGE) * (OVERSAMPLENR) > 1 << 16 + #error "MAX_RAW_THERMISTOR_VALUE is too large for uint16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION." #endif +#define MAX_RAW_THERMISTOR_VALUE (uint16_t(HAL_ADC_RANGE) * (OVERSAMPLENR) - 1) -#define OV_SCALE(N) (N) -#define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) +#define OV_SCALE(N) float(N) +#define OV(N) raw_adc_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) -typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; +typedef struct { raw_adc_t value; celsius_t celsius; } temp_entry_t; // Pt1000 and Pt100 handling // @@ -78,6 +76,12 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(503) // Zonestar (Z8XM2) Heated Bed thermistor #include "thermistor_503.h" #endif +#if ANY_THERMISTOR_IS(504) // Zonestar (P802QR2 Hot End) thermistors + #include "thermistor_504.h" +#endif +#if ANY_THERMISTOR_IS(505) // Zonestar (P802QR2 Bed) thermistor + #include "thermistor_505.h" +#endif #if ANY_THERMISTOR_IS(512) // 100k thermistor in RPW-Ultra hotend, Pull-up = 4.7 kOhm, "unknown model" #include "thermistor_512.h" #endif @@ -150,6 +154,9 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(67) // R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor #include "thermistor_67.h" #endif +#if ANY_THERMISTOR_IS(68) // PT-100 with Dyze amplifier board + #include "thermistor_68.h" +#endif #if ANY_THERMISTOR_IS(12) // beta25 = 4700 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Personal calibration for Makibox hot bed" #include "thermistor_12.h" #endif @@ -283,13 +290,6 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #define TEMPTABLE_CHAMBER_LEN 0 #endif -#if TEMP_SENSOR_COOLER > 0 - #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER) - #define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER) -#else - #define TEMPTABLE_COOLER_LEN 0 -#endif - #if TEMP_SENSOR_PROBE > 0 #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE) #define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE) @@ -297,6 +297,13 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #define TEMPTABLE_PROBE_LEN 0 #endif +#if TEMP_SENSOR_COOLER > 0 + #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER) + #define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER) +#else + #define TEMPTABLE_COOLER_LEN 0 +#endif + #if TEMP_SENSOR_BOARD > 0 #define TEMPTABLE_BOARD TT_NAME(TEMP_SENSOR_BOARD) #define TEMPTABLE_BOARD_LEN COUNT(TEMPTABLE_BOARD) @@ -316,8 +323,8 @@ static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_ || 255 > TEMPTABLE_4_LEN || 255 > TEMPTABLE_5_LEN || 255 > TEMPTABLE_6_LEN || 255 > TEMPTABLE_7_LEN || 255 > TEMPTABLE_BED_LEN || 255 > TEMPTABLE_CHAMBER_LEN - || 255 > TEMPTABLE_COOLER_LEN || 255 > TEMPTABLE_PROBE_LEN + || 255 > TEMPTABLE_COOLER_LEN || 255 > TEMPTABLE_BOARD_LEN || 255 > TEMPTABLE_REDUNDANT_LEN , "Temperature conversion tables over 255 entries need special consideration." diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 285b4cba845f..f2767f2b5b85 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -89,7 +89,7 @@ #include "../feature/mmu/mmu2.h" #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../lcd/marlinui.h" #endif @@ -1027,7 +1027,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { DEBUG_ECHOLNPGM("No move (not homed)"); } - TERN_(HAS_LCD_MENU, if (!no_move) ui.update()); + TERN_(HAS_MARLINUI_MENU, if (!no_move) ui.update()); #if ENABLED(DUAL_X_CARRIAGE) const bool idex_full_control = dual_x_carriage_mode == DXC_FULL_CONTROL_MODE; diff --git a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h new file mode 100644 index 000000000000..68b8ed4ac800 --- /dev/null +++ b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h @@ -0,0 +1,212 @@ +/** + * 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 + +/** + * MRR ESPE pin assignments + * MRR ESPE is a 3D printer control board based on the ESP32 microcontroller. + * Supports 5 stepper drivers (using I2S stepper stream), heated bed, + * single hotend, and LCD controller. + */ + +#include "env_validate.h" + +#if EXTRUDERS > 2 || E_STEPPERS > 2 + #error "MKS ESP Nano only supports two E Steppers. Comment out this line to continue." +#elif HOTENDS > 2 + #error "MKS ESP Nano only supports two hotend / E-stepper. Comment out this line to continue." +#endif + +#define BOARD_INFO_NAME "MKS TinyBee" +#define BOARD_WEBSITE_URL "https://github.com/makerbase-mks" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Servos +// +#define SERVO0_PIN 2 + +// +// Limit Switches +// +#define X_STOP_PIN 33 +#define Y_STOP_PIN 32 +#define Z_STOP_PIN 22 +//#define FIL_RUNOUT_PIN 35 + +// +// Enable I2S stepper stream +// +#define I2S_STEPPER_STREAM +#if ENABLED(I2S_STEPPER_STREAM) + #define I2S_WS 26 + #define I2S_BCK 25 + #define I2S_DATA 27 + #if ENABLED(LIN_ADVANCE) + #error "I2S stream is currently incompatible with LIN_ADVANCE." + #endif +#endif + +// +// Steppers +// +#define X_STEP_PIN 129 +#define X_DIR_PIN 130 +#define X_ENABLE_PIN 128 + +#define Y_STEP_PIN 132 +#define Y_DIR_PIN 133 +#define Y_ENABLE_PIN 131 + +#define Z_STEP_PIN 135 +#define Z_DIR_PIN 136 +#define Z_ENABLE_PIN 134 + +#define E0_STEP_PIN 138 +#define E0_DIR_PIN 139 +#define E0_ENABLE_PIN 137 + +#define E1_STEP_PIN 141 +#define E1_DIR_PIN 142 +#define E1_ENABLE_PIN 140 + +#define Z2_STEP_PIN 141 +#define Z2_DIR_PIN 142 +#define Z2_ENABLE_PIN 140 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 36 // Analog Input +#define TEMP_1_PIN 34 // Analog Input, you need set R6=0Ω and R7=NC +#define TEMP_BED_PIN 39 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 145 +#define HEATER_1_PIN 146 +#define FAN_PIN 147 +#define FAN1_PIN 148 +#define HEATER_BED_PIN 144 + +//#define CONTROLLER_FAN_PIN 148 +//#define E0_AUTO_FAN_PIN 148 // need to update Configuration_adv.h @section extruder +//#define E1_AUTO_FAN_PIN 149 // need to update Configuration_adv.h @section extruder + +// +// ADC Reference Voltage +// +#define ADC_REFERENCE_VOLTAGE 2.5 // 2.5V reference VDDA + +// +// MicroSD card +// +#define SD_MOSI_PIN 23 +#define SD_MISO_PIN 19 +#define SD_SCK_PIN 18 +#define SDSS 5 +#define SD_DETECT_PIN 34 // IO34 default is SD_DET signal (Jump to SDDET) +#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers + +/** + * ------ ------ + * (BEEPER) 149 |10 9 | 13 (BTN_ENC) (SPI MISO) 19 |10 9 | 18 (SPI SCK) + * (LCD_EN) 21 | 8 7 | 4 (LCD_RS) (BTN_EN1) 14 | 8 7 | 5 (SPI CS) + * (LCD_D4) 0 6 5 | 16 (LCD_D5) (BTN_EN2) 12 6 5 | 23 (SPI MOSI) + * (LCD_D6) 15 | 4 3 | 17 (LCD_D7) (SPI_DET) 34 | 4 3 | RESET + * GND | 2 1 | 5V GND | 2 1 | 3.3V + * ------ ------ + * EXP1 EXP2 + */ + +#define EXP1_03_PIN 17 +#define EXP1_04_PIN 15 +#define EXP1_05_PIN 16 +#define EXP1_06_PIN 0 +#define EXP1_07_PIN 4 +#define EXP1_08_PIN 21 +#define EXP1_09_PIN 13 +#define EXP1_10_PIN 149 + +#define EXP2_03_PIN -1 // RESET +#define EXP2_04_PIN 34 +#define EXP2_05_PIN 23 +#define EXP2_06_PIN 12 +#define EXP2_07_PIN 5 +#define EXP2_08_PIN 14 +#define EXP2_09_PIN 18 +#define EXP2_10_PIN 19 + +#if HAS_WIRED_LCD + + #define BEEPER_PIN 149 + #define BTN_ENC 13 + #define LCD_PINS_ENABLE 21 + #define LCD_PINS_RS 4 + #define BTN_EN1 14 + #define BTN_EN2 12 + #define LCD_BACKLIGHT_PIN -1 + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 + #define DOGLCD_A0 15 + #define DOGLCD_CS 16 + //#define DOGLCD_SCK 19 + //#define DOGLCD_MOSI 23 + + // Required for MKS_MINI_12864 with this board + //#define MKS_LCD12864B + + #elif ENABLED(MKS_MINI_12864_V3) + + #define LCD_PINS_DC EXP1_07_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 LCD_PINS_DC + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_06_PIN + #define NEOPIXEL_PIN EXP1_05_PIN + #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_SCK EXP2_09_PIN + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 0 + #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #define LCD_PINS_D5 16 + #define LCD_PINS_D6 15 + #define LCD_PINS_D7 17 + #endif + + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 600 + + #endif // !MKS_MINI_12864 + +#endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPE.h b/Marlin/src/pins/esp32/pins_MRR_ESPE.h index 60c8405dfe2d..9b9b54e3aebe 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPE.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPE.h @@ -55,7 +55,9 @@ #define I2S_WS 26 #define I2S_BCK 25 #define I2S_DATA 27 -#undef LIN_ADVANCE // Currently, I2S stream does not work with linear advance +#if ENABLED(LIN_ADVANCE) + #error "I2S stream is currently incompatible with LIN_ADVANCE." +#endif // // Steppers diff --git a/Marlin/src/pins/esp32/pins_PANDA_common.h b/Marlin/src/pins/esp32/pins_PANDA_common.h index 81862fbd553c..7deeca3f6227 100644 --- a/Marlin/src/pins/esp32/pins_PANDA_common.h +++ b/Marlin/src/pins/esp32/pins_PANDA_common.h @@ -62,6 +62,13 @@ #define TEMP_0_PIN 39 // Analog Input #define TEMP_BED_PIN 36 // Analog Input +#if ENABLED(MAX31856_PANDAPI) + #define MAX31856_CLK_PIN 29 + #define MAX31856_MISO_PIN 24 + #define MAX31856_MOSI_PIN 28 + #define MAX31856_CS_PIN 27 +#endif + // // Heaters / Fans // @@ -74,25 +81,48 @@ #define E0_AUTO_FAN_PIN 120 // FAN2 #endif +/** ------ ------ + * (MISO 19?) |10 9 | (18 SCK?) (BEEPER) 129 |10 9 | 12 (^ENC) + * (EN1) 33 | 8 7 | (5 SDSS?) (EN) 26 | 8 7 | 27 (RS) + * (EN2) 32 6 5 | (23 MOSI?) (D4) 14 | 6 5 -- + * (SDDET 2?) | 4 3 | (RESET) -- | 4 3 | -- + * -- | 2 1 | -- (GND) | 2 1 | (5V) + * ------ ------ + * EXP2 EXP1 + */ +#define EXP1_06_PIN 14 +#define EXP1_07_PIN 27 +#define EXP1_08_PIN 26 +#define EXP1_09_PIN 12 +#define EXP1_10_PIN 129 + +#define EXP2_04_PIN 2 // ? +#define EXP2_05_PIN 23 // ? +#define EXP2_06_PIN 32 +#define EXP2_07_PIN 5 // ? +#define EXP2_08_PIN 33 +#define EXP2_09_PIN 18 // ? +#define EXP2_10_PIN 19 // ? + // -// SD card +// SD Card // #if ENABLED(SDSUPPORT) - #define SD_MOSI_PIN 23 - #define SD_MISO_PIN 19 - #define SD_SCK_PIN 18 - #define SDSS 5 - #define SD_DETECT_PIN 2 + #define SD_MOSI_PIN EXP2_05_PIN + #define SD_MISO_PIN EXP2_10_PIN + #define SD_SCK_PIN EXP2_09_PIN + #define SDSS EXP2_07_PIN + #define SD_DETECT_PIN EXP2_04_PIN #endif #if HAS_WIRED_LCD - #define BEEPER_PIN 129 - #define BTN_ENC 12 + #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 33 - #define BTN_EN2 32 + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN - #define LCD_PINS_RS 27 - #define LCD_PINS_ENABLE 26 - #define LCD_PINS_D4 14 + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #endif diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 20bd5ef8cca7..e2efdfa4929b 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -234,14 +234,16 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 40 // Z_CS_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 42 // E0_CS_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 44 // E1_CS_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 40 // Z_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 42 // E0_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 44 // E1_CS_PIN + #endif #endif /** @@ -391,6 +393,7 @@ #define BEEPER_PIN 42 #define TOUCH_CS_PIN 33 + #define SD_DETECT_PIN 41 #define HAS_SPI_FLASH 1 @@ -407,17 +410,47 @@ #ifndef TFT_DRIVER #define TFT_DRIVER ST7796 #endif - #ifndef XPT2046_X_CALIBRATION - #define XPT2046_X_CALIBRATION 63934 - #endif - #ifndef XPT2046_Y_CALIBRATION - #define XPT2046_Y_CALIBRATION 63598 - #endif - #ifndef XPT2046_X_OFFSET - #define XPT2046_X_OFFSET -1 - #endif - #ifndef XPT2046_Y_OFFSET - #define XPT2046_Y_OFFSET -20 + #ifndef TOUCH_SCREEN_CALIBRATION + #if ENABLED(TFT_RES_320x240) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 20525 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 15335 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X -1 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 0 + #endif + #elif ENABLED(TFT_RES_480x272) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 30715 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 17415 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 0 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -1 + #endif + #elif ENABLED(TFT_RES_480x320) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 30595 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 20415 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 2 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 1 + #endif + #endif #endif #define BTN_BACK 70 @@ -553,7 +586,6 @@ #define DOGLCD_CS 45 #define DOGLCD_A0 44 - #define LCD_SCREEN_ROT_180 #define BEEPER_PIN 33 #define STAT_LED_RED_PIN 32 @@ -566,6 +598,8 @@ #define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board #define KILL_PIN 31 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #define DOGLCD_CS 29 @@ -587,12 +621,6 @@ #define DOGLCD_A0 27 #define DOGLCD_CS 25 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - #define BEEPER_PIN 37 // not connected to a pin #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 @@ -604,6 +632,8 @@ #define SD_DETECT_PIN 49 #define KILL_PIN 64 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(MINIPANEL) #define BEEPER_PIN 42 @@ -613,12 +643,6 @@ #define DOGLCD_A0 44 #define DOGLCD_CS 66 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - #define BTN_EN1 40 #define BTN_EN2 63 #define BTN_ENC 59 @@ -626,6 +650,8 @@ #define SD_DETECT_PIN 49 #define KILL_PIN 64 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ZONESTAR_LCD) #define ADC_KEYPAD_PIN 12 diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h index 48b178dab5fe..f0f57c63eedc 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h @@ -60,9 +60,9 @@ /** ------ ------ * 1.30 |10 9 | 2.11 0.17 |10 9 | 0.15 * 0.18 | 8 7 | 0.16 3.26 | 8 7 | 1.23 - * 0.15 6 5 | NC 3.25 6 5 | 0.18 - * NC | 4 3 | NC 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * 0.15 6 5 | -- 3.25 6 5 | 0.18 + * -- | 4 3 | -- 1.31 | 4 3 | RESET + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ 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 97d78c0d2434..586fb14e8eb7 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -195,7 +195,7 @@ * (LCD_EN) 1.18 | 8 7 | 1.19 (LCD_RS) (BTN_EN1) 3.26 | 8 7 | 0.16 (SD_SS) * (LCD_D4) 1.20 6 5 | 1.21 (LCD_D5) (BTN_EN2) 3.25 6 5 | 0.18 (MOSI) * (LCD_D6) 1.22 | 4 3 | 1.23 (LCD_D7) (SD_DETECT) 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -237,11 +237,11 @@ * * BEFORE AFTER * ------ ------ - * GND 1 | 1 2 | 2 5V 5V 1 | 1 2 | 2 GND - * CS 3 | 3 4 | 4 BTN_EN2 CS 3 | 3 4 | 4 BTN_EN2 - * SID 5 | 5 6 6 BTN_EN1 SID 5 | 5 6 6 BTN_EN1 - * open 7 | 7 8 | 8 BTN_ENC CLK 7 | 7 8 | 8 BTN_ENC - * CLK 9 | 9 10 | 10 Beeper open 9 | 9 10 | 10 Beeper + * (CLK) |10 9 | (BEEPER) (BEEPER) |10 9 | -- + * -- | 8 7 | (BTN_ENC) (BTN_ENC) | 8 7 | (CLK) + * (SID) 6 5 | (BTN_EN1) (BTN_EN1) 6 5 | (SID) + * (CS) | 4 3 | (BTN_EN2) (BTN_EN2) | 4 3 | (CS) + * GND | 2 1 | 5V GND | 2 1 | 5V * ------ ------ * LCD LCD */ @@ -270,11 +270,11 @@ * * BEFORE AFTER * ______ ______ - * GND | 1 2 | 5V 5V | 1 2 | GND - * CS | 3 4 | BTN_EN2 CS | 3 4 | BTN_EN2 - * SID | 5 6 BTN_EN1 SID | 5 6 BTN_EN1 - * SCK | 7 8 | BTN_ENC SCK | 7 8 | BTN_ENC - * MOSI | 9 10 | open | 9 10 | MOSI + * |10 9 | (MOSI) (MOSI) |10 9 | -- + * (BTN_ENC) | 8 7 | (SCK) (BTN_ENC) | 8 7 | (SCK) + * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 2 1 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ @@ -424,13 +424,13 @@ /** * Creality Ender-2 display pinout - * ----- - * 5V | 1 2 | GND - * (MOSI) P1_23 | 3 4 | P1_22 (LCD_CS) - * (LCD_A0) P1_21 | 5 6 P1_20 (BTN_EN2) - * (RESET) P1_19 | 7 8 | P1_18 (BTN_EN1) - * (BTN_ENC) P0_28 | 9 10| P1_30 (SCK) - * ----- + * ------ + * (SCK) P1_30 |10 9 | P0_28 (BTN_ENC) + * (BTN_EN1) P1_18 | 8 7 | P1_19 (RESET) + * (BTN_EN2) P1_20 6 5 | P1_21 (LCD_A0) + * (LCD_CS) P1_22 | 4 3 | P1_23 (MOSI) + * GND | 2 1 | 5V + * ------ * EXP1 */ 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 b9dc845c5b77..df6ae8c01721 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -250,7 +250,7 @@ * 1.18 | 8 7 | 1.19 3.26 | 8 7 | 0.16 * 1.20 6 5 | 1.21 3.25 6 5 | 0.18 * 1.22 | 4 3 | 1.23 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -272,7 +272,7 @@ #define EXP2_09_PIN P0_15 #define EXP2_10_PIN P0_17 -#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI // RET6 DWIN ENCODER LCD #define BTN_ENC EXP1_06_PIN @@ -298,11 +298,11 @@ * * BEFORE AFTER * ------ ------ - * GND | 1 2 | 5V 5V | 1 2 | GND - * CS | 3 4 | BTN_EN2 CS | 3 4 | BTN_EN2 - * SID | 5 6 BTN_EN1 SID | 5 6 BTN_EN1 - * open | 7 8 | BTN_ENC open | 7 8 | BTN_ENC - * CLK | 9 10| BEEPER CLK | 9 10| BEEPER + * (BEEPER) | 10 9 | (CLK) (BEEPER) | 10 9 | (CLK) + * (BTN_ENC) | 8 7 | -- (BTN_ENC) | 8 7 | -- + * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 2 1 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ @@ -330,15 +330,15 @@ * * The ANET_FULL_GRAPHICS_LCD connector plug: * - * BEFORE AFTER - * ------ ------ - * GND | 1 2 | 5V 5V | 1 2 | GND - * CS | 3 4 | BTN_EN2 CS | 3 4 | BTN_EN2 - * SID | 5 6 BTN_EN1 SID | 5 6 BTN_EN1 - * open | 7 8 | BTN_ENC CLK | 7 8 | BTN_ENC - * CLK | 9 10 | BEEPER open | 9 10 | BEEPER - * ------ ------ - * LCD LCD + * BEFORE AFTER + * ------ ------ + * (BEEPER) |10 9 | (CLK) (BEEPER) |10 9 | -- + * (BTN_ENC) | 8 7 | -- (BTN_ENC) | 8 7 | (CLK) + * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 2 1 | GND GND | 2 1 | 5V + * ------ ------ + * LCD LCD */ #define LCD_PINS_RS EXP1_03_PIN @@ -366,11 +366,11 @@ /** Creality Ender-2 display pinout * ------ - * 5V | 1 2 | GND - * (MOSI) 1.23 | 3 4 | 1.22 (LCD_RS) - * (LCD_A0) 1.21 | 5 6 1.20 (BTN_EN2) - * RESET 1.19 | 7 8 | 1.18 (BTN_EN1) - * (BTN_ENC) 0.28 | 9 10 | 1.30 (SCK) + * (SCK) 1.30 |10 9 | 0.28 (BTN_ENC) + * (BTN_EN1) 1.18 | 8 7 | 1.19 (RESET) + * (BTN_EN2) 1.20 6 5 | 1.21 (LCD_A0) + * (LCD_RS) 1.22 | 4 3 | 1.23 (MOSI) + * GND | 2 1 | 5V * ------ * EXP1 */ diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index 52f34ed0f0d5..37d0cb7fb1e0 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -150,14 +150,15 @@ #endif #if ENABLED(BTT_MOTOR_EXPANSION) - /** ------ ------ - * NC | 1 2 | GND NC | 1 2 | GND - * NC | 3 4 | M1EN M2EN | 3 4 | M3EN - * M1STP | 5 6 M1DIR M1RX | 5 6 M1DIAG - * M2DIR | 7 8 | M2STP M2RX | 7 8 | M2DIAG - * M3DIR | 9 10 | M3STP M3RX | 9 10 | M3DIAG - * ------ ------ - * EXP2 EXP1 + /** + * ------ ------ + * (M3STP) |10 9 | (M3DIR) (M3DIAG) |10 9 | (M3RX) + * (M2STP) | 8 7 | (M2DIR) (M2DIAG) | 8 7 | (M2RX) + * (M1DIR) 6 5 | (M1STP) (M1DIAG) 6 5 | (M1RX) + * (M1EN) | 4 3 | -- (M3EN) | 4 3 | (M2EN) + * GND | 2 1 | -- GND | 2 1 | -- + * ------ ------ + * EXP2 EXP1 * * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN */ diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index 406e65d2954d..7f9e530f3c72 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -278,11 +278,7 @@ #endif #elif ENABLED(MINIPANEL) - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index 15afe7e23837..95bbe17b9b38 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -233,9 +233,9 @@ /** ------ ------ * (BEEPER) 1.31 |10 9 | 1.30 (BTN_ENC) (MISO) 0.8 |10 9 | 0.7 (SD_SCK) * (LCD_EN) 0.18 | 8 7 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 8 7 | 0.28 (SD_CS2) - * (LCD_D4) 0.15 | 6 5 0.17 (LCD_D5) (BTN_EN2) 3.26 | 6 5 0.9 (SD_MOSI) + * (LCD_D4) 0.15 6 5 | 0.17 (LCD_D5) (BTN_EN2) 3.26 6 5 | 0.9 (SD_MOSI) * (LCD_D6) 1.0 | 4 3 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 934b74cbb160..b08ac536b3d0 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -228,7 +228,7 @@ #define PS_ON_PIN P2_12 // (12) -#if !defined(TEMP_0_CS_PIN) && DISABLED(USE_ZMAX_PLUG) +#if !defined(TEMP_0_CS_PIN) && !(HAS_Z_AXIS && Z_HOME_DIR) #define TEMP_0_CS_PIN P1_28 #endif @@ -258,11 +258,13 @@ // // Průša i3 MK2 Multiplexer Support // -#if SERIAL_PORT != 0 && SERIAL_PORT_2 != 0 - #define E_MUX0_PIN P0_03 // ( 0) Z_CS_PIN - #define E_MUX1_PIN P0_02 // ( 1) E0_CS_PIN +#if HAS_PRUSA_MMU1 + #if SERIAL_PORT != 0 && SERIAL_PORT_2 != 0 + #define E_MUX0_PIN P0_03 // ( 0) Z_CS_PIN + #define E_MUX1_PIN P0_02 // ( 1) E0_CS_PIN + #endif + #define E_MUX2_PIN P0_26 // (63) E1_CS_PIN #endif -#define E_MUX2_PIN P0_26 // (63) E1_CS_PIN /** * LCD / Controller @@ -348,8 +350,6 @@ #endif #if ANY(VIKI2, miniVIKI) - //#define LCD_SCREEN_ROT_180 - #define DOGLCD_CS P0_16 // (16) #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 #define DOGLCD_SCK SD_SCK_PIN @@ -358,6 +358,8 @@ #define STAT_LED_BLUE_PIN P0_26 // (63) may change if cable changes #define STAT_LED_RED_PIN P1_21 // ( 6) may change if cable changes + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else #if ENABLED(FYSETC_MINI_12864) @@ -406,11 +408,7 @@ #endif #if ENABLED(MINIPANEL) - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index f3ecebde4674..4fbc19eed843 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -155,8 +155,6 @@ #endif #if ANY(VIKI2, miniVIKI) - //#define LCD_SCREEN_ROT_180 - #define BEEPER_PIN P1_30 // (37) may change if cable changes #define DOGLCD_CS P0_26 // (63) J5-3 & AUX-2 #define DOGLCD_SCK SD_SCK_PIN @@ -164,6 +162,8 @@ #define STAT_LED_BLUE_PIN P0_26 // (63) may change if cable changes #define STAT_LED_RED_PIN P1_21 // ( 6) may change if cable changes + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else #if IS_ULTIPANEL #define LCD_PINS_D5 P1_17 // (71) ENET_MDIO @@ -180,11 +180,7 @@ #endif #if ENABLED(MINIPANEL) - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif #endif 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 bdc49fc23648..56ee7fa73235 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -186,11 +186,11 @@ /** * ------ - * 5V | 1 2 | GND - * (LCD_EN) P0_18 | 3 4 | P0_17 (LCD_RS) - * (LCD_D4) P0_15 | 5 6 P0_20 (BTN_EN2) - * RESET | 7 8 | P0_19 (BTN_EN1) - * (BTN_ENC) P0_16 | 9 10 | P2_08 (BEEPER) + * (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) + * (BTN_EN1) P0_19 | 8 7 | RESET + * (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) + * (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) + * GND | 2 1 | 5V * ------ * EXP */ @@ -203,17 +203,17 @@ #define EXP1_09_PIN P0_16 #define EXP1_10_PIN P2_08 -#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI #error "Ender-3 V2 display requires a custom cable with TX = P0_15, RX = P0_16. Comment out this line to continue." /** * Ender 3 V2 display SKR E3 Turbo (EXP1) Ender 3 V2 display --> SKR E3 Turbo * ------ ------ RX 8 --> 5 P0_15 - * 5V | 1 2 | GND 5V | 1 2 | GND TX 7 --> 9 P0_16 - * (BTN_E1) A | 3 4 | B (BTN_E2) (LCD_EN) P0_18 | 3 4 | P0_17 (LCD_RS) BEEPER 5 --> 10 P2_08 - * BEEPER | 5 6 ENT (BTN_ENC) (LCD_D4) P0_15 | 5 6 P0_20 (BTN_EN2) - * (SKR_RX1) TX | 7 8 | RX (SKR_TX1) Reset | 7 8 | P0_19 (BTN_EN1) - * NC | 9 10 | NC (BTN_ENC) P0_16 | 9 10 | P2_08 (BEEPER) + * -- |10 9 | -- (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) TX 7 --> 9 P0_16 + * (SKR_TX1) RX | 8 7 | TX (SKR_RX1) (BTN_EN1) P0_19 | 8 7 | RESET BEEPER 5 --> 10 P2_08 + * (BTN_ENC) ENT 6 5 | BEEPER (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) + * (BTN_E2) B | 4 3 | A (BTN_E1) (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) + * GND | 2 1 | 5V GND | 2 1 | 5V * ------ ------ */ 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 8107f11937cd..7edfb9196fa2 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -260,9 +260,9 @@ /** ------ ------ * (BEEPER) 1.31 |10 9 | 1.30 (BTN_ENC) (MISO) 0.8 |10 9 | 0.7 (SD_SCK) * (LCD_EN) 0.18 | 8 7 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 8 7 | 0.28 (SD_CS2) - * (LCD_D4) 0.15 | 6 5 | 0.17 (LCD_D5) (BTN_EN2) 3.26 | 6 5 | 0.9 (SD_MOSI) + * (LCD_D4) 0.15 6 5 | 0.17 (LCD_D5) (BTN_EN2) 3.26 6 5 | 0.9 (SD_MOSI) * (LCD_D6) 1.0 | 4 3 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 4 3 | RST - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h index dc7dcd6db609..81c7dc9403db 100644 --- a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h @@ -157,11 +157,11 @@ /** * ------ - * 5V | 1 2 | GND - * P0_18 | 3 4 | P0_16 - * P0_15 | 5 6 P3_25 - * P2_11 | 7 8 | P3_26 - * P1_30 | 9 10 | P1_31 + * P1_31 |10 9 | P1_30 + * P3_26 | 8 7 | P2_11 + * P3_25 6 5 | P0_15 + * P0_16 | 4 3 | P0_18 + * GND | 2 1 | 5V * ------ * EXP1 * @@ -182,11 +182,11 @@ #if ENABLED(CR10_STOCKDISPLAY) /** ------ - * 5V | 1 2 | GND - * LCD_EN | 3 4 | LCD_RS - * LCD_D4 | 5 6 EN2 - * KILL | 7 8 | EN1 - * ENC | 9 10 | BEEPER + * BEEPER |10 9 | ENC + * EN1 | 8 7 | KILL + * EN2 6 5 | LCD_D4 + * LCD_RS | 4 3 | LCD_EN + * GND | 2 1 | 5V * ------ */ #define BEEPER_PIN EXP1_10_PIN @@ -197,11 +197,11 @@ #elif ENABLED(MKS_MINI_12864) /** ------ - * 5V | 1 2 | GND - * SPI-MOSI | 3 4 | SPI-CS - * A0 | 5 6 EN2 - * -- | 7 8 | EN1 - * ENC | 9 10 | SPI-SCK + * SCK |10 9 | ENC + * EN1 | 8 7 | -- + * EN2 6 5 | A0 + * CS | 4 3 | MOSI + * GND | 2 1 | 5V * ------ */ #define DOGLCD_CS EXP1_04_PIN diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_12.h b/Marlin/src/pins/mega/pins_CNCONTROLS_12.h index f1200e09018a..137650eeed58 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_12.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_12.h @@ -147,7 +147,6 @@ #define DOGLCD_CS 35 #define DOGLCD_MOSI 48 #define DOGLCD_SCK 49 -#define LCD_SCREEN_ROT_180 // The encoder and click button #define BTN_EN1 36 @@ -164,3 +163,5 @@ #define STAT_LED_BLUE_PIN -1 #define STAT_LED_RED_PIN 10 // TOOL_0_PWM_PIN + +#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_A.h b/Marlin/src/pins/mega/pins_GT2560_REV_A.h index 1adf8d3079f4..ecd341984b6f 100644 --- a/Marlin/src/pins/mega/pins_GT2560_REV_A.h +++ b/Marlin/src/pins/mega/pins_GT2560_REV_A.h @@ -127,7 +127,7 @@ #define LCD_RESET_PIN 16 - #define DEFAULT_LCD_CONTRAST 220 + #define LCD_CONTRAST_DEFAULT 220 #define LCD_BACKLIGHT_PIN -1 #else diff --git a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h index dcf25da070ff..5c3b1dc9f6d6 100644 --- a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h +++ b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h @@ -112,7 +112,7 @@ // // M3/M4/M5 - Spindle/Laser Control // -#if EITHER(SPINDLE_FEATURE, LASER_FEATURE) +#if HAS_CUTTER #define SPINDLE_DIR_PIN 16 #define SPINDLE_LASER_ENA_PIN 17 // Pin should have a pullup! #define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM @@ -134,7 +134,7 @@ #if ENABLED(HJC_LCD_SMART_CONTROLLER) #define LCD_BACKLIGHT_PIN 5 // LCD_Backlight //#ifndef LCD_CONTRAST_PIN - // #define LCD_CONTRAST_PIN 5 // LCD_Contrast + // #define LCD_CONTRAST_PIN 5 // LCD_Contrast //#endif #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 24 // Filament runout diff --git a/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h b/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h index af5cfd6a2eef..4a32472949a3 100644 --- a/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h +++ b/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h @@ -84,7 +84,7 @@ #define E1_ENABLE_PIN 33 // -// Filament runout +// Filament Runout Sensor // #define FIL_RUNOUT_PIN 42 // ROT2 Connector #define FIL_RUNOUT2_PIN 44 // ROT1 Connector diff --git a/Marlin/src/pins/mega/pins_MEGACONTROLLER.h b/Marlin/src/pins/mega/pins_MEGACONTROLLER.h index 69c60b29ec54..dc9fa52af8e6 100644 --- a/Marlin/src/pins/mega/pins_MEGACONTROLLER.h +++ b/Marlin/src/pins/mega/pins_MEGACONTROLLER.h @@ -121,7 +121,7 @@ #define CONTROLLER_FAN_PIN FAN2_PIN #endif -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Misc. Functions @@ -139,17 +139,12 @@ #if ENABLED(MINIPANEL) #define BEEPER_PIN 46 - // Pins for DOGM SPI LCD Support + #define DOGLCD_A0 47 #define DOGLCD_CS 45 #define LCD_BACKLIGHT_PIN 44 // backlight LED on PA3 #define KILL_PIN 12 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 #define BTN_EN1 48 #define BTN_EN2 11 @@ -157,6 +152,8 @@ #define SD_DETECT_PIN 49 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #endif // MINIPANEL // diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index d5122e46a9b3..f2a95baf011b 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -69,7 +69,7 @@ #endif // -// Filament Runout Pins +// Filament Runout Sensor // #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 49 @@ -144,56 +144,41 @@ //#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // -// Augmentation for auto-assigning plugs -// -// Two thermocouple connectors allows for either -// 2 extruders or 1 extruder and a heated bed. -// With no heated bed, an additional 24V fan is possible. +// FET Pin Mapping - FET 1 is closest to the input power connector // -#define MOSFET_A_PIN 6 // H3 EX1_HEAT_PIN -#define MOSFET_B_PIN 11 // B5 EX2_HEAT_PIN -#define MOSFET_C_PIN 45 // L4 HBP_PIN -#define MOSFET_D_PIN 44 // L5 EXTRA_FET_PIN +#define MOSFET_1_PIN 6 // Plug EX1 Pin 1-2 -> PH3 #15 -> Logical 06 +#define MOSFET_2_PIN 7 // Plug EX1 Pin 3-4 -> PH4 #16 -> Logical 07 +#define MOSFET_3_PIN 12 // Plug EX2 1-2 -> PB5 #25 -> Logical 12 +#define MOSFET_4_PIN 11 // Plug EX2 3-4 -> PB6 #24 -> Logical 11 +#define MOSFET_5_PIN 45 // Plug HBD 1-2 -> PL4 #39 -> Logical 45 +#define MOSFET_6_PIN 13 // Plug Extra 1-2 -> PL5 #40 -> Logical 44 (FET not soldered in all boards) // // Heaters / Fans (24V) // -#define HEATER_0_PIN MOSFET_A_PIN - -#if FET_ORDER_EFB // Hotend, Fan, Bed - #define HEATER_BED_PIN MOSFET_C_PIN -#elif FET_ORDER_EEF // Hotend, Hotend, Fan - #define HEATER_1_PIN MOSFET_B_PIN -#elif FET_ORDER_EEB // Hotend, Hotend, Bed - #define HEATER_1_PIN MOSFET_B_PIN - #define HEATER_BED_PIN MOSFET_C_PIN -#elif FET_ORDER_EFF // Hotend, Fan, Fan - #define FAN1_PIN MOSFET_C_PIN -#endif -#ifndef FAN_PIN - #if EITHER(FET_ORDER_EFB, FET_ORDER_EFF) // Hotend, Fan, Bed or Hotend, Fan, Fan - #define FAN_PIN MOSFET_B_PIN - #elif EITHER(FET_ORDER_EEF, FET_ORDER_SF) // Hotend, Hotend, Fan or Spindle, Fan - #define FAN_PIN MOSFET_C_PIN - #else - #define FAN_PIN MOSFET_D_PIN - #endif -#endif +#define HEATER_0_PIN MOSFET_1_PIN // EX1 +#define HEATER_1_PIN MOSFET_3_PIN // EX2 +#define HEATER_BED_PIN MOSFET_5_PIN // HBP -#ifndef FAN1_PIN - #define FAN1_PIN 7 // H4 EX1_FAN_PIN +// EX1 FAN (Automatic Fans are disabled by default in Configuration_adv.h - comment that out for auto fans) +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN MOSFET_2_PIN +#else + #define FAN_PIN MOSFET_2_PIN #endif - -#ifndef CONTROLLER_FAN_PIN - #define CONTROLLER_FAN_PIN 12 // B6 EX2_FAN_PIN +// EX2 FAN (Automatic Fans are disabled by default in Configuration_adv.h - comment that out for auto fans) +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN MOSFET_4_PIN +#else + #define FAN1_PIN MOSFET_4_PIN #endif // // Misc. Functions // -#define LED_PIN 13 // B7 +#define LED_PIN MOSFET_6_PIN // B7 #define CUTOFF_RESET_PIN 16 // H1 #define CUTOFF_TEST_PIN 17 // H0 #define CUTOFF_SR_CHECK_PIN 70 // G4 (TOSC1) diff --git a/Marlin/src/pins/mega/pins_OVERLORD.h b/Marlin/src/pins/mega/pins_OVERLORD.h index 0884d8ecb514..98f8da571940 100644 --- a/Marlin/src/pins/mega/pins_OVERLORD.h +++ b/Marlin/src/pins/mega/pins_OVERLORD.h @@ -49,7 +49,7 @@ #define Z_MIN_PROBE_PIN 46 // JP4, Tfeed1 #endif -#if ENABLED(FILAMENT_RUNOUT_SENSOR) +#ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 44 // JP3, Tfeed2 #endif diff --git a/Marlin/src/pins/mega/pins_PICA.h b/Marlin/src/pins/mega/pins_PICA.h index 47c101711c4f..0e29d8dffe75 100644 --- a/Marlin/src/pins/mega/pins_PICA.h +++ b/Marlin/src/pins/mega/pins_PICA.h @@ -51,6 +51,7 @@ #define SERVO0_PIN 3 #define SERVO1_PIN 4 #define SERVO2_PIN 5 + // // Limit Switches // diff --git a/Marlin/src/pins/mega/pins_WEEDO_62A.h b/Marlin/src/pins/mega/pins_WEEDO_62A.h new file mode 100644 index 000000000000..4b3bf6a43bee --- /dev/null +++ b/Marlin/src/pins/mega/pins_WEEDO_62A.h @@ -0,0 +1,106 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Based on WEEDO 62A pin configuration + * Copyright (c) 2019 WEEDO3D Perron + */ + +#pragma once + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "WEEDO 62A" +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 40 +#define Y_MAX_PIN 41 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Steppers +// +#define X_STEP_PIN 26 +#define X_DIR_PIN 28 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 + +#define E0_STEP_PIN 54 +#define E0_DIR_PIN 55 +#define E0_ENABLE_PIN 38 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // ANALOG NUMBERING +#define TEMP_BED_PIN 14 // ANALOG NUMBERING + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 // EXTRUDER 1 +#define HEATER_BED_PIN 8 // BED +#define FAN_PIN 4 // IO pin. Buffer needed + +// +// Misc. Functions +// +#define PS_ON_PIN 12 +#define LED_PIN 13 + +// +// SD Support +// +#if ENABLED(SDSUPPORT) + #define SDSS 53 + #define SD_DETECT_PIN 49 +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BEEPER_PIN 37 + + #define DOGLCD_A0 27 + #define DOGLCD_CS 29 + #define LCD_RESET_PIN 25 + #define LCD_CONTRAST_INIT 255 + + #define BTN_EN1 33 + #define BTN_EN2 31 + #define BTN_ENC 35 +#endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 57648b3e16fe..426ce1e48e77 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -37,24 +37,28 @@ #define MAX_E_STEPPERS 8 -#if MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB) - #define FET_ORDER_EFB 1 -#elif MB(RAMPS_13_EEB, RAMPS_14_EEB, RAMPS_PLUS_EEB, RAMPS_14_RE_ARM_EEB, RAMPS_SMART_EEB, RAMPS_DUO_EEB, RAMPS4DUE_EEB) - #define FET_ORDER_EEB 1 -#elif MB(RAMPS_13_EFF, RAMPS_14_EFF, RAMPS_PLUS_EFF, RAMPS_14_RE_ARM_EFF, RAMPS_SMART_EFF, RAMPS_DUO_EFF, RAMPS4DUE_EFF) - #define FET_ORDER_EFF 1 -#elif MB(RAMPS_13_EEF, RAMPS_14_EEF, RAMPS_PLUS_EEF, RAMPS_14_RE_ARM_EEF, RAMPS_SMART_EEF, RAMPS_DUO_EEF, RAMPS4DUE_EEF) - #define FET_ORDER_EEF 1 -#elif MB(RAMPS_13_SF, RAMPS_14_SF, RAMPS_PLUS_SF, RAMPS_14_RE_ARM_SF, RAMPS_SMART_SF, RAMPS_DUO_SF, RAMPS4DUE_SF) || EITHER(SPINDLE_FEATURE, LASER_FEATURE) - #define FET_ORDER_SF 1 -#elif HAS_MULTI_HOTEND && TEMP_SENSOR_BED - #define FET_ORDER_EEB 1 -#elif HAS_MULTI_HOTEND - #define FET_ORDER_EEF 1 -#elif TEMP_SENSOR_BED - #define FET_ORDER_EFB 1 -#else - #define FET_ORDER_EFF 1 +#if NONE(FET_ORDER_EEF, FET_ORDER_EEB, FET_ORDER_EFF, FET_ORDER_EFB, FET_ORDER_SF) + #if MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB) + #define FET_ORDER_EFB 1 + #elif MB(RAMPS_13_EEB, RAMPS_14_EEB, RAMPS_PLUS_EEB, RAMPS_14_RE_ARM_EEB, RAMPS_SMART_EEB, RAMPS_DUO_EEB, RAMPS4DUE_EEB) + #define FET_ORDER_EEB 1 + #elif MB(RAMPS_13_EFF, RAMPS_14_EFF, RAMPS_PLUS_EFF, RAMPS_14_RE_ARM_EFF, RAMPS_SMART_EFF, RAMPS_DUO_EFF, RAMPS4DUE_EFF) + #define FET_ORDER_EFF 1 + #elif MB(RAMPS_13_EEF, RAMPS_14_EEF, RAMPS_PLUS_EEF, RAMPS_14_RE_ARM_EEF, RAMPS_SMART_EEF, RAMPS_DUO_EEF, RAMPS4DUE_EEF) + #define FET_ORDER_EEF 1 + #elif MB(RAMPS_13_SF, RAMPS_14_SF, RAMPS_PLUS_SF, RAMPS_14_RE_ARM_SF, RAMPS_SMART_SF, RAMPS_DUO_SF, RAMPS4DUE_SF) + #define FET_ORDER_SF 1 + #elif HAS_MULTI_HOTEND || (HAS_EXTRUDERS && HAS_CUTTER) + #if TEMP_SENSOR_BED + #define FET_ORDER_EEB 1 + #else + #define FET_ORDER_EEF 1 + #endif + #elif TEMP_SENSOR_BED + #define FET_ORDER_EFB 1 + #else + #define FET_ORDER_EFF 1 + #endif #endif #if !(BOTH(IS_ULTRA_LCD, IS_NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, WYH_L12864, MINIPANEL, REPRAPWORLD_KEYPAD)) @@ -119,6 +123,8 @@ #include "ramps/pins_ZRIB_V20.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(ZRIB_V52) #include "ramps/pins_ZRIB_V52.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(ZRIB_V53) + #include "ramps/pins_ZRIB_V53.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(FELIX2) #include "ramps/pins_FELIX2.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(RIGIDBOARD) @@ -195,6 +201,8 @@ #include "ramps/pins_RAMPS_S_12.h" // ATmega2560 env:mega2560 #elif MB(LONGER3D_LK1_PRO, LONGER3D_LKx_PRO) #include "ramps/pins_LONGER3D_LKx_PRO.h" // ATmega2560 env:mega2560 +#elif MB(PXMALION_CORE_I3) + #include "ramps/pins_PXMALION_CORE_I3.h" // ATmega2560 env:mega2560 // // RAMBo and derivatives @@ -279,6 +287,8 @@ #include "mega/pins_MALYAN_M180.h" // ATmega2560 env:mega2560 #elif MB(PROTONEER_CNC_SHIELD_V3) #include "mega/pins_PROTONEER_CNC_SHIELD_V3.h"// ATmega2560 env:mega2560 +#elif MB(WEEDO_62A) + #include "mega/pins_WEEDO_62A.h" // ATmega2560 env:mega2560 // // ATmega1281, ATmega2561 @@ -527,6 +537,8 @@ #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_MINI_E3_V2_0) #include "stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple +#elif MB(BTT_SKR_MINI_E3_V3_0) + #include "stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h" // STM32G0 env:STM32G0B1RE_btt #elif MB(BTT_SKR_MINI_MZ_V1_0) #include "stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_E3_DIP) @@ -552,19 +564,25 @@ #elif MB(CHITU3D_V9) #include "stm32f1/pins_CHITU3D_V9.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple #elif MB(CREALITY_V4) - #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V4210) - #include "stm32f1/pins_CREALITY_V4210.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V4210.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V422) + #include "stm32f1/pins_CREALITY_V422.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V423) + #include "stm32f1/pins_CREALITY_V423.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer #elif MB(CREALITY_V427) - #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V431, CREALITY_V431_A, CREALITY_V431_B, CREALITY_V431_C, CREALITY_V431_D) - #include "stm32f1/pins_CREALITY_V431.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V431.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V452) - #include "stm32f1/pins_CREALITY_V452.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V452.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V453) - #include "stm32f1/pins_CREALITY_V453.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V453.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V24S1) - #include "stm32f1/pins_CREALITY_V24S1.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V24S1.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V24S1_301) + #include "stm32f1/pins_CREALITY_V24S1_301.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(TRIGORILLA_PRO) #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple #elif MB(FLY_MINI) @@ -583,6 +601,8 @@ #include "stm32f1/pins_ZM3E4_V2_0.h" // STM32F1 env:STM32F103VE_ZM3E4V2_USB env:STM32F103VE_ZM3E4V2_USB_maple #elif MB(ERYONE_ERY32_MINI) #include "stm32f1/pins_ERYONE_ERY32_MINI.h" // STM32F103VET6 env:ERYONE_ERY32_MINI_maple +#elif MB(PANDA_PI_V29) + #include "stm32f1/pins_PANDA_PI_V29.h" // STM32F103RCT6 env:PANDA_PI_V29 // // ARM Cortex-M4F @@ -622,7 +642,7 @@ #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 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 env:BIGTREE_SKR_2_USB_debug + #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 env:BIGTREE_SKR_2_F429 env:BIGTREE_SKR_2_F429_USB env:BIGTREE_SKR_2_F429_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) @@ -643,6 +663,8 @@ #include "stm32f4/pins_FYSETC_S6_V2_0.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 #elif MB(FYSETC_SPIDER) #include "stm32f4/pins_FYSETC_SPIDER.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 +#elif MB(FYSETC_SPIDER_V2_2) + #include "stm32f4/pins_FYSETC_SPIDER_V2_2.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 #elif MB(FLYF407ZG) #include "stm32f4/pins_FLYF407ZG.h" // STM32F4 env:FLYF407ZG #elif MB(MKS_ROBIN2) @@ -651,6 +673,8 @@ #include "stm32f4/pins_MKS_ROBIN_PRO_V2.h" // STM32F4 env:mks_robin_pro2 #elif MB(MKS_ROBIN_NANO_V3) #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3 env:mks_robin_nano_v3_usb_flash_drive env:mks_robin_nano_v3_usb_flash_drive_msc +#elif MB(MKS_ROBIN_NANO_V3_1) + #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3_1 env:mks_robin_nano_v3_1_usb_flash_drive env:mks_robin_nano_v3_1_usb_flash_drive_msc #elif MB(ANET_ET4) #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_OpenBLT #elif MB(ANET_ET4P) @@ -705,6 +729,8 @@ #include "esp32/pins_PANDA_ZHU.h" // ESP32 env:PANDA #elif MB(PANDA_M4) #include "esp32/pins_PANDA_M4.h" // ESP32 env:PANDA +#elif MB(MKS_TINYBEE) + #include "esp32/pins_MKS_TINYBEE.h" // ESP32 env:mks_tinybee // // Adafruit Grand Central M4 (SAMD51 ARM Cortex-M4) @@ -712,6 +738,10 @@ #elif MB(AGCM4_RAMPS_144) #include "samd/pins_RAMPS_144.h" // SAMD51 env:SAMD51_grandcentral_m4 +#elif MB(BRICOLEMON_V1_0) + #include "samd/pins_BRICOLEMON_V1_0.h" // SAMD51 env:SAMD51_grandcentral_m4 +#elif MB(BRICOLEMON_LITE_V1_0) + #include "samd/pins_BRICOLEMON_LITE_V1_0.h" // SAMD51 env:SAMD51_grandcentral_m4 // // Custom board (with custom PIO env) @@ -733,30 +763,30 @@ // Obsolete or unknown board // - #define BOARD_MKS_13 -1000 - #define BOARD_TRIGORILLA -1001 - #define BOARD_RURAMPS4D -1002 - #define BOARD_FORMBOT_TREX2 -1003 - #define BOARD_BIQU_SKR_V1_1 -1004 - #define BOARD_STM32F1R -1005 - #define BOARD_STM32F103R -1006 - #define BOARD_ESP32 -1007 - #define BOARD_STEVAL -1008 - #define BOARD_BIGTREE_SKR_V1_1 -1009 - #define BOARD_BIGTREE_SKR_V1_3 -1010 - #define BOARD_BIGTREE_SKR_V1_4 -1011 - #define BOARD_BIGTREE_SKR_V1_4_TURBO -1012 - #define BOARD_BIGTREE_BTT002_V1_0 -1013 - #define BOARD_BIGTREE_SKR_PRO_V1_1 -1014 - #define BOARD_BIGTREE_SKR_MINI_V1_1 -1015 - #define BOARD_BIGTREE_SKR_MINI_E3 -1016 - #define BOARD_BIGTREE_SKR_E3_DIP -1017 - #define BOARD_RUMBA32 -1018 - #define BOARD_RUMBA32_AUS3D -1019 - #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 + #define BOARD_MKS_13 99900 + #define BOARD_TRIGORILLA 99901 + #define BOARD_RURAMPS4D 99902 + #define BOARD_FORMBOT_TREX2 99903 + #define BOARD_BIQU_SKR_V1_1 99904 + #define BOARD_STM32F1R 99905 + #define BOARD_STM32F103R 99906 + #define BOARD_ESP32 99907 + #define BOARD_STEVAL 99908 + #define BOARD_BIGTREE_SKR_V1_1 99909 + #define BOARD_BIGTREE_SKR_V1_3 99910 + #define BOARD_BIGTREE_SKR_V1_4 99911 + #define BOARD_BIGTREE_SKR_V1_4_TURBO 99912 + #define BOARD_BIGTREE_BTT002_V1_0 99913 + #define BOARD_BIGTREE_SKR_PRO_V1_1 99914 + #define BOARD_BIGTREE_SKR_MINI_V1_1 99915 + #define BOARD_BIGTREE_SKR_MINI_E3 99916 + #define BOARD_BIGTREE_SKR_E3_DIP 99917 + #define BOARD_RUMBA32 99918 + #define BOARD_RUMBA32_AUS3D 99919 + #define BOARD_RAMPS_DAGOMA 99920 + #define BOARD_RAMPS_LONGER3D_LK4PRO 99921 + #define BOARD_BTT_SKR_V2_0 99922 + #define BOARD_TH3D_EZBOARD_LITE_V2 99923 #if MB(MKS_13) #error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration." diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index dc0d5225db32..2328a826ef7e 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -141,24 +141,24 @@ 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) #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(TEMP_COOLER) #if ANALOG_OK(TEMP_COOLER_PIN) 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) +#if PIN_EXISTS(TEMP_BOARD) + #if ANALOG_OK(TEMP_BOARD_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_BOARD_PIN) #endif #endif #if PIN_EXISTS(ADC_KEYPAD) @@ -1601,6 +1601,24 @@ #if PIN_EXISTS(Z4_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, Z4_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(E0_DIAG) REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) #endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index 1e6703fd4a3a..aabe0da85873 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -477,7 +477,7 @@ #endif #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #ifdef I_STOP_PIN #if I_HOME_TO_MIN #define I_MIN_PIN I_STOP_PIN @@ -500,7 +500,7 @@ #undef I_MAX_PIN #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #ifdef J_STOP_PIN #if J_HOME_TO_MIN #define J_MIN_PIN J_STOP_PIN @@ -523,7 +523,7 @@ #undef J_MAX_PIN #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #ifdef K_STOP_PIN #if K_HOME_TO_MIN #define K_MIN_PIN K_STOP_PIN @@ -548,12 +548,16 @@ // Filament Sensor first pin alias #if HAS_FILAMENT_SENSOR - #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN + #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN // Filament Sensor first pin alias #else #undef FIL_RUNOUT_PIN #undef FIL_RUNOUT1_PIN #endif +#if NUM_RUNOUT_SENSORS < 2 + #undef FIL_RUNOUT2_PIN +#endif + #ifndef LCD_PINS_D4 #define LCD_PINS_D4 -1 #endif @@ -595,12 +599,13 @@ #define X2_E_INDEX E_STEPPERS #endif -// The X2 axis, if any, should be the next open extruder port #if HAS_X2_STEPPER && !defined(X2_DIAG_PIN) && !defined(X2_STEP_PIN) && !PIN_EXISTS(X2_CS_PIN) #define Y2_E_INDEX INCREMENT(X2_E_INDEX) #else #define Y2_E_INDEX X2_E_INDEX #endif + +// The X2 axis, if any, should be the next open extruder port #if HAS_X2_STEPPER #ifndef X2_STEP_PIN #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP) @@ -683,12 +688,13 @@ #define X2_MS3_PIN -1 #endif -// The Y2 axis, if any, should be the next open extruder port #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && !defined(Y2_DIAG_PIN) && !defined(Y2_STEP_PIN) && !PIN_EXISTS(Y2_CS_PIN) #define Z2_E_INDEX INCREMENT(Y2_E_INDEX) #else #define Z2_E_INDEX Y2_E_INDEX #endif + +// The Y2 axis, if any, should be the next open extruder port #if ENABLED(Y_DUAL_STEPPER_DRIVERS) #ifndef Y2_STEP_PIN #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP) @@ -768,12 +774,13 @@ #define Y2_MS3_PIN -1 #endif -// The Z2 axis, if any, should be the next open extruder port #if NUM_Z_STEPPER_DRIVERS >= 2 && !defined(Z2_DIAG_PIN) && !defined(Z2_STEP_PIN) && !PIN_EXISTS(Z2_CS_PIN) #define Z3_E_INDEX INCREMENT(Z2_E_INDEX) #else #define Z3_E_INDEX Z2_E_INDEX #endif + +// The Z2 axis, if any, should be the next open extruder port #if NUM_Z_STEPPER_DRIVERS >= 2 #ifndef Z2_STEP_PIN #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP) @@ -853,12 +860,13 @@ #define Z2_MS3_PIN -1 #endif -// The Z3 axis, if any, should be the next open extruder port #if NUM_Z_STEPPER_DRIVERS >= 3 && !defined(Z3_DIAG_PIN) && !defined(Z3_STEP_PIN) && !PIN_EXISTS(Z3_CS_PIN) #define Z4_E_INDEX INCREMENT(Z3_E_INDEX) #else #define Z4_E_INDEX Z3_E_INDEX #endif + +// The Z3 axis, if any, should be the next open extruder port #if NUM_Z_STEPPER_DRIVERS >= 3 #ifndef Z3_STEP_PIN #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP) @@ -938,12 +946,13 @@ #define Z3_MS3_PIN -1 #endif -// The Z4 axis, if any, should be the next open extruder port #if NUM_Z_STEPPER_DRIVERS >= 4 && !defined(Z4_DIAG_PIN) && !defined(Z4_STEP_PIN) && !PIN_EXISTS(Z4_CS_PIN) #define I_E_INDEX INCREMENT(Z4_E_INDEX) #else #define I_E_INDEX Z4_E_INDEX #endif + +// The Z4 axis, if any, should be the next open extruder port #if NUM_Z_STEPPER_DRIVERS >= 4 #ifndef Z4_STEP_PIN #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP) @@ -1023,13 +1032,14 @@ #define Z4_MS3_PIN -1 #endif -// The I axis, if any, should be the next open extruder port -#if LINEAR_AXES >= 4 && !defined(I_DIAG_PIN) && !defined(I_STEP_PIN) && !PIN_EXISTS(I_CS_PIN) +#if HAS_I_AXIS && !defined(I_DIAG_PIN) && !defined(I_STEP_PIN) && !PIN_EXISTS(I_CS_PIN) #define J_E_INDEX INCREMENT(I_E_INDEX) #else #define J_E_INDEX I_E_INDEX #endif -#if LINEAR_AXES >= 4 + +// The I axis, if any, should be the next open extruder port +#if HAS_I_AXIS #ifndef I_STEP_PIN #define I_STEP_PIN _EPIN(I_E_INDEX, STEP) #define I_DIR_PIN _EPIN(I_E_INDEX, DIR) @@ -1108,13 +1118,14 @@ #define I_MS3_PIN -1 #endif -// The J axis, if any, should be the next open extruder port -#if LINEAR_AXES >= 5 && !defined(J_DIAG_PIN) && !defined(J_STEP_PIN) && !PIN_EXISTS(J_CS_PIN) +#if HAS_J_AXIS && !defined(J_DIAG_PIN) && !defined(J_STEP_PIN) && !PIN_EXISTS(J_CS_PIN) #define K_E_INDEX INCREMENT(J_E_INDEX) #else #define K_E_INDEX J_E_INDEX #endif -#if LINEAR_AXES >= 5 + +// The J axis, if any, should be the next open extruder port +#if HAS_J_AXIS #ifndef J_STEP_PIN #define J_STEP_PIN _EPIN(J_E_INDEX, STEP) #define J_DIR_PIN _EPIN(J_E_INDEX, DIR) @@ -1194,7 +1205,7 @@ #endif // The K axis, if any, should be the next open extruder port -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #ifndef K_STEP_PIN #define K_STEP_PIN _EPIN(K_E_INDEX, STEP) #define K_DIR_PIN _EPIN(K_E_INDEX, DIR) diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index a7d1a6282048..9150bf13655d 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -163,9 +163,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#endif // // LCD / Controller diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index 45c09ae33e3b..8bc0a90c0586 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -55,7 +55,6 @@ #define X_MIN_PIN 12 // X- #define Y_MIN_PIN 11 // Y- - #define Z_MIN_PIN 10 // Z- #define X_MAX_PIN 81 // X+ #define Y_MAX_PIN 57 // Y+ @@ -78,15 +77,16 @@ #endif #if ENABLED(BLTOUCH) - #define Z_MIN_PIN 11 // Y-MIN - #define SERVO0_PIN 10 // Z-MIN - #else - #define Z_MIN_PIN 10 + #define Z_MIN_PIN 11 // Y- + #define SERVO0_PIN 10 // Z- #endif #endif #define Z_MAX_PIN 7 +#ifndef Z_MIN_PIN 7 + #define Z_MIN_PIN 10 // Z- +#endif // // Z Probe (when not Z_MIN_PIN) @@ -157,9 +157,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#endif // // LCD / Controller diff --git a/Marlin/src/pins/rambo/pins_MINIRAMBO.h b/Marlin/src/pins/rambo/pins_MINIRAMBO.h index ab25e2e692af..31d44f2b34ba 100644 --- a/Marlin/src/pins/rambo/pins_MINIRAMBO.h +++ b/Marlin/src/pins/rambo/pins_MINIRAMBO.h @@ -130,10 +130,12 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#if !MB(MINIRAMBO_10A) - #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #if !MB(MINIRAMBO_10A) + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 + #endif #endif // diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 41e59c1b22dd..5484b193b93b 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -186,9 +186,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 84 // 84 in MK2 Firmware +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 84 // 84 in MK2 Firmware +#endif // // LCD / Controller @@ -214,7 +216,6 @@ #define DOGLCD_A0 70 #define DOGLCD_CS 71 - #define LCD_SCREEN_ROT_180 #define BTN_EN1 85 #define BTN_EN2 84 @@ -225,6 +226,8 @@ #define STAT_LED_RED_PIN 22 #define STAT_LED_BLUE_PIN 32 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else // !VIKI2 && !miniVIKI #define BEEPER_PIN 79 // AUX-4 diff --git a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h index c2a691a3b73b..4c2645e64b2a 100644 --- a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h +++ b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h @@ -148,10 +148,11 @@ // Pins for DOGM SPI LCD Support #define DOGLCD_A0 70 #define DOGLCD_CS 71 - #define LCD_SCREEN_ROT_180 #define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board #define STAT_LED_RED_PIN 22 #define STAT_LED_BLUE_PIN 32 -#endif // VIKI2/miniVIKI + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 +#endif diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h index 79ac308ce71c..0a94a582d43c 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -134,7 +134,6 @@ #define FAN_PIN 9 #define FAN1_PIN 12 -#define NUM_RUNOUT_SENSORS 2 #define FIL_RUNOUT_PIN 22 #define FIL_RUNOUT2_PIN 21 diff --git a/Marlin/src/pins/ramps/pins_K8800.h b/Marlin/src/pins/ramps/pins_K8800.h index 9bc74943b47a..5cc4b4323a5a 100644 --- a/Marlin/src/pins/ramps/pins_K8800.h +++ b/Marlin/src/pins/ramps/pins_K8800.h @@ -30,8 +30,6 @@ #define BOARD_INFO_NAME "K8800" #define DEFAULT_MACHINE_NAME "Vertex Delta" -//#define LCD_SCREEN_ROT_180 - // // Limit Switches // @@ -109,7 +107,8 @@ #define LCD_CONTRAST_MIN 0 #define LCD_CONTRAST_MAX 100 - #define DEFAULT_LCD_CONTRAST 30 + #define LCD_CONTRAST_DEFAULT 30 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #if IS_NEWPANEL #define BTN_EN1 17 diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index 75ee01946ae5..a7817c6f3a7b 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -32,13 +32,13 @@ #error "Longer3D LGT KIT V1.0 board only supports one hotend / E-stepper. Comment out this line to continue." #endif -#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 +#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || SERIAL_PORT_3 == 1 #warning "Serial 1 is originally reserved to DGUS LCD." #endif -#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 +#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || SERIAL_PORT_3 == 2 || LCD_SERIAL_PORT == 2 #warning "Serial 2 has no connector. Hardware changes may be required to use it." #endif -#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 +#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || SERIAL_PORT_3 == 3 || LCD_SERIAL_PORT == 3 #define CHANGE_Y_LIMIT_PINS #warning "Serial 3 is originally reserved to Y limit switches. Hardware changes are required to use it." #endif @@ -105,7 +105,9 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX2_PIN -1 +#if HAS_PRUSA_MMU1 + #define E_MUX2_PIN -1 +#endif // // Misc. Functions diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h index 4742ac9b0d25..5f373f99d74b 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h @@ -89,7 +89,7 @@ * BLUE_LED | 8 7 | RED_LED ENCBTN | 8 7 | SDCS * KILL 6 5 | BEEPER 6 5 | MOSI * A0 | 4 3 | LCD_CS SDCD | 4 3 | - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h b/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h new file mode 100644 index 000000000000..12c40c7dca03 --- /dev/null +++ b/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h @@ -0,0 +1,86 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * Pxmalion Core i3 - https://github.com/Pxmalion + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Core i3" +#endif + +// +// Servos +// +#define SERVO0_PIN 51 +#define SERVO1_PIN -1 +#define SERVO2_PIN -1 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 2 +#define Z_MIN_PIN 19 +#define Z_MAX_PIN 18 + +// TODO: Filament Runout Sensor +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN -1 +#endif + +// +// Steppers +// +#define X_CS_PIN -1 +#define Y_CS_PIN -1 +#define Z_CS_PIN -1 +#define E0_CS_PIN -1 +#define E1_CS_PIN -1 + +// +// Heaters / Fans +// +#define FET_ORDER_EFB +#ifndef MOSFET_A_PIN + #define MOSFET_A_PIN 8 +#endif +#ifndef MOSFET_B_PIN + #define MOSFET_B_PIN 7 +#endif +#ifndef MOSFET_C_PIN + #define MOSFET_C_PIN 9 +#endif + +// +// Misc. Functions +// +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN -1 // Analog Input +#endif + +#define PS_ON_PIN 11 + +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 4697ff61b2c4..29caaf0533b9 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -120,14 +120,14 @@ #define X_DIR_PIN 55 #define X_ENABLE_PIN 38 #ifndef X_CS_PIN - #define X_CS_PIN AUX3_03_PIN + #define X_CS_PIN 53 #endif #define Y_STEP_PIN 60 #define Y_DIR_PIN 61 #define Y_ENABLE_PIN 56 #ifndef Y_CS_PIN - #define Y_CS_PIN AUX3_07_PIN + #define Y_CS_PIN 49 #endif #ifndef Z_STEP_PIN @@ -241,7 +241,7 @@ // Misc. Functions // #ifndef SDSS - #define SDSS AUX3_03_PIN + #define SDSS AUX3_06_PIN #endif #define LED_PIN 13 @@ -412,30 +412,59 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 40 // Z_CS_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 42 // E0_CS_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 44 // E1_CS_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 40 // Z_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 42 // E0_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 44 // E1_CS_PIN + #endif #endif // -// AUX3 : GND D52 D50 5V -// NC D53 D51 D49 +// AUX1 5V GND D2 D1 +// 2 4 6 8 +// 1 3 5 7 +// 5V GND A3 A4 +// +#define AUX1_05_PIN 57 // (A3) +#define AUX1_06_PIN 2 +#define AUX1_07_PIN 58 // (A4) +#define AUX1_08_PIN 1 -#define AUX3_03_PIN 53 -#define AUX3_04_PIN 52 -#define AUX3_05_PIN 51 -#define AUX3_06_PIN 50 -#define AUX3_07_PIN 49 +// +// AUX2 GND A9 D40 D42 A11 +// 2 4 6 8 10 +// 1 3 5 7 9 +// VCC A5 A10 D44 A12 +// +#define AUX2_03_PIN 59 // (A5) +#define AUX2_04_PIN 63 // (A9) +#define AUX2_05_PIN 64 // (A10) +#define AUX2_06_PIN 40 +#define AUX2_07_PIN 44 +#define AUX2_08_PIN 42 +#define AUX2_09_PIN 66 // (A12) +#define AUX2_10_PIN 65 // (A11) // -// AUX4 : D16 D17 D23 D25 D27 D29 D31 D33 D35 D37 D39 D41 D43 D45 D47 D32 GND 5V +// AUX3 GND D52 D50 5V +// 7 5 3 1 +// 8 6 4 2 +// NC D53 D51 D49 // +#define AUX3_02_PIN 49 +#define AUX3_03_PIN 50 +#define AUX3_04_PIN 51 +#define AUX3_05_PIN 52 +#define AUX3_06_PIN 53 +// +// AUX4 5V GND D32 D47 D45 D43 D41 D39 D37 D35 D33 D31 D29 D27 D25 D23 D17 D16 +// #define AUX4_03_PIN 32 #define AUX4_04_PIN 47 #define AUX4_05_PIN 45 @@ -454,35 +483,69 @@ #define AUX4_18_PIN 16 /** - * LCD adapter. NOTE: These come in two variants. The socket keys can be + * LCD adapters come in different variants. The socket keys can be * on either side, and may be backwards on some boards / displays. - * ------ ------ - * D37 |10 9 | D35 (MISO) D50 |10 9 | D52 (SCK) - * D17 | 8 7 | D16 D31 | 8 7 | D53 - * D23 6 5 D25 D33 6 5 D51 (MOSI) - * D27 | 4 3 | D29 D49 | 4 3 | D41 - * GND | 2 1 | 5V GND | 2 1 | NC - * ------ ------ - * EXP1 EXP2 */ #ifndef EXP1_03_PIN + #define EXP1_03_PIN AUX4_13_PIN #define EXP1_04_PIN AUX4_14_PIN #define EXP1_05_PIN AUX4_15_PIN #define EXP1_06_PIN AUX4_16_PIN #define EXP1_07_PIN AUX4_18_PIN #define EXP1_08_PIN AUX4_17_PIN - #define EXP1_09_PIN AUX4_10_PIN - #define EXP1_10_PIN AUX4_09_PIN - #define EXP2_03_PIN AUX4_07_PIN - #define EXP2_04_PIN AUX3_07_PIN - #define EXP2_05_PIN AUX3_05_PIN - #define EXP2_06_PIN AUX4_11_PIN - #define EXP2_07_PIN AUX3_03_PIN - #define EXP2_08_PIN AUX4_12_PIN - #define EXP2_09_PIN AUX3_04_PIN - #define EXP2_10_PIN AUX3_06_PIN + #define EXP2_04_PIN AUX3_02_PIN + #define EXP2_05_PIN AUX3_04_PIN + #define EXP2_07_PIN AUX3_06_PIN + #define EXP2_09_PIN AUX3_05_PIN + #define EXP2_10_PIN AUX3_03_PIN + + #if ENABLED(G3D_PANEL) + /** Gadgets3D Smart Adapter + * ------ ------ + * 4-11 |10 9 | 4-12 (MISO) 3-03 |10 9 | 3-05 (SCK) + * 4-17 | 8 7 | 4-18 4-10 | 8 7 | 3-06 + * 4-16 6 5 | 4-15 4-09 6 5 | 3-04 (MOSI) + * 4-14 | 4 3 | 4-13 3-02 | 4 3 | 4-07 + * (GND) 4-02 | 2 1 | 4-01 (5V) -- | 2 1 | -- + * ------ ------ + * EXP1 EXP2 + */ + #define EXP1_09_PIN AUX4_12_PIN + #define EXP1_10_PIN AUX4_11_PIN + + #define EXP2_03_PIN AUX4_07_PIN + #define EXP2_06_PIN AUX4_09_PIN + #define EXP2_08_PIN AUX4_10_PIN + + #else + + /** Smart Adapter (c) RRD + * ------ ------ + * 4-09 |10 9 | 4-10 (MISO) 3-03 |10 9 | 3-05 (SCK) + * 4-17 | 8 7 | 4-18 4-12 | 8 7 | 3-06 + * 4-16 6 5 | 4-15 4-11 6 5 | 3-04 (MOSI) + * 4-14 | 4 3 | 4-13 3-02 | 4 3 | 4-07 + * (GND) 3-07 | 2 1 | 3-01 (5V) (GND) 3-07 | 2 1 | -- + * ------ ------ + * EXP1 EXP2 + */ + #define EXP1_09_PIN AUX4_10_PIN + #define EXP1_10_PIN AUX4_09_PIN + + #if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + #define EXP2_03_PIN -1 // RESET + #define EXP2_06_PIN AUX4_12_PIN + #define EXP2_08_PIN AUX4_11_PIN + #else + #define EXP2_03_PIN AUX4_07_PIN + #define EXP2_06_PIN AUX4_11_PIN + #define EXP2_08_PIN AUX4_12_PIN + #endif + + #endif + #endif ////////////////////////// @@ -491,10 +554,7 @@ #if HAS_WIRED_LCD - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 // // LCD Display output pins @@ -507,12 +567,12 @@ #elif BOTH(IS_NEWPANEL, PANEL_ONE) - #define LCD_PINS_RS 40 - #define LCD_PINS_ENABLE 42 - #define LCD_PINS_D4 65 - #define LCD_PINS_D5 66 - #define LCD_PINS_D6 44 - #define LCD_PINS_D7 64 + #define LCD_PINS_RS AUX2_06_PIN + #define LCD_PINS_ENABLE AUX2_08_PIN + #define LCD_PINS_D4 AUX2_10_PIN + #define LCD_PINS_D5 AUX2_09_PIN + #define LCD_PINS_D6 AUX2_07_PIN + #define LCD_PINS_D7 AUX2_05_PIN #elif ENABLED(TFTGLCD_PANEL_SPI) @@ -533,12 +593,12 @@ #elif ENABLED(ZONESTAR_LCD) #error "CAUTION! ZONESTAR_LCD on RAMPS requires wiring modifications. It plugs into AUX2 but GND and 5V need to be swapped. Comment out this line to continue." - #define LCD_PINS_RS 64 - #define LCD_PINS_ENABLE 44 - #define LCD_PINS_D4 63 - #define LCD_PINS_D5 40 - #define LCD_PINS_D6 42 - #define LCD_PINS_D7 65 + #define LCD_PINS_RS AUX2_05_PIN + #define LCD_PINS_ENABLE AUX2_07_PIN + #define LCD_PINS_D4 AUX2_04_PIN + #define LCD_PINS_D5 AUX2_06_PIN + #define LCD_PINS_D6 AUX2_08_PIN + #define LCD_PINS_D7 AUX2_10_PIN #else @@ -570,8 +630,8 @@ // Buttons attached to a shift register // Not wired yet //#define SHIFT_CLK_PIN 38 - //#define SHIFT_LD_PIN 42 - //#define SHIFT_OUT_PIN 40 + //#define SHIFT_LD_PIN AUX2_08_PIN + //#define SHIFT_OUT_PIN AUX2_06_PIN //#define SHIFT_EN_PIN EXP1_08_PIN #endif @@ -612,10 +672,10 @@ #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define BTN_EN1 64 - #define BTN_EN2 59 - #define BTN_ENC 63 - #define SD_DETECT_PIN 42 + #define BTN_EN1 AUX2_05_PIN + #define BTN_EN2 AUX2_03_PIN + #define BTN_ENC AUX2_04_PIN + #define SD_DETECT_PIN AUX2_08_PIN #elif ENABLED(LCD_I2C_PANELOLU2) @@ -627,8 +687,8 @@ #elif ENABLED(LCD_I2C_VIKI) - #define BTN_EN1 40 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - #define BTN_EN2 42 + #define BTN_EN1 AUX2_06_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains AUX2-06 and AUX2-08. + #define BTN_EN2 AUX2_08_PIN #define BTN_ENC -1 #define LCD_SDSS SDSS @@ -636,17 +696,17 @@ #elif ANY(VIKI2, miniVIKI) - #define DOGLCD_CS 45 - #define DOGLCD_A0 44 - #define LCD_SCREEN_ROT_180 + #define DOGLCD_CS AUX4_05_PIN + #define DOGLCD_A0 AUX2_07_PIN + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #define BEEPER_PIN EXP2_06_PIN - #define STAT_LED_RED_PIN 32 + #define STAT_LED_RED_PIN AUX4_03_PIN #define STAT_LED_BLUE_PIN EXP1_09_PIN #define BTN_EN1 22 #define BTN_EN2 7 - #define BTN_ENC 39 + #define BTN_ENC AUX4_08_PIN #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board #define KILL_PIN EXP2_08_PIN @@ -723,19 +783,18 @@ #elif ENABLED(MINIPANEL) - #define BEEPER_PIN 42 - // not connected to a pin - #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + #define BEEPER_PIN AUX2_08_PIN + #define LCD_BACKLIGHT_PIN AUX2_10_PIN - #define DOGLCD_A0 44 - #define DOGLCD_CS 66 + #define DOGLCD_A0 AUX2_07_PIN + #define DOGLCD_CS AUX2_09_PIN - #define BTN_EN1 40 - #define BTN_EN2 63 - #define BTN_ENC 59 + #define BTN_EN1 AUX2_06_PIN + #define BTN_EN2 AUX2_04_PIN + #define BTN_ENC AUX2_03_PIN - #define SD_DETECT_PIN EXP2_04_PIN - #define KILL_PIN 64 + #define SD_DETECT_PIN AUX3_02_PIN + #define KILL_PIN AUX2_05_PIN #elif ENABLED(ZONESTAR_LCD) @@ -747,14 +806,14 @@ #elif ENABLED(G3D_PANEL) - #define BEEPER_PIN EXP2_06_PIN + #define BEEPER_PIN EXP1_10_PIN #define SD_DETECT_PIN EXP2_04_PIN #define KILL_PIN EXP2_03_PIN - #define BTN_EN1 EXP1_10_PIN - #define BTN_EN2 EXP1_09_PIN - #define BTN_ENC EXP2_08_PIN + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_08_PIN + #define BTN_ENC EXP1_09_PIN #elif IS_TFTGLCD_PANEL @@ -764,11 +823,10 @@ #define BEEPER_PIN EXP2_06_PIN - // Buttons are directly attached to AUX-2 - #if ENABLED(PANEL_ONE) - #define BTN_EN1 59 // AUX2 PIN 3 - #define BTN_EN2 63 // AUX2 PIN 4 - #define BTN_ENC EXP2_04_PIN + #if ENABLED(PANEL_ONE) // Buttons connect directly to AUX-2 + #define BTN_EN1 AUX2_03_PIN + #define BTN_EN2 AUX2_04_PIN + #define BTN_ENC AUX3_02_PIN #else #define BTN_EN1 EXP1_10_PIN #define BTN_EN2 EXP1_09_PIN @@ -781,17 +839,17 @@ #endif // HAS_WIRED_LCD #if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS - #define SHIFT_OUT_PIN 40 - #define SHIFT_CLK_PIN 44 - #define SHIFT_LD_PIN 42 + #define SHIFT_OUT_PIN AUX2_06_PIN + #define SHIFT_CLK_PIN AUX2_07_PIN + #define SHIFT_LD_PIN AUX2_08_PIN #ifndef BTN_EN1 - #define BTN_EN1 64 + #define BTN_EN1 AUX2_05_PIN #endif #ifndef BTN_EN2 - #define BTN_EN2 59 + #define BTN_EN2 AUX2_03_PIN #endif #ifndef BTN_ENC - #define BTN_ENC 63 + #define BTN_ENC AUX2_04_PIN #endif #endif @@ -802,15 +860,15 @@ /** * FYSETC TFT-81050 display pinout * - * Board Display - * ----- ----- - * (SCK) D52 | 1 2 | D50 (MISO) MISO | 1 2 | SCK - * (SD_CS) D53 | 3 4 | D33 (BNT_EN2) (BNT_EN2) MOD_RESET | 3 4 | SD_CS - * (MOSI) D51 | 5 6 D31 (BNT_EN1) (BNT_EN1) LCD_CS | 5 6 MOSI - * RESET | 7 8 | D49 (SD_DET) SD_DET | 7 8 | RESET - * NC | 9 10| GND GND | 9 10| 5V - * ----- ----- - * EXP2 EXP1 + * Board Display + * ------ ------ + * (MISO) 50 |10 9 | 52 (SCK) 5V |10 9 | GND + * (BTN_EN2) 33 | 8 7 | 53 (SD_CS) RESET | 8 7 | (SD_DET) + * (BTN_EN1) 31 6 5 | 51 (MOSI) (MOSI) 6 5 | (LCD_CS) + * (SD_DET) 49 | 4 3 | RESET (SD_CS) | 4 3 | (MOD_RESET) + * GND | 2 1 | -- (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP2 * * Needs custom cable: * @@ -835,6 +893,7 @@ #define SD_DETECT_PIN EXP2_04_PIN - #define CLCD_MOD_RESET EXP2_08_PIN - #define CLCD_SPI_CS EXP2_06_PIN + #define CLCD_MOD_RESET EXP2_06_PIN + #define CLCD_SPI_CS EXP2_08_PIN + #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h index def71fefc13e..679503e98268 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -30,9 +30,8 @@ // // Heaters / Fans // - -// Power outputs EFBF or EFBE -#define MOSFET_D_PIN 7 +#define MOSFET_B_PIN 7 // For HEATER_1_PIN ("EEF" or "EEB") +#define FAN_PIN 9 #define FIL_RUNOUT_PIN 2 #if NUM_RUNOUT_SENSORS >= 2 @@ -40,7 +39,12 @@ #endif #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN 49 // Always define onboard SD detect + #if SD_CONNECTION_IS(ONBOARD) + //#define HAS_ONBOARD_SD_DETECT // If the SD_DETECT_PIN is wired up + #endif + #if ENABLED(HAS_ONBOARD_SD_DETECT) || !SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN 49 + #endif #endif #ifndef PS_ON_PIN diff --git a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h index a69572dee7a8..0c554c353faf 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h @@ -23,10 +23,6 @@ /** * Arduino Mega with RAMPS v1.4Plus, also known as 3DYMY version, pin assignments - * The differences to the RAMPS v1.4 are: - * - Swap heater E0 with E1 - * - Swap pins 8 and 10. Bed/Fan/Hotend as labeled on the board are on pins 8/9/10. - * - Change pins 16->42, 17->44 and 29->53 used for display. * * Applies to the following boards: * @@ -35,6 +31,11 @@ * RAMPS_PLUS_EFF (Extruder, Fan, Fan) * RAMPS_PLUS_EEF (Extruder, Extruder, Fan) * RAMPS_PLUS_SF (Spindle, Controller Fan) + * + * Differences from RAMPS v1.4: + * - Swap heater E0 with E1 + * - Swap pins 8 and 10. Bed/Fan/Hotend as labeled on the board are on pins 8/9/10. + * - Change EXP1/2 pins */ #include "env_validate.h" @@ -62,15 +63,32 @@ #define E1_ENABLE_PIN 24 #define E1_CS_PIN -1 -#include "pins_RAMPS.h" +/** 3DYMY Expansion Headers + * ------ ------ + * 37 |10 9 | 35 (MISO) 50 |10 9 | 52 (SCK) + * 31 | 8 7 | 41 29 | 8 7 | 53 + * 33 6 5 | 23 25 6 5 | 51 (MOSI) + * 42 | 4 3 | 44 49 | 4 3 | 27 + * GND | 2 1 | 5V GND | 2 1 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_03_PIN 44 +#define EXP1_04_PIN 42 +#define EXP1_05_PIN 23 +#define EXP1_06_PIN 33 +#define EXP1_07_PIN 41 +#define EXP1_08_PIN 31 +#define EXP1_09_PIN 35 +#define EXP1_10_PIN 37 -#if IS_ULTRA_LCD && NONE(REPRAPWORLD_GRAPHICAL_LCD, CR10_STOCKDISPLAY) && !BOTH(IS_NEWPANEL, PANEL_ONE) - #if DISABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306) - #undef LCD_PINS_RS - #define LCD_PINS_RS 42 // 3DYMY boards pin 16 -> 42 - #undef LCD_PINS_ENABLE - #define LCD_PINS_ENABLE 44 // 3DYMY boards pin 17 -> 44 - #endif - #undef LCD_PINS_D7 - #define LCD_PINS_D7 53 // 3DYMY boards pin 29 -> 53 -#endif +#define EXP2_03_PIN 27 +#define EXP2_04_PIN 49 +#define EXP2_05_PIN 51 +#define EXP2_06_PIN 25 +#define EXP2_07_PIN 53 +#define EXP2_08_PIN 29 +#define EXP2_09_PIN 52 +#define EXP2_10_PIN 50 + +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h index e1ba91cde8f0..f41573b527cd 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h @@ -233,14 +233,16 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 29 // E2_STEP_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 28 // E2_DIR_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 39 // E2_ENABLE_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 29 // E2_STEP_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 28 // E2_DIR_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 39 // E2_ENABLE_PIN + #endif #endif ////////////////////////// diff --git a/Marlin/src/pins/ramps/pins_RUMBA.h b/Marlin/src/pins/ramps/pins_RUMBA.h index d8e2dd09715f..7d17bf2e12ed 100644 --- a/Marlin/src/pins/ramps/pins_RUMBA.h +++ b/Marlin/src/pins/ramps/pins_RUMBA.h @@ -220,7 +220,7 @@ #define RGB_LED_B_PIN 40 #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN 25 + #define NEOPIXEL_PIN 38 #endif #else diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index 01769fbff0cd..9d844ebcdcba 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -226,7 +226,7 @@ // // M3/M4/M5 - Spindle/Laser Control // -#if EITHER(SPINDLE_FEATURE, LASER_FEATURE) && !PIN_EXISTS(SPINDLE_LASER_ENA) +#if HAS_CUTTER && !PIN_EXISTS(SPINDLE_LASER_ENA) #if !NUM_SERVOS // Prefer the servo connector #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM @@ -252,15 +252,17 @@ // // Průša i3 MK2 Multiplexer Support // -//#ifndef E_MUX0_PIN -// #define E_MUX0_PIN 58 // Y_CS_PIN -//#endif -//#ifndef E_MUX1_PIN -// #define E_MUX1_PIN 53 // Z_CS_PIN -//#endif -//#ifndef E_MUX2_PIN -// #define E_MUX2_PIN 49 // En_CS_PIN -//#endif +#if 0 && HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 58 // Y_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 53 // Z_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 49 // En_CS_PIN + #endif +#endif ////////////////////////// // LCDs and Controllers // @@ -402,7 +404,6 @@ #define DOGLCD_CS 45 #define DOGLCD_A0 44 - #define LCD_SCREEN_ROT_180 #define BEEPER_PIN 33 #define STAT_LED_RED_PIN 32 @@ -416,6 +417,8 @@ #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board //#define KILL_PIN 31 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #define DOGLCD_CS 29 @@ -437,13 +440,6 @@ #define DOGLCD_A0 27 #define DOGLCD_CS 25 - // GLCD features - //#define LCD_CONTRAST_INIT 190 - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - #define BEEPER_PIN 37 #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 @@ -455,6 +451,9 @@ #define SD_DETECT_PIN 49 //#define KILL_PIN 64 + //#define LCD_CONTRAST_INIT 190 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(MINIPANEL) #define BEEPER_PIN 42 @@ -464,13 +463,6 @@ #define DOGLCD_A0 44 #define DOGLCD_CS 66 - // GLCD features - //#define LCD_CONTRAST_INIT 190 - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - #define BTN_EN1 40 #define BTN_EN2 63 #define BTN_ENC 59 @@ -479,6 +471,9 @@ #define SD_DETECT_PIN 49 //#define KILL_PIN 64 + //#define LCD_CONTRAST_INIT 190 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else // Beeper on AUX-4 diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V52.h b/Marlin/src/pins/ramps/pins_ZRIB_V52.h index 27f043914f07..002b9dbef580 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V52.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V52.h @@ -49,111 +49,111 @@ #include "pins_MKS_BASE_common.h" // ... RAMPS -/* - Available connectors on MKS BASE v1.4 (Basically same as ZRIB V5.2) - - ======= - | GND | - |-----| E0 - | 10 | (10) PB4 ** Pin23 ** PWM10 - |-----| - | GND | - |-----| E1 - | 7 | ( 7) PH4 ** Pin16 ** PWM7 - |-----| - | GND | - |-----| FAN - | 9 | ( 9) PH6 ** Pin18 ** PWM9 - ======= - - ======= - | GND | - |-----| Heated Bed - | 8 | ( 8) PH5 ** Pin17 ** PWM8 - ======= - - ========== - | 12-24V | - |--------| Power - | GND | - ========== - - XS3 Connector - ================= - | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 - |----|-----|----| - | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 - ================= - - Servos Connector - ================= - | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 - |----|-----|----| - | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 - ================= - - ICSP - ================= - | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI - |----|----|-----| - | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO - ================= (52) PB1 ** Pin20 ** SPI_SCK - - XS6/AUX-1 Connector - ====================== - | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA - |----|-----|----|----| - | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO - ====================== (51) PB2 ** Pin21 ** SPI_MOSI - (52) PB1 ** Pin20 ** SPI_SCK - (21) PD0 ** Pin43 ** I2C_SCL - - Temperature - ================================== - | GND | 69 | GND | 68 | GND | 67 | - ================================== - (69) PK7 ** Pin82 ** A15 - (68) PK6 ** Pin83 ** A14 - (67) PK5 ** Pin84 ** A13 - - Limit Switches - ============ - | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 - |----|-----| - | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 - |----|-----| - | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX - |----|-----| - | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX - |----|-----| - | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX - |----|-----| - | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX - ============ - - EXP1 - ============ - | 37 | 35 | (37) PC0 ** Pin53 ** D37 - |-----|----| (35) PC2 ** Pin55 ** D35 - | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX - |-----|----| (16) PH1 ** Pin13 ** USART2_TX - | 23 | 25 | (23) PA1 ** Pin77 ** D23 - |-----|----| (25) PA3 ** Pin75 ** D25 - | 27 | 29 | (27) PA5 ** Pin73 ** D27 - |-----|----| (29) PA7 ** Pin71 ** D29 - | GND | 5V | - ============ - - EXP2 - ============ - | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO - |-----|----| (52) PB1 ** Pin20 ** SPI_SCK - | 31 | 53 | (31) PC6 ** Pin59 ** D31 - |-----|----| (53) PB0 ** Pin19 ** SPI_SS - | 33 | 51 | (33) PC4 ** Pin57 ** D33 - |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI - | 49 | 41 | (49) PL0 ** Pin35 ** D49 - |-----|----| (41) PG0 ** Pin51 ** D41 - | GND | NC | - ============ -*/ +/** + * Available connectors on MKS BASE v1.4 (Basically same as ZRIB V5.2) + * + * ======= + * | GND | + * |-----| E0 + * | 10 | (10) PB4 ** Pin23 ** PWM10 + * |-----| + * | GND | + * |-----| E1 + * | 7 | ( 7) PH4 ** Pin16 ** PWM7 + * |-----| + * | GND | + * |-----| FAN + * | 9 | ( 9) PH6 ** Pin18 ** PWM9 + * ======= + * + * ======= + * | GND | + * |-----| Heated Bed + * | 8 | ( 8) PH5 ** Pin17 ** PWM8 + * ======= + * + * ========== + * | 12-24V | + * |--------| Power + * | GND | + * ========== + * + * XS3 Connector + * ================= + * | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 + * |----|-----|----| + * | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 + * ================= + * + * Servos Connector + * ================= + * | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 + * |----|-----|----| + * | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 + * ================= + * + * ICSP + * ================= + * | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI + * |----|----|-----| + * | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO + * ================= (52) PB1 ** Pin20 ** SPI_SCK + * + * XS6/AUX-1 Connector + * ====================== + * | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA + * |----|-----|----|----| + * | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO + * ====================== (51) PB2 ** Pin21 ** SPI_MOSI + * (52) PB1 ** Pin20 ** SPI_SCK + * (21) PD0 ** Pin43 ** I2C_SCL + * + * Temperature + * ================================== + * | GND | 69 | GND | 68 | GND | 67 | + * ================================== + * (69) PK7 ** Pin82 ** A15 + * (68) PK6 ** Pin83 ** A14 + * (67) PK5 ** Pin84 ** A13 + * + * Limit Switches + * ============ + * | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 + * |----|-----| + * | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 + * |----|-----| + * | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX + * |----|-----| + * | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX + * |----|-----| + * | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX + * |----|-----| + * | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX + * ============ + * + * EXP1 + * ============ + * | 37 | 35 | (37) PC0 ** Pin53 ** D37 + * |-----|----| (35) PC2 ** Pin55 ** D35 + * | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX + * |-----|----| (16) PH1 ** Pin13 ** USART2_TX + * | 23 | 25 | (23) PA1 ** Pin77 ** D23 + * |-----|----| (25) PA3 ** Pin75 ** D25 + * | 27 | 29 | (27) PA5 ** Pin73 ** D27 + * |-----|----| (29) PA7 ** Pin71 ** D29 + * | GND | 5V | + * ============ + * + * EXP2 + * ============ + * | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO + * |-----|----| (52) PB1 ** Pin20 ** SPI_SCK + * | 31 | 53 | (31) PC6 ** Pin59 ** D31 + * |-----|----| (53) PB0 ** Pin19 ** SPI_SS + * | 33 | 51 | (33) PC4 ** Pin57 ** D33 + * |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI + * | 49 | 41 | (49) PL0 ** Pin35 ** D49 + * |-----|----| (41) PG0 ** Pin51 ** D41 + * | GND | NC | + * ============ + */ diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V53.h b/Marlin/src/pins/ramps/pins_ZRIB_V53.h new file mode 100644 index 000000000000..6cbc0351ba98 --- /dev/null +++ b/Marlin/src/pins/ramps/pins_ZRIB_V53.h @@ -0,0 +1,511 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * ZRIB V5.3 Based on MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + */ + +#include "env_validate.h" + +#if HOTENDS > 2 + #error "ZRIB V5.3 only supports up to 2 hotends. Comment out this line to continue." +#elif E_STEPPERS > 3 + #error "ZRIB V5.3 only supports up to 3 E-steppers. Comment out this line to continue." +#endif + +#define BOARD_INFO_NAME "ZRIB V5.3" + +// +// PIN 12 Connector +// +#define PIN_12_PIN 12 + +// +// XS1 Connector +// +#define XS1_01_PIN 42 +#define XS1_03_PIN 43 +#define XS1_05_PIN 44 +#define XS1_07_PIN 45 +#define XS1_08_PIN 47 + +// +// XS6 Connector +// +#define XS6_01_PIN 20 +#define XS6_03_PIN 52 +#define XS6_05_PIN 51 +#define XS6_07_PIN 50 +#define XS6_08_PIN 21 + +// +// Servos / XS3 Connector +// +#ifndef SERVO0_PIN + #define SERVO0_PIN 11 // Analog Output +#endif +#ifndef SERVO1_PIN + #define SERVO1_PIN 12 // Analog Output +#endif + +// +// Limit Switches +// +#ifndef X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN 3 + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN 2 + #endif +#endif +#ifndef Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN 14 + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN 15 + #endif +#endif +#ifndef Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN 18 + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN 19 + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 + +#if NUM_Z_STEPPER_DRIVERS == 2 + #define Z2_STEP_PIN 26 // E0 connector + #define Z2_DIR_PIN 28 + #define Z2_ENABLE_PIN 24 + + #define E0_STEP_PIN 36 // E1 connector + #define E0_DIR_PIN 34 + #define E0_ENABLE_PIN 30 + + #define E1_STEP_PIN 4 // E2 connector + #define E1_DIR_PIN 5 + #define E1_ENABLE_PIN 22 +#else + #define E0_STEP_PIN 26 + #define E0_DIR_PIN 28 + #define E0_ENABLE_PIN 24 + + #define E1_STEP_PIN 36 + #define E1_DIR_PIN 34 + #define E1_ENABLE_PIN 30 + + #define E2_STEP_PIN 4 + #define E2_DIR_PIN 5 + #define E2_ENABLE_PIN 22 +#endif + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN 13 // Analog Input +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN 15 // Analog Input +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN 14 // Analog Input +#endif + +// +// Heaters / Fans Connectors +// + +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define FAN_PIN 9 +#define HEATER_BED_PIN 8 +#define FAN1_PIN 6 + +// +// Misc. Functions +// +#ifndef SDSS + #define SDSS 53 +#endif + +#define LED_PIN 13 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN XS1_01_PIN +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN XS1_03_PIN +#endif + +#if HAS_TMC_UART + /** + * TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + * + * Serial2 -- AUX-4 Pin 18 (D16 TX2) and AUX-4 Pin 17 (D17 RX2) + * Serial1 -- Pins D18 and D19 are used for Z-MIN and Z-MAX + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef X2_SERIAL_TX_PIN + #define X2_SERIAL_TX_PIN -1 + #endif + #ifndef X2_SERIAL_RX_PIN + #define X2_SERIAL_RX_PIN -1 + #endif + + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef Y2_SERIAL_TX_PIN + #define Y2_SERIAL_TX_PIN -1 + #endif + #ifndef Y2_SERIAL_RX_PIN + #define Y2_SERIAL_RX_PIN -1 + #endif + + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef Z2_SERIAL_TX_PIN + #define Z2_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Z2_SERIAL_RX_PIN + #define Z2_SERIAL_RX_PIN PIN_12_PIN + #endif + + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN -1 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN -1 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN -1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN -1 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN -1 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN -1 + #endif + #ifndef E3_SERIAL_TX_PIN + #define E3_SERIAL_TX_PIN -1 + #endif + #ifndef E3_SERIAL_RX_PIN + #define E3_SERIAL_RX_PIN -1 + #endif + #ifndef E4_SERIAL_TX_PIN + #define E4_SERIAL_TX_PIN -1 + #endif + #ifndef E4_SERIAL_RX_PIN + #define E4_SERIAL_RX_PIN -1 + #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif +#endif + +/** + * LCD adapter. NOTE: These come in two variants. The socket keys can be + * on either side, and may be backwards on some displays. + * ------ ------ + * D37 |10 9 | D35 (MISO) D50 |10 9 | D52 (SCK) + * D17 | 8 7 | D16 D31 | 8 7 | D53 + * D23 6 5 D25 D33 6 5 D51 (MOSI) + * D27 | 4 3 | D29 D49 | 4 3 | D41 + * GND | 2 1 | 5V GND | 2 1 | -- + * ------ ------ + * EXP1 EXP2 + */ + +#ifndef EXP1_03_PIN + #define EXP1_03_PIN 29 + #define EXP1_04_PIN 27 + #define EXP1_05_PIN 25 + #define EXP1_06_PIN 23 + #define EXP1_07_PIN 16 + #define EXP1_08_PIN 17 + #define EXP1_09_PIN 35 + #define EXP1_10_PIN 37 + + #define EXP2_03_PIN 41 + #define EXP2_04_PIN 49 + #define EXP2_05_PIN XS6_05_PIN + #define EXP2_06_PIN 33 + #define EXP2_07_PIN 53 + #define EXP2_08_PIN 31 + #define EXP2_09_PIN XS6_03_PIN + #define EXP2_10_PIN XS6_07_PIN +#endif + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +#if ENABLED(ZONESTAR_12864LCD) + #define LCDSCREEN_NAME "ZONESTAR LCD12864" + #define LCD_SDSS 16 + #define LCD_PINS_RS 16 // ST7920_CS_PIN LCD_PIN_RS (PIN4 of LCD module) + #define LCD_PINS_ENABLE 23 // ST7920_DAT_PIN LCD_PIN_R/W (PIN5 of LCD module) + #define LCD_PINS_D4 17 // ST7920_CLK_PIN LCD_PIN_ENABLE (PIN6 of LCD module) + #define BTN_EN2 25 + #define BTN_EN1 27 + #define BTN_ENC 29 + #define BEEPER_PIN 37 + #define KILL_PIN 35 +#elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define LCDSCREEN_NAME "Reprap LCD12864" + // Use EXP1 & EXP2 connector + #define LCD_PINS_RS 16 // ST7920_CS_PIN LCD_PIN_RS + #define LCD_PINS_ENABLE 17 // ST7920_DAT_PIN LCD_PIN_ENABLE + #define LCD_PINS_D4 23 // ST7920_CLK_PIN LCD_PIN_R/W + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + #define BEEPER_PIN 37 + #define KILL_PIN 41 +#endif + +//================================================================================ +// OLED 128x64 +//================================================================================ + +#if EITHER(ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) + #define LCDSCREEN_NAME "ZONESTAR 12864OLED" + #define LCD_SDSS 16 + #define LCD_PINS_RS 23 // RESET Pull low for 1s to init + #define LCD_PINS_DC 17 + #define DOGLCD_CS 16 // CS + #define BTN_EN2 25 + #define BTN_EN1 27 + #define BTN_ENC 29 + #define BEEPER_PIN -1 + #define KILL_PIN -1 + #if EITHER(OLED_HW_IIC, OLED_HW_SPI) + #error "Oops! You must choose SW SPI for ZRIB V53 board and connect the OLED screen to EXP1 connector." + #else // SW_SPI + #define DOGLCD_A0 LCD_PINS_DC + #define DOGLCD_MOSI 35 // SDA + #define DOGLCD_SCK 37 // SCK + #endif +#endif // OLED 128x64 + +//================================================================================ +// LCD 2004 KEYPAD +//================================================================================ + +#if ENABLED(ZONESTAR_LCD) + #define LCDSCREEN_NAME "LCD2004 ADCKEY" + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_D7 EXP1_03_PIN + #define ADC_KEYPAD_PIN 10 // A10 for ADCKEY + #define BEEPER_PIN EXP1_10_PIN +#endif + +/** + * ZRIB V5.3 Main Board + * + * Available connectors on ZRIB V5.3 + * + * ======= + * | GND | + * |-----| E0 + * | 10 | (10) PB4 ** Pin23 ** PWM10 + * |-----| + * | GND | + * |-----| E1 + * | 7 | ( 7) PH4 ** Pin16 ** PWM7 + * |-----| + * | GND | + * |-----| FAN + * | 9 | ( 9) PH6 ** Pin18 ** PWM9 + * ======= + * ======= + * | GND | + * |-----| Heated Bed + * | 8 | ( 8) PH5 ** Pin17 ** PWM8 + * ======= + * ========== + * | 12-24V | + * |--------| Power + * | GND | + * ========== + * XS3 Connector + * ================= + * | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 + * |----|-----|----| + * | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 + * ================= + * XS3/Servos Connector + * ================= + * | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 + * |----|-----|----| + * | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 + * ================= + * ICSP + * ================= + * | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI + * |----|----|-----| + * | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO + * ================= (52) PB1 ** Pin20 ** SPI_SCK + * XS6 Connector + * ====================== + * | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA + * |----|-----|----|----| + * | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO + * ====================== (51) PB2 ** Pin21 ** SPI_MOSI + * (52) PB1 ** Pin20 ** SPI_SCK + * (21) PD0 ** Pin43 ** I2C_SCL + * XS1 Connector + * ====================== + * | 5V | GND | NC | 47 | (47) PL2 ** Pin37 ** D47 + * |----|-----|----|----| + * | 42 | 43 | 44 | 45 | (45) PL4 ** Pin39 ** D45 + * ====================== (44) PL5 ** Pin40 ** D44 + * (43) PL6 ** Pin41 ** D43 + * (42) PL7 ** Pin42 ** D42 + * Temperature + * ================================== + * | GND | 69 | GND | 68 | GND | 67 | + * ================================== + * (69) PK7 ** Pin82 ** A15 + * (68) PK6 ** Pin83 ** A14 + * (67) PK5 ** Pin84 ** A13 + * Limit Switches + * ============ + * | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 + * |----|-----| + * | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 + * |----|-----| + * | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX + * |----|-----| + * | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX + * |----|-----| + * | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX + * |----|-----| + * | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX + * ============ + * EXP1 + * ============ + * | 37 | 35 | (37) PC0 ** Pin53 ** D37 + * |-----|----| (35) PC2 ** Pin55 ** D35 + * | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX + * |-----|----| (16) PH1 ** Pin13 ** USART2_TX + * | 23 | 25 | (23) PA1 ** Pin77 ** D23 + * |-----|----| (25) PA3 ** Pin75 ** D25 + * | 27 | 29 | (27) PA5 ** Pin73 ** D27 + * |-----|----| (29) PA7 ** Pin71 ** D29 + * | GND | 5V | + * ============ + * EXP2 + * ============ + * | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO + * |-----|----| (52) PB1 ** Pin20 ** SPI_SCK + * | 31 | 53 | (31) PC6 ** Pin59 ** D31 + * |-----|----| (53) PB0 ** Pin19 ** SPI_SS + * | 33 | 51 | (33) PC4 ** Pin57 ** D33 + * |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI + * | 49 | 41 | (49) PL0 ** Pin35 ** D49 + * |-----|----| (41) PG0 ** Pin51 ** D41 + * | GND | NC | + * ============ + * + * PIN 12 + * ====== + * | 12 | (12) PB6 ** Pin25 ** D12 + * ====== +*/ diff --git a/Marlin/src/pins/sam/pins_ARCHIM1.h b/Marlin/src/pins/sam/pins_ARCHIM1.h index 57bbeb62a280..d9f1dcbf9427 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM1.h +++ b/Marlin/src/pins/sam/pins_ARCHIM1.h @@ -46,8 +46,7 @@ // // Timers // -// These are already defined in DUE, so must be undefined first -#define STEP_TIMER_NUM 3 +#define MF_TIMER_STEP 3 #define HAL_STEP_TIMER_ISR() void TC3_Handler() // diff --git a/Marlin/src/pins/sam/pins_RADDS.h b/Marlin/src/pins/sam/pins_RADDS.h index 7a865b4ad870..da176f444784 100644 --- a/Marlin/src/pins/sam/pins_RADDS.h +++ b/Marlin/src/pins/sam/pins_RADDS.h @@ -286,7 +286,7 @@ #endif // SPARK_FULL_GRAPHICS #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #define BTN_ENC_EN 47 // Detect the presence of the encoder #endif #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index 5e612d3e8c22..4bdadd80828e 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -117,14 +117,8 @@ //#define E3_MS2_PIN ? //#define E3_MS3_PIN ? -#if USES_Z_MIN_PROBE_PIN - #define Z_MIN_PROBE_PIN 49 -#endif - -#if HAS_FILAMENT_SENSOR - #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN Y_MIN_PIN - #endif +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN Y_MIN_PIN #endif // diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index 37a76c527821..5273cbcd0e93 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -53,13 +53,6 @@ #define Z_MIN_PIN 47 #define Z_MAX_PIN 43 -// -// Z Probe (when not Z_MIN_PIN) -// -#ifndef Z_MIN_PROBE_PIN - #define Z_MIN_PROBE_PIN 49 -#endif - // // Steppers // @@ -105,14 +98,12 @@ #define E2_CS_PIN 61 #endif -#if USES_Z_MIN_PROBE_PIN +#ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN 49 #endif -#if HAS_FILAMENT_SENSOR - #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN Y_MIN_PIN - #endif +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN Y_MIN_PIN #endif // diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h new file mode 100644 index 000000000000..1e0efcf0b21d --- /dev/null +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h @@ -0,0 +1,616 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * BRICOLEMON LITE Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * This board its a 3.3V LOGIC Board, following the ADAFRUIT example, all of the board is open source. + * Schematic: Refer to the Bricolemon + * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon%20Lite/LC_BG_002_PCB_V1I4.step + * PinDemux: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/PinDEMUX.xlsx + * + * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 + */ + +#if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) + #error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BRICOLEMON LITE V1.0" // , Lemoncrest & BricoGeek collaboration. +#endif + +/** + * EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on. + */ +//#define FLASH_EEPROM_EMULATION +#define I2C_EEPROM // EEPROM on I2C-0 +#define MARLIN_EEPROM_SIZE 0x70000 // 512K (CAT24C512) + +// This is another option to emulate an EEPROM, but it's more efficient to not lose the data in the first place. +//#define SDCARD_EEPROM_EMULATION + +// +// BLTOUCH PIN: This pin is the signal pin for the BLTOUCH sensor. +// +#define SERVO0_PIN 33 // BLTouch PWM + +// +// Limit Switches +// +#define X_STOP_PIN 10 +#define Y_STOP_PIN 11 +#define Z_STOP_PIN 12 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 12 +#endif + +// +// Steppers +// +#define X_STEP_PIN 3 +#define X_DIR_PIN 22 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 4 +#define Y_DIR_PIN 23 +#define Y_ENABLE_PIN 27 + +#define Z_STEP_PIN 5 +#define Z_DIR_PIN 24 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 2 +#define E0_DIR_PIN 25 +#define E0_ENABLE_PIN 29 + +// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O. +// For example, a switch to detect any kind of behavior, Power supply pin .... etc. +#define FIL_RUNOUT_PIN 32 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 +#define TEMP_BED_PIN 3 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_BED_PIN 7 +#define FAN_PIN 8 +#define FAN1_PIN 9 + +// +// LCD / Controller +// + +/** + * Bricolemon Expansion connectors + * + * ------ ------ + * VCC | 1 2 | GND KILL | 1 2 | GND + * LCD7 | 3 4 | LCDD6 RESET | 3 4 | SD_DETECT + * LCD5 | 5 6 LCDD4 MOSI | 5 6 BTN_EN1 + * LCDRS | 7 8 | LCDDE SS | 7 8 | BTN_EN2 + * BTN_ENCODER | 9 10 | BEEPER SCLK | 9 10 | MISO + * ------ ------ + * EXP1 EXP2 + * + *- This extra connector is for a serial display like the MKS TFT. + * MKS TFT + * ------ + * RX0 | . . | NC + * TX0 | . . NC + * GND | . . GND + * 5B | . . | 5V + * ------ + * + *- Special mapping of EXP1 to EXP3 to work with Ender displays. + * + * Enable CR10_STOCKDISPLAY in Configuration.h and connect EXP1 to the display EXP3 with this mapping. + * ------ + * VCC | 1 2 | GND + * LCDDE | 3 4 | LCDRS + * LCDD4 | 5 6 BTN_EN2 + * RESET | 7 8 | BTN_EN1 + * BTN_ENCODER | 9 10 | BEEPER + * ------ + * + *- Digital pinout reference of the Bricolemon for advanced users/configurations. + * + * ------ ------ + * VCC | 1 2 | GND D49 | 1 2 | GND + * D39 | 3 4 | D38 RST | 3 4 | D44 + * D37 | 5 6 D36 D51 | 5 6 D42 + * D34 | 7 8 | D35 D53 | 7 8 | D43 + * D40 | 9 10 | D41 D52 | 9 10 | D50 + * ------ ------ + * EXP1 EXP2 + * + *- Pin table overview + * LCD--- SPI--- + * LCD4 36 MISO 50 + * LCD5 37 SS 53 + * LCD6 38 SCKL 52 + * LCD7 39 MOSI 51 + * LCDRS 34 BEEPER + * LCDDE 35 BEEP 41 + * ENCODER--- SD-CARD--- + * BTN_EN1 42 + * BTN_EN2 43 SD_DETECT 44 + * BTN_ENCODER 40 KILL_PIN 49 + */ + +#define EXP1_03_PIN 39 +#define EXP1_04_PIN 38 +#define EXP1_05_PIN 37 +#define EXP1_06_PIN 36 +#define EXP1_07_PIN 34 +#define EXP1_08_PIN 35 +#define EXP1_09_PIN 40 +#define EXP1_10_PIN 41 + +#define EXP2_01_PIN 49 +#define EXP2_04_PIN 44 +#define EXP2_05_PIN 51 +#define EXP2_06_PIN 42 +#define EXP2_07_PIN 53 +#define EXP2_08_PIN 43 +#define EXP2_09_PIN 52 +#define EXP2_10_PIN 50 + +#if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_03_PIN EXP1_03_PIN + #define EXP3_04_PIN EXP1_04_PIN + #define EXP3_05_PIN EXP1_05_PIN + #define EXP3_06_PIN EXP1_06_PIN + #define EXP3_07_PIN EXP1_07_PIN + #define EXP3_08_PIN EXP1_08_PIN + #define EXP3_09_PIN EXP1_09_PIN + #define EXP3_10_PIN EXP1_10_PIN +#endif + +/************************************/ +/***** Configurations Section ******/ +/************************************/ + +/** + * This section starts with the pins_RAMPS_144.h as example, after if you need any new + * display, you could use normal duponts and connect it with with the scheme showed before. + * Tested: + * - Ender 3 Old display (Character LCD) + * - Ender 3 New Serial DWING Display + * - Reprap Display + * - Ender 5 New Serial Display + * - Any Reprap character display like + */ + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + + #if LCD_SERIAL_PORT != 1 + #error "LCD_SERIAL_PORT should be 1 for this display." + #endif + + // DWIN Encoder + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_10_PIN + #undef SPEAKER + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define LCD_PINS_RS EXP2_01_PIN // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE EXP2_05_PIN // SID (MOSI) + //#define LCD_PINS_D4 EXP2_09_PIN // SCK (CLK) clock + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + // TO TEST + //#define LCD_PINS_RS EXP1_09_PIN + //#define LCD_PINS_ENABLE EXP2_06_PIN + //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 + //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 + //#define LCD_PINS_D6 EXP2_04_PIN + //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + // TO TEST + #define LCD_PINS_RS EXP3_04_PIN + #define LCD_PINS_ENABLE EXP3_03_PIN + #define LCD_PINS_D4 EXP3_05_PIN + + #if !IS_NEWPANEL + // TO TEST + //#define BEEPER_PIN EXP3_05_PIN + #endif + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_PINS_ENABLE EXP2_04_PIN + //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 + //#define LCD_PINS_D5 EXP1_09_PIN + //#define LCD_PINS_D6 EXP2_06_PIN + //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + // TO TEST + //#define LCD_PINS_DC 25 // Set as output on init + //#define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + //#define DOGLCD_CS 16 + //#define DOGLCD_MOSI 17 + //#define DOGLCD_SCK 23 + //#define DOGLCD_A0 LCD_PINS_DC + + + #else + // Definitions for any standard Display + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #endif + + #define LCD_PINS_D7 EXP1_03_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_10_PIN + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN EXP1_04_PIN + //#define SHIFT_LD_PIN EXP2_06_PIN + //#define SHIFT_OUT_PIN EXP1_09_PIN + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN EXP1_10_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_06_PIN + + #else + // Definitions for any standard Display + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_08_PIN + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #define BTN_ENC EXP1_09_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_04_PIN + #endif + #define KILL_PIN EXP2_01_PIN + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN EXP1_03_PIN // TO TEST + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 + //#define SD_DETECT_PIN EXP2_06_PIN + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 EXP2_08_PIN + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN EXP1_10_PIN + + #elif ENABLED(LCD_I2C_VIKI) + + // TO TEST + //#define BTN_EN1 EXP1_09_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_06_PIN + //#define BTN_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_01_PIN + + #elif ANY(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 EXP2_04_PIN + //#define LCD_SCREEN_ROT_180 + + //#define BEEPER_PIN 33 + //#define STAT_LED_RED_PIN 32 + //#define STAT_LED_BLUE_PIN EXP1_08_PIN + + //#define BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC EXP1_03_PIN + + //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + //#define KILL_PIN 31 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + // TO TEST + //#define DOGLCD_CS 29 + //#define DOGLCD_A0 27 + + //#define BEEPER_PIN 23 + //#define LCD_BACKLIGHT_PIN 33 + + //#define BTN_EN1 EXP1_08_PIN + //#define BTN_EN2 EXP1_05_PIN + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_01_PIN + //#define KILL_PIN EXP1_10_PIN + + #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) + + // TO TEST + //#define BEEPER_PIN EXP1_05_PIN + //#define BTN_ENC EXP1_08_PIN + //#define SD_DETECT_PIN EXP2_01_PIN + + //#ifndef KILL_PIN + // #define KILL_PIN EXP1_10_PIN + //#endif + + #if ENABLED(MKS_MINI_12864) + + // TO TEST + //#define DOGLCD_A0 27 + //#define DOGLCD_CS 25 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define BTN_EN1 31 + //#define BTN_EN2 33 + + #elif ENABLED(FYSETC_MINI_12864) + + // From https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8 + + // TO TEST + //#define DOGLCD_A0 16 + //#define DOGLCD_CS 17 + + //#define BTN_EN1 33 + //#define BTN_EN2 31 + + //#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 23 // 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 + // TO TEST + //#define RGB_LED_R_PIN 25 + #endif + #ifndef RGB_LED_G_PIN + // TO TEST + //#define RGB_LED_G_PIN 27 + #endif + #ifndef RGB_LED_B_PIN + // TO TEST + //#define RGB_LED_B_PIN 29 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + // TO TEST + //#define NEOPIXEL_PIN 25 + #endif + + #endif + + #elif ENABLED(MINIPANEL) + + // TO TEST + //#define BEEPER_PIN EXP2_06_PIN + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + //#define BTN_EN1 EXP1_09_PIN + //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 + //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 + + //#define SD_DETECT_PIN EXP2_01_PIN + //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // TO TEST + + #else + + // Beeper on AUX-4 + //#define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + // TO TEST + //#define SHIFT_OUT_PIN EXP1_09_PIN + //#define SHIFT_CLK_PIN EXP2_04_PIN + //#define SHIFT_LD_PIN EXP2_06_PIN + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 + #elif ENABLED(PANEL_ONE) + // TO TEST + //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) + //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) + //#define BTN_ENC EXP2_01_PIN // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 EXP1_05_PIN + //#define BTN_EN2 EXP1_08_PIN + //#define BTN_ENC 31 + #endif + + #if ENABLED(G3D_PANEL) + // TO TEST + //#define SD_DETECT_PIN EXP2_01_PIN + //#define KILL_PIN EXP1_10_PIN + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +/** + * Bricolemon has an SD slot, but to change it to your LCD or Custom, set the option to one of the following: + * + * LCD - Use the SD drive in the external LCD controller. + * ONBOARD - Use the SD drive on the control board. + * CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file). + * + * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] + */ + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDSS 83 + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 95 +#else + #define SDSS EXP2_07_PIN +#endif + +#if HAS_TMC_UART + /** + * Address for the UART Configuration of the TMC2209. Override in Configuration files. + * To test TMC2209 Steppers enable TMC_DEBUG in Configuration_adv.h and test the M122 command with voltage on the steppers. + */ + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0b00 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 0b01 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 0b10 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0b11 + #endif + + /** + * TMC2208/TMC2209 stepper drivers + * It seems to work perfectly fine on Software Serial, if an advanced user wants to test, you could use the SAMD51 Serial1 and Serial 2. Be careful with the Sercom configurations. + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + + // This is the stable default value after testing, but, higher UART rates could be configured, remeber to test the Steppers with the M122 command to check if everything works. + #define TMC_BAUD_RATE 250000 + + // + // Software serial + // + #define X_SERIAL_TX_PIN 0 + #define X_SERIAL_RX_PIN 1 + + #define Y_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define Z_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Z_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E0_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define E0_SERIAL_RX_PIN X_SERIAL_RX_PIN + +#endif diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h new file mode 100644 index 000000000000..2484674a90b3 --- /dev/null +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h @@ -0,0 +1,676 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * BRICOLEMON Board. Based on ATSAMD51 (AGCM4), bootloader and credits by ADAFRUIT. + */ + +#if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) + #error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BRICOLEMON V1.0" // , Lemoncrest & BricoGeek collaboration. +#endif + +/** + * BRICOLEMON Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * This board its a 3.3V LOGIC Board, following the ADAFRUIT example, all of the board is open source. + * Schematic: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/EsquemaBricolemon_REVB.pdf + * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/BricolemonREVB.step + * PinDemux: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/PinDEMUX.xlsx + * + * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 + */ + +/** + * EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on. + */ +//#define FLASH_EEPROM_EMULATION +#define I2C_EEPROM // EEPROM on I2C-0 +#define MARLIN_EEPROM_SIZE 0x70000 // 512K (CAT24C512) + +//This its another option to emulate an EEPROM, but its more efficient to dont loose the data the first One. +//#define SDCARD_EEPROM_EMULATION + +// +// BLTouch +// +#define SERVO0_PIN 33 // BLTouch PWM + +// +// Limit Switches +// +#define X_STOP_PIN 10 +#define Y_STOP_PIN 11 +#define Z_STOP_PIN 12 + +/** + * NOTE: Useful if extra TMC2209 are to be used as independent axes. + * We need to configure the new digital PIN, for this we could configure on the board the extra pin of this stepper, for example as a MIN_PIN/MAX_PIN. This pin is the D14. + */ +//#define Z2_STOP_PIN 14 +//#define X2_STOP_PIN 14 +//#define Y2_STOP_PIN 14 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 12 +#endif + +// +// Steppers +// +#define X_STEP_PIN 3 +#define X_DIR_PIN 22 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 4 +#define Y_DIR_PIN 23 +#define Y_ENABLE_PIN 27 + +#define Z_STEP_PIN 5 +#define Z_DIR_PIN 24 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 2 +#define E0_DIR_PIN 25 +#define E0_ENABLE_PIN 29 + +#define E1_STEP_PIN 13 +#define E1_DIR_PIN 46 +#define E1_ENABLE_PIN 47 + +// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O. +// For example, a switch to detect any kind of behavior, Power supply pin .... etc. +#define FIL_RUNOUT_PIN 32 + +// This board have the option to use an extra TMC2209 stepper, one of the use could be as a second extruder. +#if EXTRUDERS < 2 + // TODO: Corregir aquí que cuando tenemos dos extrusores o lo que sea, utiliza los endstop que le sobran, osea los max, no hay Z2_endstop + #if NUM_Z_STEPPER_DRIVERS > 1 + #define Z2_STOP_PIN 14 + #endif +#else + // If we want to configure the extra stepper as a Extruder, we should have undef all of the extra motors. + #undef X2_DRIVER_TYPE + #undef Y2_DRIVER_TYPE + #undef Z2_DRIVER_TYPE + #undef Z3_DRIVER_TYPE + #undef Z4_DRIVER_TYPE + + // Si tenemos más de un extrusor lo que hacemos es definir el nuevo extrusor así como sus pines + // Acordarse de definir el #define TEMP_SENSOR_1, ya que este contiene el tipo de sonda del extrusor E1 + + #define FIL_RUNOUT2_PIN 14 + +#endif + +// +// Extruder / Bed +// + +// Temperature Sensors +#define TEMP_0_PIN 1 + +// You could use one of the ADC for a temp chamber if you don't use the second extruder, for example. +#if TEMP_SENSOR_CHAMBER > 0 + #define TEMP_CHAMBER_PIN 3 +#else + #define TEMP_1_PIN 3 +#endif + +#define TEMP_BED_PIN 2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_1_PIN 45 +#define HEATER_BED_PIN 7 + +// The board has 4 PWM fans, use and configure as desired +#define FAN_PIN 8 +#define FAN1_PIN 9 +#define FAN2_PIN 30 +#define FAN3_PIN 31 + +// +// LCD / Controller +// + +/** + * Bricolemon Expansion connectors + * + * ------ ------ + * VCC | 1 2 | GND KILL | 1 2 | GND + * LCD7 | 3 4 | LCDD6 RESET | 3 4 | SD_DETECT + * LCD5 | 5 6 LCDD4 MOSI | 5 6 BTN_EN1 + * LCDRS | 7 8 | LCDDE SS | 7 8 | BTN_EN2 + * BTN_ENCODER | 9 10 | BEEPER SCLK | 9 10 | MISO + * ------ ------ + * EXP1 EXP2 + * + *- This extra connector is for a serial display like the MKS TFT. + * MKS TFT + * ------ + * RX0 | . . | NC + * TX0 | . . NC + * GND | . . GND + * 5B | . . | 5V + * ------ + * + *- Special mapping of EXP1 to EXP3 to work with Ender displays. + * + * Enable CR10_STOCKDISPLAY in Configuration.h and connect EXP1 to the display EXP3 with this mapping. + * ------ + * VCC | 1 2 | GND + * LCDDE | 3 4 | LCDRS + * LCDD4 | 5 6 BTN_EN2 + * RESET | 7 8 | BTN_EN1 + * BTN_ENCODER | 9 10 | BEEPER + * ------ + * + *- Digital pinout reference of the Bricolemon for advanced users/configurations. + * + * ------ ------ + * VCC | 1 2 | GND D49 | 1 2 | GND + * D39 | 3 4 | D38 RST | 3 4 | D44 + * D37 | 5 6 D36 D51 | 5 6 D42 + * D34 | 7 8 | D35 D53 | 7 8 | D43 + * D40 | 9 10 | D41 D52 | 9 10 | D50 + * ------ ------ + * EXP1 EXP2 + * + *- Pin table overview + * LCD--- SPI--- + * LCD4 36 MISO 50 + * LCD5 37 SS 53 + * LCD6 38 SCKL 52 + * LCD7 39 MOSI 51 + * LCDRS 34 BEEPER + * LCDDE 35 BEEP 41 + * ENCODER--- SD-CARD--- + * BTN_EN1 42 SD_DETECT 44 + * BTN_EN2 43 KILL_PIN 49 + * BTN_ENCODER 40 + */ + +#define EXP1_03_PIN 39 +#define EXP1_04_PIN 38 +#define EXP1_05_PIN 37 +#define EXP1_06_PIN 36 +#define EXP1_07_PIN 34 +#define EXP1_08_PIN 35 +#define EXP1_09_PIN 40 +#define EXP1_10_PIN 41 + +#define EXP2_01_PIN 49 +#define EXP2_04_PIN 44 +#define EXP2_05_PIN 51 +#define EXP2_06_PIN 42 +#define EXP2_07_PIN 53 +#define EXP2_08_PIN 43 +#define EXP2_09_PIN 52 +#define EXP2_10_PIN 50 + +#if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_03_PIN EXP1_03_PIN + #define EXP3_04_PIN EXP1_04_PIN + #define EXP3_05_PIN EXP1_05_PIN + #define EXP3_06_PIN EXP1_06_PIN + #define EXP3_07_PIN EXP1_07_PIN + #define EXP3_08_PIN EXP1_08_PIN + #define EXP3_09_PIN EXP1_09_PIN + #define EXP3_10_PIN EXP1_10_PIN +#endif + +/************************************/ +/***** Configurations Section ******/ +/************************************/ + +/** + * This sections starts with the pins_RAMPS_144.h as example, after if you need any new + * display, you could use normal duponts and connect it with with the scheme showed before. + * Tested: + * - Ender 3 Old display (Character LCD) + * - Ender 3 New Serial DWING Display + * - Reprap Display + * - Ender 5 New Serial Display + * - Any Reprap character display like + */ + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + + #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + + #if LCD_SERIAL_PORT != 1 + #error "LCD_SERIAL_PORT should be 1 for this display." + #endif + + // DWIN Encoder + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_10_PIN + #undef SPEAKER + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define LCD_PINS_RS EXP2_01_PIN // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE EXP2_05_PIN // SID (MOSI) + //#define LCD_PINS_D4 EXP2_09_PIN // SCK (CLK) clock + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + // TO TEST + //#define LCD_PINS_RS EXP1_09_PIN + //#define LCD_PINS_ENABLE EXP2_06_PIN + //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 + //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 + //#define LCD_PINS_D6 EXP2_04_PIN + //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + // TO TEST + #define LCD_PINS_RS EXP3_04_PIN + #define LCD_PINS_ENABLE EXP3_03_PIN + #define LCD_PINS_D4 EXP3_05_PIN + + #if !IS_NEWPANEL + // TO TEST + //#define BEEPER_PIN EXP3_05_PIN + #endif + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_PINS_ENABLE EXP2_04_PIN + //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 + //#define LCD_PINS_D5 EXP1_09_PIN + //#define LCD_PINS_D6 EXP2_06_PIN + //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + // TO TEST + //#define LCD_PINS_DC 25 // Set as output on init + //#define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + //#define DOGLCD_CS 16 + //#define DOGLCD_MOSI 17 + //#define DOGLCD_SCK 23 + //#define DOGLCD_A0 LCD_PINS_DC + + #else + // Definitions for any standard Display + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #endif + + #define LCD_PINS_D7 EXP1_03_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_10_PIN + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN EXP1_04_PIN + //#define SHIFT_LD_PIN EXP2_06_PIN + //#define SHIFT_OUT_PIN EXP1_09_PIN + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN EXP1_10_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_06_PIN + #else + // Definitions fpr any standard Display + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_08_PIN + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #define BTN_ENC EXP1_09_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_04_PIN + #endif + #define KILL_PIN EXP2_01_PIN + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN EXP1_03_PIN // TO TEST + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 + //#define SD_DETECT_PIN EXP2_06_PIN + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 EXP2_08_PIN + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN EXP1_10_PIN + + #elif ENABLED(LCD_I2C_VIKI) + + // TO TEST + //#define BTN_EN1 EXP1_09_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_06_PIN + //#define BTN_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_01_PIN + + #elif ANY(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 EXP2_04_PIN + //#define LCD_SCREEN_ROT_180 + + //#define BEEPER_PIN 33 + //#define STAT_LED_RED_PIN 32 + //#define STAT_LED_BLUE_PIN EXP1_08_PIN + + //#define BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC EXP1_03_PIN + + //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + //#define KILL_PIN 31 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + // TO TEST + //#define DOGLCD_CS 29 + //#define DOGLCD_A0 27 + + //#define BEEPER_PIN 23 + //#define LCD_BACKLIGHT_PIN 33 + + //#define BTN_EN1 EXP1_08_PIN + //#define BTN_EN2 EXP1_05_PIN + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_01_PIN + //#define KILL_PIN EXP1_10_PIN + + #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) + + // TO TEST + //#define BEEPER_PIN EXP1_05_PIN + //#define BTN_ENC EXP1_08_PIN + //#define SD_DETECT_PIN EXP2_01_PIN + + //#ifndef KILL_PIN + // #define KILL_PIN EXP1_10_PIN + //#endif + + #if ENABLED(MKS_MINI_12864) + + // TO TEST + //#define DOGLCD_A0 27 + //#define DOGLCD_CS 25 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define BTN_EN1 31 + //#define BTN_EN2 33 + + #elif ENABLED(FYSETC_MINI_12864) + + // From https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8 + + // TO TEST + //#define DOGLCD_A0 16 + //#define DOGLCD_CS 17 + + //#define BTN_EN1 33 + //#define BTN_EN2 31 + + //#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 23 // 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 + // TO TEST + //#define RGB_LED_R_PIN 25 + #endif + #ifndef RGB_LED_G_PIN + // TO TEST + //#define RGB_LED_G_PIN 27 + #endif + #ifndef RGB_LED_B_PIN + // TO TEST + //#define RGB_LED_B_PIN 29 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + // TO TEST + //#define NEOPIXEL_PIN 25 + #endif + + #endif + + #elif ENABLED(MINIPANEL) + + // TO TEST + //#define BEEPER_PIN EXP2_06_PIN + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + //#define BTN_EN1 EXP1_09_PIN + //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 + //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 + + //#define SD_DETECT_PIN EXP2_01_PIN + //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // TO TEST + + #else + + // Beeper on AUX-4 + //#define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + // TO TEST + //#define SHIFT_OUT_PIN EXP1_09_PIN + //#define SHIFT_CLK_PIN EXP2_04_PIN + //#define SHIFT_LD_PIN EXP2_06_PIN + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 + #elif ENABLED(PANEL_ONE) + // TO TEST + //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) + //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) + //#define BTN_ENC EXP2_01_PIN // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 EXP1_05_PIN + //#define BTN_EN2 EXP1_08_PIN + //#define BTN_ENC 31 + #endif + + #if ENABLED(G3D_PANEL) + // TO TEST + //#define SD_DETECT_PIN EXP2_01_PIN + //#define KILL_PIN EXP1_10_PIN + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +/** + * Bricolemon has an SD slot, but to change it to your LCD or Custom, set the option to one of the following: + * + * LCD - Use the SD drive in the external LCD controller. + * ONBOARD - Use the SD drive on the control board. + * CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file). + * + * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] + */ + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDSS 83 + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 95 +#else + #define SDSS EXP2_07_PIN +#endif + +#if HAS_TMC_UART + + /** + * Address for the UART Configuration of the TMC2209. Override in Configuration files. + * To test TMC2209 Steppers enable TMC_DEBUG in Configuration_adv.h and test the M122 command with voltage on the steppers. + */ + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0b00 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 0b01 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 0b10 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0b11 + #endif + #ifndef E1_SLAVE_ADDRESS + #define E1_SLAVE_ADDRESS 0b00 + #endif + + /** + * TMC2208/TMC2209 stepper drivers + * It seems to work perfectly fine on Software Serial, if an advanced user wants to test, you could use the SAMD51 Serial1 and Serial 2. Be careful with the Sercom configurations. + * Steppers 1,2,3,4 (X,Y,Z,E0) are on the Serial1, Sercom (RX = 0, TX = 1), extra stepper 5 (E1 or any axis you want) is on Serial2, Sercom (RX = 17, TX = 16) + */ + + //#define X_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial2 + + #define TMC_BAUD_RATE 250000 + + // + // Software serial + // + #define X_SERIAL_TX_PIN 0 + #define X_SERIAL_RX_PIN 1 + + #define Y_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define Z_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Z_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E0_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define E0_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E1_SERIAL_TX_PIN 17 + #define E1_SERIAL_RX_PIN 16 + +#endif diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 449ae0273e23..406162c0896e 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -413,7 +413,6 @@ // TO TEST //#define DOGLCD_CS 45 //#define DOGLCD_A0 44 - //#define LCD_SCREEN_ROT_180 //#define BEEPER_PIN 33 //#define STAT_LED_RED_PIN 32 @@ -426,6 +425,8 @@ //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board //#define KILL_PIN 31 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) // TO TEST @@ -460,18 +461,14 @@ //#define DOGLCD_A0 27 //#define DOGLCD_CS 25 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - // not connected to a pin //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) //#define BTN_EN1 31 //#define BTN_EN2 33 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(FYSETC_MINI_12864) // From https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8 @@ -518,12 +515,6 @@ //#define DOGLCD_A0 44 //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - //#define BTN_EN1 40 //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 @@ -531,6 +522,8 @@ //#define SD_DETECT_PIN 49 //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ZONESTAR_LCD) // TO TEST diff --git a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h index 1b37940e2a0a..a450515a79ff 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h @@ -68,7 +68,7 @@ #if SERVO0_PIN == BEEPER_PIN #undef BEEPER_PIN #endif -#elif ENABLED(FILAMENT_RUNOUT_SENSOR) +#elif HAS_FILAMENT_SENSOR #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 27 #endif diff --git a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h index 02f4a6e985b6..8471d1c7f5f3 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h @@ -135,7 +135,7 @@ #define LCD_BACKLIGHT_PIN 17 // LCD backlight LED #endif -#if NONE(SPINDLE_FEATURE, LASER_FEATURE) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(IS_ULTRA_LCD, IS_NEWPANEL) // try to use IO Header +#if !HAS_CUTTER && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(IS_ULTRA_LCD, IS_NEWPANEL) // try to use IO Header #define CASE_LIGHT_PIN 4 // Hardware PWM - see if IO Header is available #endif @@ -207,11 +207,7 @@ #endif - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_0 - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #elif ENABLED(ZONESTAR_LCD) // For the Tronxy Melzi boards diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index cb2dec160029..0a8143c37600 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -146,7 +146,7 @@ #define FAN1_PIN -1 // -//filament run out sensor +// Filament Runout Sensor // #if EITHER(Z6S_ZFAULT, Z6BS_ZFAULT) #define FIL_RUNOUT_PIN 13 @@ -162,32 +162,38 @@ #endif #define SD_DETECT_PIN -1 -/*=================================================== - * ZMIB Version 1 - EXP1 Connector - * MOSI(D5) TX1(D11) ENA(D12) ENC(D29/A2) 5V - * SCK(D7) RX1(D10) SCS(D4) ENB(D2) GND - *=================================================== - * ZMIB Version 2 - EXP1 Connector - * MOSI(D5) TX1(D11) ENA(D12) ENC(D29/A2) 5V - * SCK(D7) RX1(D10) SCS(D3) ENB(D2) GND - *=================================================== - * LCD 128x64 - *==================================================*/ +/** EXP1 + * ------ + * (MOSI) D5 |10 9 | D7 (SCK) + * (CS) D11 | 8 7 | D10 (DC/D4) + * (EN2) D12 6 5 | D4 or D3 (EN/RS) + * (ENC) D29 | 4 3 | D2 (EN1) + * (GND) | 2 1 | (5V) + * ------ + */ +#define EXP1_03_PIN 2 +#define EXP1_04_PIN 29 +#ifndef IS_ZMIB_V2 + #define EXP1_05_PIN 4 // ZMIB V1 +#else + #define EXP1_05_PIN 3 // ZMIB V2 +#endif +#define EXP1_06_PIN 12 +#define EXP1_07_PIN 10 +#define EXP1_08_PIN 11 +#define EXP1_09_PIN 7 +#define EXP1_10_PIN 5 #if ENABLED(ZONESTAR_12864LCD) // // LCD 128x64 // - #define LCDSCREEN_NAME "ZONESTAR_12864LCD" + #define LCDSCREEN_NAME "ZONESTAR_12864LCD" #define FORCE_SOFT_SPI - //#define LCD_SDSS 11 - #define LCD_PINS_RS 11 // ST7920_CS_PIN LCD_PIN_RS (PIN4 of LCD module) - #ifdef IS_ZMIB_V2 - #define LCD_PINS_ENABLE 3 // ST7920_DAT_PIN LCD_PIN_R/W (PIN5 of LCD module) - #else - #define LCD_PINS_ENABLE 4 // ST7920_DAT_PIN LCD_PIN_R/W (PIN5 of LCD module) - #endif - #define LCD_PINS_D4 10 // ST7920_CLK_PIN LCD_PIN_ENABLE (PIN6 of LCD module) + //#define LCD_SDSS EXP1_08_PIN + #define LCD_PINS_RS EXP1_08_PIN // ST7920_CS_PIN (LCD module pin 4) + #define LCD_PINS_ENABLE EXP1_05_PIN // ST7920_DAT_PIN (LCD module pin 5) + #define LCD_PINS_D4 EXP1_07_PIN // ST7920_CLK_PIN (LCD module pin 6) #define BOARD_ST7920_DELAY_1 DELAY_2_NOP #define BOARD_ST7920_DELAY_2 DELAY_2_NOP @@ -199,34 +205,28 @@ // #define LCDSCREEN_NAME "ZONESTAR 12864OLED" #define FORCE_SOFT_SPI - #ifdef IS_ZMIB_V2 - #define LCD_PINS_RS 3 // RESET - #else - #define LCD_PINS_RS 4 // RESET - #endif - #define LCD_PINS_DC 10 // DC - #define DOGLCD_CS 11 // CS + #define LCD_PINS_RS EXP1_05_PIN + #define LCD_PINS_DC EXP1_07_PIN + #define DOGLCD_CS EXP1_08_PIN + #if ENABLED(OLED_HW_IIC) #error "Oops! can't choose HW IIC for ZMIB board!!" - #elif ENABLED(OLED_HW_SPI) - // HW SPI - #define DOGLCD_A0 LCD_PINS_DC // A0 = DC #else - // SW SPI - #define DOGLCD_A0 LCD_PINS_DC // A0 = DC - #define DOGLCD_MOSI AVR_MOSI_PIN // SDA - #define DOGLCD_SCK AVR_SCK_PIN // SCK + #define DOGLCD_A0 LCD_PINS_DC + #if DISABLED(OLED_HW_SPI) + #define DOGLCD_MOSI AVR_MOSI_PIN // Software SPI + #define DOGLCD_SCK AVR_SCK_PIN + #endif #endif - #endif // // All the above are also RRDSC with rotary encoder // #if IS_RRD_SC - #define BTN_EN1 2 - #define BTN_EN2 12 - #define BTN_ENC 29 + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_06_PIN + #define BTN_ENC EXP1_04_PIN #define BEEPER_PIN -1 #define KILL_PIN -1 #endif diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index 5f2bd0467e1c..f9911cc863fa 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -155,7 +155,7 @@ #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #if PIN_EXISTS(I_MIN) #define _I_MIN I_MIN_PIN, @@ -201,7 +201,7 @@ #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #if PIN_EXISTS(J_MIN) #define _J_MIN J_MIN_PIN, @@ -247,7 +247,7 @@ #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #if PIN_EXISTS(K_MIN) #define _K_MIN K_MIN_PIN, diff --git a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h index 299b9ff49cee..904a9a56fac6 100644 --- a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h +++ b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h @@ -45,8 +45,8 @@ // // Timers // -#define STEP_TIMER 6 -#define TEMP_TIMER 7 +#define STEP_TIMER 6 +#define TEMP_TIMER 7 // // Limit Switches diff --git a/Marlin/src/pins/stm32f1/pins_BEAST.h b/Marlin/src/pins/stm32f1/pins_BEAST.h index 2ace47822e16..d494b29c1448 100644 --- a/Marlin/src/pins/stm32f1/pins_BEAST.h +++ b/Marlin/src/pins/stm32f1/pins_BEAST.h @@ -93,7 +93,7 @@ #define FAN_PIN PB10 #endif -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Temperature Sensors diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h index 8368fd03cd9c..7b8abb130060 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h @@ -70,9 +70,14 @@ // // Probe // -#define PROBE_TARE_PIN PA1 +#ifndef PROBE_TARE_PIN + #define PROBE_TARE_PIN PA1 +#endif + #if ENABLED(PROBE_ACTIVATION_SWITCH) - #define PROBE_ACTIVATION_SWITCH_PIN PC2 // Optoswitch to Enable Z Probe + #ifndef PROBE_ACTIVATION_SWITCH_PIN + #define PROBE_ACTIVATION_SWITCH_PIN PC2 // Optoswitch to Enable Z Probe + #endif #endif // @@ -108,7 +113,7 @@ #define HEATER_BED_PIN PC9 // HOT BED #define FAN_PIN PC6 // FAN -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED #define CONTROLLER_FAN_PIN PC7 diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index dae43d3c13ed..704501de108b 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -156,14 +156,14 @@ #define USB_CONNECT_INVERTING false /** - * ----- - * 5V | 1 2 | GND - * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) - * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PB6 | 9 10| PA15 (BEEPER) - * ----- - * EXP1 + * ------ + * (BEEPER) PA15 |10 9 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 8 7 | RESET + * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 4 3 | PB7 (LCD_EN) + * GND | 2 1 | 5V + * ------ + * EXP1 */ #if HAS_WIRED_LCD @@ -195,13 +195,13 @@ #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) /** Creality Ender-2 display pinout - * ----- - * 5V | 1 2 | GND - * (MOSI) PB7 | 3 4 | PB8 (LCD_RS) - * (LCD_A0) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PB6 | 9 10| PA15 (SCK) - * ----- + * ------ + * (SCK) PA15 |10 9 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 8 7 | RESET + * (BTN_EN2) PA10 6 5 | PB9 (LCD_A0) + * (LCD_RS) PB8 | 4 3 | PB7 (MOSI) + * GND | 2 1 | 5V + * ------ * EXP1 */ @@ -228,15 +228,15 @@ /** FYSETC TFT TFT81050 display pinout * - * Board Display - * ----- ----- - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 PA10 (SD_CS) (PB8) LCD_CS | 5 6 MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PA15) SD_DET | 7 8 | RESET - * (BEEPER) PB6 | 9 10| PA15 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * Board Display + * ------ ------ + * (SD_DET) PA15 |10 9 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 6 5 | PB9 (MOSI) 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * 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 c132691c2090..5b48d7cadbcf 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 @@ -120,11 +120,11 @@ /** * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 * ------ ------ - * 5V | 1 2 | GND 5V | 1 2 | GND - * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) (LCD_EN) PB15 | 3 4 | PB8 (LCD_RS) - * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PB6 | 9 10 | PB5 (BEEPER) (BTN_ENC) PA15 | 9 10 | PB5 (BEEPER) + * (BEEPER) PB5 |10 9 | PB6 (BTN_ENC) (BEEPER) PB5 |10 9 | PA15 (BTN_ENC) + * (BTN_EN1) PA9 | 8 7 | RESET (BTN_EN1) PA9 | 8 7 | RESET + * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 4 3 | PB7 (LCD_EN) (LCD_RS) PB8 | 4 3 | PB15 (LCD_EN) + * GND | 2 1 | 5V GND | 2 1 | 5V * ------ ------ * EXP1 EXP1 */ @@ -136,16 +136,16 @@ #define EXP1_3 PB7 #endif -#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** - * ------ ------ ------ - * VCC | 1 2 | GND VCC | 1 2 | GND GND | 2 1 | VCC - * A | 3 4 | B A | 3 4 | B B | 4 3 | A - * | 5 6 TX BEEP | 5 6 ENT ENT | 6 5 | BEEP - * | 7 8 | RX TX | 7 8 | RX RX | 8 7 | TX - * BEEP | 9 10 | ENT | 9 10 | | 10 9 | - * ------ ------ ------ - * EXP1 DWIN DWIN (plug) + * ------ ------ ------ + * (ENT) |10 9 | (BEEP) |10 9 | |10 9 | + * (RX) | 8 7 | (RX) | 8 7 | (TX) RX | 8 7 | TX + * (TX) 6 5 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP + * (B) | 4 3 | (A) (B) | 4 3 | (A) B | 4 3 | A + * GND | 2 1 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) * * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. */ @@ -206,15 +206,15 @@ /** * TFTGLCD_PANEL_SPI display pinout * - * Board Display - * ------ ------ - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) LCD_CS | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 | PA10 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | (FREE) - * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V - * ------ ------ - * EXP1 EXP1 + * Board Display + * ------ ------ + * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 8 7 | RESET -- | 8 7 | (SD_DET) + * (SD_CS) PA10 6 5 | PB9 (MOSI) | 6 5 | -- + * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (LCD_CS) + * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * @@ -236,8 +236,72 @@ #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #error "CAUTION! FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." + + /** + * FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 display pinout + * + * Board Display + * ------ ------ + * PB5 |10 9 | PA15 (BEEP) |10 9 | BTN_ENC + * PA9 | 8 7 | RESET LCD_CS | 8 7 | LCD A0 + * PA10 | 6 5 | PB9 LCD_RST | 6 5 | RED + * PB8 | 4 3 | PB15 (GREEN) | 4 3 | (BLUE) + * GND | 2 1 | 5V GND | 2 1 | 5V + * ------ ------ + * EXP1 EXP1 + * + * --- ------ + * RST | 1 | (MISO) |10 9 | SCK + * (RX2) PA2 | 2 | BTN_EN1 | 8 7 | (SS) + * (TX2) PA3 | 3 | BTN_EN2 | 6 5 | MOSI + * GND | 4 | (CD) | 4 3 | (RST) + * 5V | 5 | (GND) | 2 1 | (KILL) + * --- ------ + * TFT EXP2 + * + * Needs custom cable: + * + * Board Display + * + * EXP1-1 ----------- EXP1-1 + * EXP1-2 ----------- EXP1-2 + * EXP1-3 ----------- EXP2-6 + * EXP1-4 ----------- EXP1-5 + * EXP1-5 ----------- EXP2-8 + * EXP1-6 ----------- EXP1-6 + * EXP1-8 ----------- EXP1-8 + * EXP1-9 ----------- EXP1-9 + * EXP1-10 ----------- EXP1-7 + * + * TFT-2 ----------- EXP2-9 + * TFT-3 ----------- EXP2-5 + * + * for backlight configuration see steps 2 (V2.1) and 3 in https://wiki.fysetc.com/Mini12864_Panel/ + */ + + #define LCD_PINS_RS PA9 // CS + #define LCD_PINS_ENABLE PA3 // MOSI + #define LCD_BACKLIGHT_PIN -1 + #define NEOPIXEL_PIN PB8 + #define LCD_CONTRAST 255 + #define LCD_RESET_PIN PA10 + + #define DOGLCD_CS PA9 + #define DOGLCD_A0 PB5 + #define DOGLCD_SCK PA2 + #define DOGLCD_MOSI PA3 + + #define BTN_ENC PA15 + #define BTN_EN1 PB9 + #define BTN_EN2 PB15 + + #define FORCE_SOFT_SPI + #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, TFTGLCD_PANEL_(SPI|I2C), FYSETC_MINI_12864_2_1, MKS_MINI_12864_V3, and BTT_MINI_12864_V1 are currently supported on the BIGTREE_SKR_MINI_E3." #endif #endif // HAS_WIRED_LCD @@ -249,15 +313,15 @@ /** * FYSETC TFT TFT81050 display pinout * - * Board Display - * ------ ------ - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 | PA10 (SD_CS) (PB8) LCD_CS | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | RESET - * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V - * ------ ------ - * EXP1 EXP1 + * Board Display + * ------ ------ + * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 6 5 | PB9 (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index a6cc5ffa60fb..a92de805f75b 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -98,7 +98,7 @@ * (LCD_EN) PB6 | 8 7 | PC12 (LCD_RS) (BTN_EN1) PD2 | 8 7 | PA15 (SD_SS) * (LCD_D4) PC13 6 5 | PB7 (LCD_D5) (BTN_EN2) PB8 6 5 | PB5 (MOSI) * (LCD_D6) PC15 | 4 3 | PC14 (LCD_D7) (SD_DETECT) PB9 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index 2d33fb9f2cc2..1f56e59a23c5 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -87,7 +87,7 @@ #define FAN_PIN PG14 // MAIN BOARD FAN #endif -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Temperature Sensors @@ -178,7 +178,6 @@ // Pins for DOGM SPI LCD Support #define DOGLCD_A0 PC12 // 44 #define DOGLCD_CS PC13 // 45 - #define LCD_SCREEN_ROT_180 #define BTN_EN1 PB6 // 22 #define BTN_EN2 PA7 // 7 @@ -192,6 +191,8 @@ #define STAT_LED_RED_PIN PC0 // 32 #define STAT_LED_BLUE_PIN PC3 // 35 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #define BTN_EN1 PC3 // 35 #define BTN_EN2 PC5 // 37 @@ -214,11 +215,7 @@ #define SDSS PD5 // 53 #define KILL_PIN PE0 // 64 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + // The encoder and click button #define BTN_EN1 PC8 // 40 #define BTN_EN2 PD15 // 63 @@ -226,6 +223,8 @@ // not connected to a pin #define SD_DETECT_PIN PD1 // 49 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else // Beeper on AUX-4 diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h index afe58df803d6..53b6797e91d2 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -23,6 +23,6 @@ #define BOARD_INFO_NAME "Chitu3D V5" -#define Z_STOP_PIN PG9 +#define Z_STOP_PIN PA14 #include "pins_CHITU3D_common.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h index ffd7baa00c4d..9d7e0f695b79 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality v2.4.S1 (STM32F103RE) v101 as found in the Ender 7 board pin assignments + * Creality v2.4.S1 (STM32F103RE / STM32F103RC) v101 as found in the Ender 7 board pin assignments */ #define BOARD_INFO_NAME "Creality v2.4.S1 V101" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h new file mode 100644 index 000000000000..fb7198e57c21 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h @@ -0,0 +1,88 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * Creality V24S1_301 (STM32F103RE / STM32F103RC) board pin assignments as found on Ender 3 S1 + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality V24S1 only supports one hotend / E-stepper. Comment out this line to continue." +#endif + +#if BOTH(BLTOUCH, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #error "Disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN when using BLTOUCH with Creality V24S1-301." +#endif + +#define BOARD_INFO_NAME "Creality V24S1-301" +#define DEFAULT_MACHINE_NAME "Ender 3 S1" + +// +// Servos +// +#if !defined(SERVO0_PIN) && !defined(HAS_PIN_27_BOARD) + #define SERVO0_PIN PC13 // BLTouch OUT +#endif + +// +// Limit Switches +// +#define Z_STOP_PIN PA15 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC14 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // "Pulled-high" +#endif + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PA7 // HOT BED +#define FAN1_PIN PC0 // extruder fan + +// +// SD Card +// +#define ONBOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PA4 // SDSS + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + //#define HEATER_0_PIN -1 + //#define HEATER_BED_PIN -1 + #define FAN_PIN -1 + #define SPINDLE_LASER_ENA_PIN PA0 // FET 1 + #define SPINDLE_LASER_PWM_PIN PA0 // Bed FET + #define SPINDLE_DIR_PIN PA0 // FET 4 +#endif + +#include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index bf2a55fc7b99..d6d496624121 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality 4.2.x (STM32F103RET6) board pin assignments + * Creality 4.2.x (STM32F103RE / STM32F103RC) board pin assignments */ #include "env_validate.h" @@ -72,7 +72,9 @@ // #define X_STOP_PIN PA5 #define Y_STOP_PIN PA6 -#define Z_STOP_PIN PA7 +#ifndef Z_STOP_PIN + #define Z_STOP_PIN PA7 +#endif #ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN PB1 // BLTouch IN @@ -143,17 +145,13 @@ #ifndef FAN_PIN #define FAN_PIN PA0 // FAN #endif -#if PIN_EXISTS(FAN) - #define FAN_SOFT_PWM -#endif +#define FAN_SOFT_PWM_REQUIRED // // SD Card // #define SD_DETECT_PIN PC7 #define SDCARD_CONNECTION ONBOARD -#define ONBOARD_SPI_DEVICE 1 -#define ONBOARD_SD_CS_PIN PA4 // SDSS #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer @@ -189,7 +187,7 @@ #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." #endif -#elif EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI // RET6 DWIN ENCODER LCD #define BTN_ENC PB14 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h index ae54805a94c6..7bf34441bcf4 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (C) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY 4.2.10 (STM32F103) board pin assignments + * CREALITY 4.2.10 (STM32F103RE / STM32F103RC) board pin assignments */ #include "env_validate.h" @@ -144,7 +144,7 @@ #define HEATER_BED_PIN PA1 // HOT BED #define FAN_PIN PA2 // FAN -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // SD Card @@ -167,7 +167,7 @@ * PB10 | 8 7 | PE8 * PB14 6 5 | PB13 * PB12 | 4 3 | PB15 - * GND | 2 1 | 5V + * GND | 2 1 | 5V * ------ * EXP1 */ @@ -191,7 +191,7 @@ * PB10 | 8 7 | ? * PA6 6 5 | PA5 * PA4 | 4 3 | PA7 - * GND | 2 1 | 5V + * GND | 2 1 | 5V * ------ * EXP1 */ @@ -216,7 +216,7 @@ #define BTN_EN1 EXP1_08_PIN #define BTN_EN2 EXP1_06_PIN -#elif EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI // RET6 DWIN ENCODER LCD #define BTN_ENC PB14 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h new file mode 100644 index 000000000000..5499adb07668 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h @@ -0,0 +1,31 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * CREALITY v4.2.2 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#define BOARD_INFO_NAME "Creality v4.2.2" +#define DEFAULT_MACHINE_NAME "Creality3D" + +#include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h new file mode 100644 index 000000000000..c174b0e56ed6 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h @@ -0,0 +1,44 @@ +/** + * 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 + +/** + * CREALITY v4.2.3 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#define BOARD_INFO_NAME "Creality v4.2.3" +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Heaters +// +#define HEATER_BED_PIN PB10 // HOT BED + +#include "pins_CREALITY_V4.h" + +// +// Encoder +// +#if BTN_EN1 == PB10 + #undef BTN_EN1 + #define BTN_EN1 PA2 // Rotary Encoder +#endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h index c327abee7796..077f4c73a657 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY v4.2.7 (STM32F103) board pin assignments + * CREALITY v4.2.7 (STM32F103RE / STM32F103RC) board pin assignments */ #define BOARD_INFO_NAME "Creality v4.2.7" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h index 2f1f2ffb4113..9226b537d91b 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY v4.3.1 (STM32F103) board pin assignments + * CREALITY v4.3.1 (STM32F103RE / STM32F103RC) board pin assignments */ #define BOARD_INFO_NAME "Creality v4.3.1" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h index 7d3140056a0d..ced64e2a893c 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality v4.5.2 (STM32F103RET6) board pin assignments + * Creality v4.5.2 (STM32F103RE / STM32F103RC) board pin assignments */ #if HAS_MULTI_HOTEND || E_STEPPERS > 1 @@ -36,7 +36,9 @@ #define FAN_PIN PA0 // FAN #if ENABLED(PROBE_ACTIVATION_SWITCH) - #define PROBE_ACTIVATION_SWITCH_PIN PC6 // Optoswitch to Enable Z Probe + #ifndef PROBE_ACTIVATION_SWITCH_PIN + #define PROBE_ACTIVATION_SWITCH_PIN PC6 // Optoswitch to Enable Z Probe + #endif #endif #include "pins_CREALITY_V45x.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h index b669887d1eaf..e7296d1ed077 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality v4.5.3 (STM32F103RET6) board pin assignments + * Creality v4.5.3 (STM32F103RE / STM32F103RC) board pin assignments */ #if HAS_MULTI_HOTEND || E_STEPPERS > 1 @@ -36,7 +36,9 @@ #define FAN_PIN PB15 // FAN #if ENABLED(PROBE_ACTIVATION_SWITCH) - #define PROBE_ACTIVATION_SWITCH_PIN PB2 // Optoswitch to Enable Z Probe + #ifndef PROBE_ACTIVATION_SWITCH_PIN + #define PROBE_ACTIVATION_SWITCH_PIN PB2 // Optoswitch to Enable Z Probe + #endif #endif #include "pins_CREALITY_V45x.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h index 39dccf1271af..85d279872d55 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h @@ -64,7 +64,9 @@ // // Probe // -#define PROBE_TARE_PIN PA5 +#ifndef PROBE_TARE_PIN + #define PROBE_TARE_PIN PA5 +#endif // // Steppers @@ -95,7 +97,7 @@ // Heaters / Fans // -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // SD Card diff --git a/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h b/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h index fea5b00b50d8..0682bfd73620 100644 --- a/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h @@ -38,10 +38,9 @@ //#define DISABLE_DEBUG #define DISABLE_JTAG //#define ENABLE_SPI3 -#define FLASH_EEPROM_EMULATION -#define FAN_SOFT_PWM -#if ENABLED(FLASH_EEPROM_EMULATION) +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) @@ -118,6 +117,8 @@ #endif #endif +#define FAN_SOFT_PWM_REQUIRED + // // Misc. Functions // diff --git a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index e19d3300921a..947e36c765e7 100644 --- a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h +++ b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -41,7 +41,7 @@ #define BOARD_NO_NATIVE_USB // Avoid conflict with TIMER_SERVO when using the STM32 HAL -#define TEMP_TIMER 5 +#define TEMP_TIMER 5 // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role diff --git a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h index e4c741eae7f9..5468d0b4bd7c 100644 --- a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h @@ -30,10 +30,12 @@ // // Flash EEPROM Emulation // -#define FLASH_EEPROM_EMULATION -#define EEPROM_PAGE_SIZE 0x800 // 2KB -#define EEPROM_START_ADDRESS (0x8000000 + 256 * 1024 - 2 * EEPROM_PAGE_SIZE) // 256K firmware space -#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE 0x800 // 2KB + #define EEPROM_START_ADDRESS (0x8000000 + 256 * 1024 - 2 * EEPROM_PAGE_SIZE) // 256K firmware space + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif // // Servos @@ -123,9 +125,9 @@ /** ------ ------ * (BEEPER) PC14 |10 9 | PC13 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SD_SCK) * (LCD_EN) PB9 | 8 7 | PB8 (LCD_RS) (BTN_EN1) PB3 | 8 7 | PB12 (SD_CS2) - * (LCD_D4) PB7 | 6 5 PB6 (LCD_D5) (BTN_EN2) PD2 | 6 5 PB15 (SD_MOSI) + * (LCD_D4) PB7 6 5 | PB6 (LCD_D5) (BTN_EN2) PD2 6 5 | PB15 (SD_MOSI) * (LCD_D6) PB5 | 4 3 | PB4 (LCD_D7) (SD_DETECT) PB11 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index 7ffe67c4f86b..de91db22d554 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -166,9 +166,7 @@ #endif //#define LCD_CONTRAST_INIT 190 - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 0c2f2fc5db31..e0f906bf9ecc 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -163,13 +163,11 @@ #define DOGLCD_CS EXP1_04_PIN #define DOGLCD_SCK EXP1_05_PIN #define DOGLCD_MOSI EXP1_03_PIN - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 #if EITHER(FYSETC_MINI_12864, U8GLIB_ST7920) #define FORCE_SOFT_SPI #endif + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif #define LCD_PINS_RS EXP1_04_PIN // CS -- SOFT SPI for ENDER3 LCD diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h index 520764a503bc..03547381c010 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h @@ -186,7 +186,7 @@ #ifdef GTM32_PRO_VB_USE_LCD_BEEPER // This is pin 32 on J2 FFC40 and pin, goes to the beeper // on Geeetech's version of RepRapDiscount Smart Controller - // (e.g. on Rostock 301) + // (e.g., on Rostock 301) #define BEEPER_PIN PE12 #else // This is the beeper on the board itself diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 3a8019a27e9c..ac11bd8b38b8 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -89,16 +89,19 @@ #define HEATER_BED_PIN PA8 // pin 67 (Hot Bed Mosfet) #define FAN_PIN PA15 // pin 77 (4cm Fan) -#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 + +#if TERN(MAPLE_STM32F1, ENABLED(FAN_SOFT_PWM), ENABLED(FAST_PWM_FAN)) && FAN_MIN_PWM < 5 // Required to avoid issues with heating or STLink + #error "FAN_MIN_PWM must be 5 or higher." // Fan will not start in 1-30 range +#endif + +#if defined(MAPLE_STM32F1) || DISABLED(FAST_PWM_FAN) // STM32 HAL required to allow TIMER2 Hardware PWM + #define FAN_SOFT_PWM_REQUIRED #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 + #if FAST_PWM_FAN_FREQUENCY <= 1000 // Default 1000 is noisy, max 65K (uint16) + #error "FAST_PWM_FAN_FREQUENCY must be greater than 1000." + #elif FAST_PWM_FAN_FREQUENCY > 65535 + #error "FAST_PWM_FAN_FREQUENCY must be less than 65536." + #endif #endif //#define BEEPER_PIN PD13 // pin 60 (Servo PWM output 5V/GND on Board V0G+) made for BL-Touch sensor @@ -154,7 +157,7 @@ #if defined(TFT_BACKLIGHT_PWM) && !defined(MAPLE_STM32F1) #define HAS_LCD_BRIGHTNESS 1 - #define DEFAULT_LCD_BRIGHTNESS TFT_BACKLIGHT_PWM + #define LCD_BRIGHTNESS_DEFAULT TFT_BACKLIGHT_PWM #endif #if ENABLED(SDIO_SUPPORT) diff --git a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h index 32d1937653d7..94e53400996e 100644 --- a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h +++ b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h @@ -47,8 +47,8 @@ // On STM32F103: // PB3, PB6, PB7, and PB8 can be used with pwm, which rules out TIM2 and TIM4. // On STM32F070, 16 and 17 are in use, but 1 and 3 are available. -#define STEP_TIMER 1 -#define TEMP_TIMER 3 +#define STEP_TIMER 1 +#define TEMP_TIMER 3 // // Limit Switches diff --git a/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h b/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h index 3fed0adac336..87526bac8797 100644 --- a/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h @@ -22,16 +22,16 @@ #pragma once /** - * MKS Robin mini (STM32F103VET6) board pin assignments + * MPX ARM MINI (STM32F103ZET6) board pin assignments */ #if NOT_TARGET(STM32F1, STM32F1xx) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" -#elif HOTENDS > 2 || E_STEPPERS > 2 - #error "MKS Robin supports up to 2 hotends / E-steppers. Comment out this line to continue." +#elif HOTENDS > 1 || E_STEPPERS > 1 + #error "MPX ARM Mini only supports one hotend / E-stepper. Comment out this line to continue." #endif -#define BOARD_INFO_NAME "Mingda MPX_ARM_MINI" +#define BOARD_INFO_NAME "Mingda MPX ARM Mini" #define BOARD_NO_NATIVE_USB #define DISABLE_DEBUG @@ -64,9 +64,9 @@ // Limit Switches // #define X_MIN_PIN PD6 -#define X_MAX_PIN PG15 +#define X_MAX_PIN PG15 // To double check #define Y_MIN_PIN PG9 -#define Y_MAX_PIN PG14 +#define Y_MAX_PIN PG14 // To double check #define Z_MIN_PIN PG10 #define Z_MAX_PIN PG13 @@ -137,18 +137,6 @@ // TFT with FSMC interface // #if HAS_FSMC_TFT - /** - * Note: MKS Robin TFT screens use various TFT controllers - * Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240) - * ILI9488 is not supported - * Define init sequences for other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp - * - * If the screen stays white, disable 'TFT_RESET_PIN' - * to let the bootloader init the screen. - * - * Setting an 'TFT_RESET_PIN' may cause a flicker when entering the LCD menu - * because Marlin uses the reset as a failsafe to revive a glitchy LCD. - */ #define TFT_RESET_PIN PF15 #define TFT_BACKLIGHT_PIN PF11 @@ -166,8 +154,8 @@ #endif #if NEED_TOUCH_PINS - #define TOUCH_CS_PIN PA4 // SPI2_NSS - #define TOUCH_SCK_PIN PA5 // SPI2_SCK - #define TOUCH_MISO_PIN PA6 // SPI2_MISO - #define TOUCH_MOSI_PIN PA7 // SPI2_MOSI + #define TOUCH_CS_PIN PA4 // SPI1_NSS + #define TOUCH_SCK_PIN PA5 // SPI1_SCK + #define TOUCH_MISO_PIN PA6 // SPI1_MISO + #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 29baeba934f1..150c18d79a1b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -125,7 +125,7 @@ //#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // -// Filament runout sensor +// Filament Runout Sensor // #define FIL_RUNOUT_PIN PF11 // MT_DET diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index 06b9721403c1..88c5d5f53c73 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -39,7 +39,7 @@ #define MKS_HARDWARE_TEST_ONLY_E0 // Avoid conflict with TIMER_SERVO when using the STM32 HAL -#define TEMP_TIMER 5 +#define TEMP_TIMER 5 // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -314,10 +314,10 @@ #define BEEPER_PIN -1 #endif - #elif ENABLED(MKS_MINI_12864_V3) + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define LCD_PINS_DC PC6 #define DOGLCD_CS PD13 - #define DOGLCD_A0 PC6 - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 DOGLCD_A0 #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN PE14 #define NEOPIXEL_PIN PE15 @@ -326,7 +326,7 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else // !MKS_MINI_12864 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 025c65a38b24..a1a822a9c2f3 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -64,11 +64,6 @@ #define Z_MIN_PROBE_PIN PB1 #endif -// LED driving pin -#ifndef NEOPIXEL_PIN - #define NEOPIXEL_PIN PA2 -#endif - // // Steppers // @@ -150,7 +145,7 @@ * (LCD_EN) PA4 | 8 7 | PA5 (LCD_RS) (BTN_EN1) PB11 | 8 7 | PA15 (SD_SS) (BTN_EN1) PB11 | 8 7 | RESET * (LCD_D4) PA6 6 5 | PA7 (LCD_D5) (BTN_EN2) PB0 6 5 | PB15 (SD_MOSI) (BTN_EN2) PB0 6 5 | PA6 (LCD_D4) * (LCD_D6) PC4 | 4 3 | PC5 (LCD_D7) (SD_DETECT) PC10 | 4 3 | RESET (LCD_RS) PA5 | 4 3 | PA4 (LCD_EN) - * GND | 2 1 | 5V GND | 2 1 | NC GND | 2 1 | 5V + * GND | 2 1 | 5V GND | 2 1 | -- GND | 2 1 | 5V * ------ ------ ------ * EXP1 EXP2 "Ender-3 EXP1" */ @@ -201,10 +196,11 @@ #define DOGLCD_SCK EXP2_09_PIN #define DOGLCD_MOSI EXP2_05_PIN - #elif ENABLED(MKS_MINI_12864_V3) + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #define LCD_PINS_DC EXP1_07_PIN #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN EXP1_06_PIN #define NEOPIXEL_PIN EXP1_05_PIN @@ -212,7 +208,7 @@ #define DOGLCD_SCK EXP2_09_PIN #define FORCE_SOFT_SPI #define SOFTWARE_SPI - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else @@ -245,6 +241,11 @@ #endif #endif +// LED driving pin +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA2 +#endif + // // SD Card // diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index 94f7313996d0..9f33d4392a14 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -79,31 +79,51 @@ #define FIL_RUNOUT_PIN PB8 // MT_DET +/** ------ + * (BEEPER) PD2 |10 9 | PB3 (BTN_ENC) + * (BTN_EN1) PB5 | 8 7 | PA11 (RESET?) + * (BTN_EN2) PB4 6 5 | PC1 (LCD_D4) + * (LCD_RS) PC3 | 4 3 | PC2 (LCD_EN) + * GND | 2 1 | 5V + * ------ + * "E3" EXP1 + */ +#define E3_EXP1_01_PIN -1 // 5V +#define E3_EXP1_02_PIN -1 // GND +#define E3_EXP1_03_PIN PC2 +#define E3_EXP1_04_PIN PC3 +#define E3_EXP1_05_PIN PC1 +#define E3_EXP1_06_PIN PB4 +#define E3_EXP1_07_PIN PA11 // RESET? +#define E3_EXP1_08_PIN PB5 +#define E3_EXP1_09_PIN PB3 +#define E3_EXP1_10_PIN PD2 + // // LCD Pins // #if HAS_WIRED_LCD - #define BEEPER_PIN PD2 - #define BTN_ENC PB3 - #define LCD_PINS_RS PC3 + #define BEEPER_PIN E3_EXP1_10_PIN + #define BTN_ENC E3_EXP1_09_PIN + #define LCD_PINS_RS E3_EXP1_04_PIN - #define BTN_EN1 PB5 - #define BTN_EN2 PB4 + #define BTN_EN1 E3_EXP1_08_PIN + #define BTN_EN2 E3_EXP1_06_PIN - #define LCD_PINS_ENABLE PC2 + #define LCD_PINS_ENABLE E3_EXP1_03_PIN #if ENABLED(MKS_MINI_12864) #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN -1 - #define DOGLCD_A0 PC1 - #define DOGLCD_CS PC2 + #define DOGLCD_A0 E3_EXP1_05_PIN + #define DOGLCD_CS E3_EXP1_03_PIN #define DOGLCD_SCK PB13 #define DOGLCD_MOSI PB15 #else // !MKS_MINI_12864 - #define LCD_PINS_D4 PC1 + #define LCD_PINS_D4 E3_EXP1_05_PIN #if IS_ULTIPANEL #define LCD_PINS_D5 -1 #define LCD_PINS_D6 -1 @@ -141,3 +161,15 @@ #define SD_MISO_PIN PB14 #define SD_MOSI_PIN PB15 #define SD_SS_PIN PA15 + +// EXP1 replace LCD with keys for EasyThreeD ET4000+ Mainboard +#if ENABLED(EASYTHREED_UI) + #define BTN_HOME E3_EXP1_04_PIN // INPUT_PULLUP (unused) + #define BTN_FEED E3_EXP1_09_PIN // Run E Forward + #define BTN_RETRACT E3_EXP1_08_PIN // Run E Backward + #define BTN_PRINT E3_EXP1_07_PIN // Start File Print + #define BTN_HOME_GND E3_EXP1_03_PIN // OUTPUT (LOW) + #define BTN_FEED_GND E3_EXP1_06_PIN // OUTPUT (LOW) + #define BTN_RETRACT_GND E3_EXP1_05_PIN // OUTPUT (LOW) + #define EASYTHREED_LED_PIN E3_EXP1_10_PIN // Indicator LED +#endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index c729274c54cf..115058a19f77 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -45,3 +45,7 @@ //#define LED_PIN PB2 #include "pins_MKS_ROBIN_NANO_common.h" + +#if HAS_TFT_LVGL_UI && FAN1_PIN != PB0 && HEATER_1_PIN != PB0 + #define BOARD_INIT() OUT_WRITE(PB0, LOW) +#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 1cdee92b088d..07ee8c4fa060 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -39,7 +39,7 @@ #define USES_DIAG_PINS // Avoid conflict with TIMER_SERVO when using the STM32 HAL -#define TEMP_TIMER 5 +#define TEMP_TIMER 5 // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -193,7 +193,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW @@ -338,10 +340,10 @@ #define BEEPER_PIN -1 #endif - #elif ENABLED(MKS_MINI_12864_V3) + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define LCD_PINS_DC PC6 #define DOGLCD_CS PD13 - #define DOGLCD_A0 PC6 - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 DOGLCD_A0 #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN PE14 #define NEOPIXEL_PIN PE15 @@ -350,7 +352,7 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else // !MKS_MINI_12864 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h index c76175a35c1b..e057e13c25f0 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h @@ -32,7 +32,7 @@ #define BOARD_NO_NATIVE_USB // Avoid conflict with TIMER_SERVO when using the STM32 HAL -#define TEMP_TIMER 5 +#define TEMP_TIMER 5 // // EEPROM @@ -98,15 +98,6 @@ #ifndef HEATER_0_PIN #define HEATER_0_PIN PC3 #endif -#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) - #ifndef FAN1_PIN - #define FAN1_PIN PB0 - #endif -#else - #ifndef HEATER_1_PIN - #define HEATER_1_PIN PB0 - #endif -#endif #ifndef FAN_PIN #define FAN_PIN PB1 // FAN #endif @@ -114,12 +105,22 @@ #define HEATER_BED_PIN PA0 #endif +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #ifndef FAN1_PIN + #define FAN1_PIN PB0 + #endif +#elif !defined(HEATER_1_PIN) + #define HEATER_1_PIN PB0 +#endif + // // Power Supply Control // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index a738a4faa259..53f207adb7ab 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -185,7 +185,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PG11 #define SUICIDE_PIN_STATE LOW diff --git a/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h new file mode 100644 index 000000000000..7f4aa563b01c --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h @@ -0,0 +1,222 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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" + +#define BOARD_INFO_NAME "PANDA PI V2.9" + +// Release PB3/PB4 (TMC_SW Pins) from JTAG pins +#define DISABLE_JTAG + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB +#endif + +// +// Servos +// +#define SERVO0_PIN PA11 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PA3 // X-STOP +#define Y_STOP_PIN PC9 // Y-STOP +#define Z_STOP_PIN PA1 // Z-STOP + +// +// Z Probe must be this pin +// +//#define Z_MIN_PROBE_PIN PA1 // PROBE + +// +// Filament Runout Sensor +// +//#ifndef FIL_RUNOUT_PIN +// #define FIL_RUNOUT_PIN PC2 // E0-STOP +//#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC12 +#define X_STEP_PIN PC11 +#define X_DIR_PIN PB6 + +#define Y_ENABLE_PIN PC12 +#define Y_STEP_PIN PB5 +#define Y_DIR_PIN PB4 + +#define Z_ENABLE_PIN PC12 +#define Z_STEP_PIN PB3 +#define Z_DIR_PIN PA15 + +#define E0_ENABLE_PIN PC12 +#define E0_STEP_PIN PB15 +#define E0_DIR_PIN PB14 + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB5 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB4 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB3 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD2 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB0 // Analog Input "TH0" +#define TEMP_BED_PIN PB1 // Analog Input "TB0" +#define TEMP_1_PIN PA2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB12 // "HE" +#define HEATER_BED_PIN PB13 // "HB" +#define FAN_PIN PA8 // "FAN0" +#define HEATER_1_PIN PA12 + +// +// SD Support +// +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card +#define SDSS ONBOARD_SD_CS_PIN + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif +#if SD_CONNECTION_IS(ONBOARD) + //#define SD_DETECT_PIN PA4 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BTN_ENC PA0 + #define BTN_EN1 PC4 + #define BTN_EN2 PC5 + + #define LCD_PINS_RS PC0 + #define LCD_PINS_ENABLE PC2 + #define LCD_PINS_D4 PC1 +#endif + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_E3_DIP.h' for details. Comment out this line to continue." + + /** FYSETC TFT TFT81050 display pinout + * + * Board Display + * ----- ----- + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) + * (FREE) PB9 | 5 6 PA10 (SD_CS) (PB8) LCD_CS | 5 6 MOSI (SPI1-MOSI) + * RESET | 7 8 | PA9 (MOD_RESET) (PA15) SD_DET | 7 8 | RESET + * (BEEPER) PB6 | 9 10| PA15 (SD_DET) GND | 9 10| 5V + * ----- ----- + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * _________ + * EXP1-1 ----------- EXP1-10 + * EXP1-2 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-4 ----------- EXP1-5 + * SP11-3 ----------- EXP1-2 + * EXP1-6 ----------- EXP1-4 + * EXP1-7 ----------- EXP1-8 + * EXP1-8 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-10 ----------- EXP1-7 + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN PB6 + + #define CLCD_MOD_RESET PA9 + #define CLCD_SPI_CS PB8 + + #if SD_CONNECTION_IS(LCD) && BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + #define SD_DETECT_PIN PA15 + #define SD_SS_PIN PA10 + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN PC3 + +#endif diff --git a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h index 7171de919d03..e189fc3f97b9 100644 --- a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h @@ -91,7 +91,7 @@ #endif #define FAN1_PIN PD13 -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Temperature Sensors diff --git a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h index bf38955127e4..6c7e7cbbfa48 100644 --- a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h @@ -45,7 +45,9 @@ // // EEPROM // -#define FLASH_EEPROM_EMULATION +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION +#endif #if ENABLED(FLASH_EEPROM_EMULATION) // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h index ba948bc479fe..b1e5f77d0e9f 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h @@ -224,7 +224,7 @@ #define LCD_PINS_RS EXP1_05_PIN // = LCD_RESET_PIN #define LCD_PINS_DC EXP1_07_PIN // DC #define DOGLCD_CS EXP1_08_PIN // CS - #define DOGLCD_A0 LCD_PINS_DC // A0 = DC + #define DOGLCD_A0 LCD_PINS_DC #define DOGLCD_MOSI EXP1_10_PIN // SDA #define DOGLCD_SCK EXP1_09_PIN // SCK // Encoder diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h index eb3af65f32eb..43aefe97f51d 100644 --- a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h +++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h @@ -203,19 +203,12 @@ #if ENABLED(SDSUPPORT) - #define SDIO_D0_PIN PC8 - #define SDIO_D1_PIN PC9 - #define SDIO_D2_PIN PC10 - #define SDIO_D3_PIN PC11 - #define SDIO_CK_PIN PC12 - #define SDIO_CMD_PIN PD2 - #if DISABLED(SDIO_SUPPORT) #define SOFTWARE_SPI - #define SDSS SDIO_D3_PIN - #define SD_SCK_PIN SDIO_CK_PIN - #define SD_MISO_PIN SDIO_D0_PIN - #define SD_MOSI_PIN SDIO_CMD_PIN + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 #endif #ifndef SD_DETECT_PIN diff --git a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h index 4cf9768fbe80..e6d7c3c20c3c 100644 --- a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h +++ b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h @@ -29,8 +29,10 @@ #define BOARD_INFO_NAME "Artillery Ruby" -#define FLASH_EEPROM_EMULATION -//#define I2C_EEPROM +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + //#define I2C_EEPROM +#endif //#define E2END 0xFFF // 4KB #define HAL_TIMER_RATE F_CPU @@ -155,7 +157,7 @@ #define NEOPIXEL_PIN PB9 #endif - #define DEFAULT_LCD_CONTRAST 255 + #define LCD_CONTRAST_DEFAULT 255 #else #define LCD_PINS_RS PC15 #define LCD_PINS_ENABLE PB6 diff --git a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h index d8a83bef3a89..061680aa79cd 100644 --- a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h +++ b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h @@ -140,25 +140,17 @@ // // Onboard SD support // -#define SDIO_D0_PIN PC8 -#define SDIO_D1_PIN PC9 -#define SDIO_D2_PIN PC10 -#define SDIO_D3_PIN PC11 -#define SDIO_CK_PIN PC12 -#define SDIO_CMD_PIN PD2 - #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif #if SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT // Use SDIO for onboard SD - - #ifndef SDIO_SUPPORT + #if DISABLED(SDIO_SUPPORT) #define SOFTWARE_SPI // Use soft SPI for onboard SD - #define SDSS SDIO_D3_PIN - #define SD_SCK_PIN SDIO_CK_PIN - #define SD_MISO_PIN SDIO_D0_PIN - #define SD_MOSI_PIN SDIO_CMD_PIN + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 #endif #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 7b99352ef495..99de2e43e7a3 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -188,17 +188,25 @@ #endif #endif +#ifndef E0_FAN_TACHO_PIN + #ifdef MK3_FAN_PINS + #define E0_FAN_TACHO_PIN PE1 // Fan1 + #else + #define E0_FAN_TACHO_PIN PE0 // Fan0 + #endif +#endif + /** - * -----------------------------------BTT002 V1.0---------------------------------------- - * ------ ------ | - * PA3 | 1 2 | GND 5V | 1 2 | GND | - * NRESET | 3 4 | PC4 (SD_DET) (LCD_D7) PE13 | 3 4 | PE12 (LCD_D6) | - * (MOSI) PA7 | 5 6 | PB0 (BTN_EN2) (LCD_D5) PE11 | 5 6 | PE10 (LCD_D4) | - * (SD_SS) PA4 | 7 8 | PC5 (BTN_EN1) (LCD_RS) PE8 | 7 8 | PE9 (LCD_EN) | - * (SCK) PA5 | 9 10 | PA6 (MISO) (BTN_ENC) PB1 | 9 10 | PE7 (BEEPER) | - * ------ ------ | - * EXP2 EXP1 | - * -------------------------------------------------------------------------------------- + * ---------------------------------BTT002 V1.0--------------------------------- + * ------ ------ | + * (BEEPER) PE7 |10 9 | PB1 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) | + * (LCD_EN) PE9 | 8 7 | PE8 (LCD_RS) (BTN_EN1) PC5 | 8 7 | PA4 (SD_SS) | + * (LCD_D4) PE10 6 5 | PE11 (LCD_D5) (BTN_EN2) PB0 6 5 | PA7 (MOSI) | + * (LCD_D6) PE12 | 4 3 | PE13 (LCD_D7) (SD_DET) PC4 | 4 3 | RESET | + * GND | 2 1 | 5V GND | 2 1 | PA3 | + * ------ ------ | + * EXP1 EXP2 | + * ------------------------------------------------------------------------------ */ #define EXP1_03_PIN PE13 #define EXP1_04_PIN PE12 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h index d1f38f5c8098..554b2704c7df 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h @@ -184,24 +184,24 @@ #endif /** - * BTT E3 RRF - * ----- - * 5V | 1 2 | GND - * (LCD_EN) PE11 | 3 4 | PB1 (LCD_RS) - * (LCD_D4) PE10 | 5 6 PB2 (BTN_EN2) - * RESET | 7 8 | PE7 (BTN_EN1) - * (BTN_ENC) PE9 | 9 10| PE8 (BEEPER) - * ----- + * BTT E3 RRF + * ------ + * (BEEPER) PE8 |10 9 | PE9 (BTN_ENC) + * (BTN_EN1) PE7 | 8 7 | RESET + * (BTN_EN2) PB2 6 5 | PE10 (LCD_D4) + * (LCD_RS) PB1 | 4 3 | PE11 (LCD_EN) + * GND | 2 1 | 5V + * ------ * EXP1 */ #if HAS_WIRED_LCD - #if ENABLED(CR10_STOCKDISPLAY) + #if EITHER(CR10_STOCKDISPLAY, LCD_FOR_MELZI) #define BEEPER_PIN PE8 - #define BTN_ENC PE9 + #define BTN_ENC PE9 #define BTN_EN1 PE7 #define BTN_EN2 PB2 @@ -209,6 +209,40 @@ #define LCD_PINS_ENABLE PE11 #define LCD_PINS_D4 PE10 + #if ENABLED(LCD_FOR_MELZI) + + #error "CAUTION! LCD_FOR_MELZI requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. Comment out this line to continue." + + /** LCD_FOR_MELZI display pinout + * + * BTT E3 RRF Display Ribbon + * ------ ------ + * (BEEPER) PE8 |10 9 | PE9 (BTN_ENC) GND |10 9 | 5V + * (BTN_EN1) PE7 | 8 7 | RESET BEEPER | 8 7 | ESTOP (RESET) + * (BTN_EN2) PB2 6 5 | PE10 (LCD_D4) (BTN_ENC) ENC_BTN | 6 5 | LCD_SCLK (LCD_D4) + * (LCD_RS) PB1 | 4 3 | PE11 (LCD_EN) (BTN_EN2) ENC_A | 4 3 | LCD_DATA (LCD_EN) + * GND | 2 1 | 5V (BTN_EN1) ENC_B | 2 1 | LCD_CS (LCD_RS) + * ------ ------ + * EXP1 Ribbon + * + * Needs custom cable: + * + * Board Adapter Display Ribbon (coming from display) + * + * EXP1-1 ----------- EXP1-9 + * EXP1-2 ----------- EXP1-10 + * EXP1-3 ----------- EXP1-3 + * EXP1-4 ----------- EXP1-1 + * EXP1-5 ----------- EXP1-5 + * EXP1-6 ----------- EXP1-4 + * EXP1-7 ----------- EXP1-7 + * EXP1-8 ----------- EXP1-8 + * EXP1-9 ----------- EXP1-6 + * EXP1-10 ----------- EXP1-8 + */ + + #endif + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. Comment out this line to continue." @@ -244,15 +278,15 @@ /** * TFTGLCD_PANEL_SPI display pinout * - * Board Display - * ----- ----- - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PE11 | 3 4 | PB1 (LCD_CS) (PE7) LCD_CS | 3 4 | SD_CS (PB2) - * (FREE) PE10 | 5 6 | PB2 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PE7 (MOD_RESET) (PE8) SD_DET | 7 8 | (FREE) - * (BEEPER) PE9 | 9 10| PE8 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * Board Display + * ------ ------ + * (SD_DET) PE8 |10 9 | PE9 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PE7 | 8 7 | RESET -- | 8 7 | (SD_DET) + * (SD_CS) PB2 6 5 | PE10 (MOSI) 6 5 | -- + * (LCD_CS) PB1 | 4 3 | PE11 (SD_CS) | 4 3 | (LCD_CS) + * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * @@ -275,11 +309,15 @@ #endif #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BTT_E3_RRF." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, LCD_FOR_MELZI, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BTT_E3_RRF." #endif // Alter timing for graphical display - #if IS_U8GLIB_ST7920 + #if ENABLED(LCD_FOR_MELZI) // LCD_FOR_MELZI default timing is too fast. This works but may be reduced. + #define BOARD_ST7920_DELAY_1 200 + #define BOARD_ST7920_DELAY_2 400 + #define BOARD_ST7920_DELAY_3 1200 + #elif IS_U8GLIB_ST7920 #define BOARD_ST7920_DELAY_1 96 #define BOARD_ST7920_DELAY_2 48 #define BOARD_ST7920_DELAY_3 600 @@ -293,20 +331,20 @@ /** FYSETC TFT TFT81050 display pinout * - * Board Display - * ----- ----- - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PE11 | 3 4 | PB1 (LCD_CS) (PE7) MOD_RESET | 3 4 | SD_CS (PB2) - * (FREE) PE10 | 5 6 | PB2 (SD_CS) (PB1) LCD_CS | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PE7 (MOD_RESET) (PE8) SD_DET | 7 8 | RESET - * (BEEPER) PE9 | 9 10| PE8 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * Board Display + * ------ ------ + * (SD_DET) PE8 |10 9 | PE9 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PE7 | 8 7 | RESET RESET | 8 7 | (SD_DET) + * (SD_CS) PB2 6 5 | PE10 (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB1 | 4 3 | PE11 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ + * * EXP1-1 ----------- EXP1-10 * EXP1-2 ----------- EXP1-9 * SPI1-4 ----------- EXP1-6 @@ -338,13 +376,6 @@ #if SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT // Use SDIO for onboard SD - #define SDIO_D0_PIN PC8 - #define SDIO_D1_PIN PC9 - #define SDIO_D2_PIN PC10 - #define SDIO_D3_PIN PC11 - #define SDIO_CK_PIN PC12 - #define SDIO_CMD_PIN PD2 - //#define SDIO_CLOCK 48000000 #define SD_DETECT_PIN PC4 #elif SD_CONNECTION_IS(CUSTOM_CABLE) 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 dfa9d8a7b9dd..7db6c4922e88 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -365,14 +365,14 @@ #endif /** - * ------ ------ - * NC | 1 2 | GND 5V | 1 2 | GND - * RESET | 3 4 | PB10 (SD_DETECT) (LCD_D7) PG5 | 3 4 | PG6 (LCD_D6) - * (MOSI) PB15 | 5 6 | PH10 (BTN_EN2) (LCD_D5) PG7 | 5 6 | PG8 (LCD_D4) - * (SD_SS) PB12 | 7 8 | PD10 (BTN_EN1) (LCD_RS) PA8 | 7 8 | PC10 (LCD_EN) - * (SCK) PB13 | 9 10 | PB14 (MISO) (BTN_ENC) PA15 | 9 10 | PC11 (BEEPER) - * ------ ------ - * EXP2 EXP1 + * ------ ------ + * (BEEPER) PC11 |10 9 | PA15 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SCK) + * (LCD_EN) PC10 | 8 7 | PA8 (LCD_RS) (BTN_EN1) PD10 | 8 7 | PB12 (SD_SS) + * (LCD_D4) PG8 6 5 | PG7 (LCD_D5) (BTN_EN2) PH10 6 5 | PB15 (MOSI) + * (LCD_D6) PG6 | 4 3 | PG5 (LCD_D7) (SD_DETECT) PB10 | 4 3 | RESET + * GND | 2 1 | 5V GND | 2 1 | -- + * ------ ------ + * EXP1 EXP2 */ #define EXP1_03_PIN PG5 #define EXP1_04_PIN PG6 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 fd367e87c04f..dd8812fe2af9 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 @@ -37,4 +37,8 @@ #define TEMP_0_PIN PF4 // TH0 #endif +#if !defined(Z_MIN_PROBE_PIN) && DISABLED(BLTOUCH) + #define Z_MIN_PROBE_PIN PC5 // Probe (Proximity switch) port +#endif + #include "pins_BTT_OCTOPUS_V1_common.h" 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 efeff04f256a..8652a815c21b 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -33,7 +33,7 @@ #define I2C_SDA_PIN PB9 // Avoid conflict with TIMER_TONE -#define STEP_TIMER 10 +#define STEP_TIMER 10 // // Servos @@ -61,11 +61,7 @@ // Z Probe (when not Z_MIN_PIN) // #ifndef Z_MIN_PROBE_PIN - #if ENABLED(BLTOUCH) - #define Z_MIN_PROBE_PIN PB7 - #else - #define Z_MIN_PROBE_PIN PC5 // Probe (Proximity switch) port - #endif + #define Z_MIN_PROBE_PIN PB7 #endif // @@ -330,7 +326,7 @@ * (LCD_EN) PE9 | 8 7 | PE10 (LCD_RS) (BTN_EN1) PB2 | 8 7 | PA4 (SD_SS) * (LCD_D4) PE12 6 5 | PE13 (LCD_D5) (BTN_EN2) PB1 6 5 | PA7 (MOSI) * (LCD_D6) PE14 | 4 3 | PE15 (LCD_D7) (SD_DETECT) PC15 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -379,14 +375,14 @@ #if ENABLED(BTT_MOTOR_EXPANSION) /** - * ------ ------ - * NC | 1 2 | GND NC | 1 2 | GND - * NC | 3 4 | M1EN M2EN | 3 4 | M3EN - * M1STP | 5 6 M1DIR M1RX | 5 6 M1DIAG - * M2DIR | 7 8 | M2STP M2RX | 7 8 | M2DIAG - * M3DIR | 9 10 | M3STP M3RX | 9 10 | M3DIAG - * ------ ------ - * EXP2 EXP1 + * ------ ------ + * M3DIAG |10 9 | M3RX M3STP |10 9 | M3DIR + * M2DIAG | 8 7 | M2RX M2STP | 8 7 | M2DIR + * M1DIAG 6 5 | M1RX M1DIR 6 5 | M1STP + * M3EN | 4 3 | M2EN M1EN | 4 3 | -- + * GND | 2 1 | -- GND | 2 1 | -- + * ------ ------ + * EXP1 EXP2 */ // M1 on Driver Expansion Module @@ -534,9 +530,9 @@ * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) * 3.3V | 11 | | 6 | PB14 (ESP-MISO) * (ESP-IO0) PD7 | 12 | | 5 | PB13 (ESP-CLK) - * (ESP-IO4) PD10 | 13 | | 4 | NC - * NC | 14 | | 3 | PE15 (ESP-EN) - * (ESP-RX) PD8 | 15 | | 2 | NC + * (ESP-IO4) PD10 | 13 | | 4 | -- + * -- | 14 | | 3 | PE15 (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- * (ESP-TX) PD9 | 16 | | 1 | PE14 (ESP-RST) * ------- * 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 ac049baa2122..5e424d4105fb 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -309,7 +309,7 @@ // #ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION LCD + #define SDCARD_CONNECTION ONBOARD #endif /** ------ ------ @@ -317,7 +317,7 @@ * (LCD_EN) PD11 | 8 7 | PD10 (LCD_RS) (BTN_EN1) PG10 | 8 7 | PB12 (SD_SS) * (LCD_D4) PG2 6 5 | PG3 (LCD_D5) (BTN_EN2) PF11 6 5 | PB15 (MOSI) * (LCD_D6) PG6 | 4 3 | PG7 (LCD_D7) (SD_DETECT) PF12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -367,8 +367,8 @@ #if ENABLED(BTT_MOTOR_EXPANSION) /** ----- ----- - * NC | . . | GND NC | . . | GND - * NC | . . | M1EN M2EN | . . | M3EN + * -- | . . | GND -- | . . | GND + * -- | . . | M1EN M2EN | . . | M3EN * M1STP | . . M1DIR M1RX | . . M1DIAG * M2DIR | . . | M2STP M2RX | . . | M2DIAG * M3DIR | . . | M3STP M3RX | . . | M3DIAG @@ -466,13 +466,13 @@ * * The WYH_L12864 connector plug: * - * BEFORE AFTER - * ______ ______ - * GND | 1 2 | 5V 5V | 1 2 | GND - * CS | 3 4 | BTN_EN2 CS | 3 4 | BTN_EN2 - * SID | 5 6 BTN_EN1 SID | 5 6 BTN_EN1 - * SCK | 7 8 | BTN_ENC SCK | 7 8 | BTN_ENC - * MOSI | 9 10 | MOSI | 9 10 | + * BEFORE AFTER + * ------ ------ + * -- |10 9 | MOSI -- |10 9 | MOSI + * BTN_ENC | 8 7 | SCK BTN_ENC | 8 7 | SCK + * BTN_EN1 | 6 5 SID BTN_EN1 | 6 5 SID + * BTN_EN2 | 4 3 | CS BTN_EN2 | 4 3 | CS + * 5V | 2 1 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ @@ -550,12 +550,12 @@ // /** - * ----- - * TX | 1 2 | GND Enable PG1 // Must be high for module to run - * Enable | 3 4 | GPIO2 Reset PG0 // active low, probably OK to leave floating - * Reset | 5 6 | GPIO0 GPIO2 PF15 // must be high (ESP3D software configures this with a pullup so OK to leave as floating) - * 3.3V | 7 8 | RX GPIO0 PF14 // Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) - * ----- + * ------ + * RX | 8 7 | 3.3V GPIO0 PF14 ... Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) + * GPIO0 | 6 5 | Reset GPIO2 PF15 ... must be high (ESP3D software configures this with a pullup so OK to leave as floating) + * GPIO2 | 4 3 | Enable Reset PG0 ... active low, probably OK to leave floating + * GND | 2 1 | TX Enable PG1 ... Must be high for module to run + * ------ * W1 */ #define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this 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 762e35562663..4f5ed6c1b4eb 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 @@ -50,7 +50,7 @@ #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // Avoid conflict with TIMER_TONE -#define STEP_TIMER 10 +#define STEP_TIMER 10 // // Servos @@ -136,7 +136,9 @@ // Probe enable // #if ENABLED(PROBE_ENABLE_DISABLE) - #define PROBE_ENABLE_PIN SERVO0_PIN + #ifndef PROBE_ENABLE_PIN + #define PROBE_ENABLE_PIN SERVO0_PIN + #endif #endif // @@ -188,16 +190,28 @@ #define Z_CS_PIN PD0 #endif -#define E0_STEP_PIN PD15 -#define E0_DIR_PIN PD14 -#define E0_ENABLE_PIN PC7 +#ifndef E0_STEP_PIN + #define E0_STEP_PIN PD15 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN PD14 +#endif +#ifndef E0_ENABLE_PIN + #define E0_ENABLE_PIN PC7 +#endif #ifndef E0_CS_PIN #define E0_CS_PIN PC6 #endif -#define E1_STEP_PIN PD11 -#define E1_DIR_PIN PD10 -#define E1_ENABLE_PIN PD13 +#ifndef E1_STEP_PIN + #define E1_STEP_PIN PD11 +#endif +#ifndef E1_DIR_PIN + #define E1_DIR_PIN PD10 +#endif +#ifndef E1_ENABLE_PIN + #define E1_ENABLE_PIN PD13 +#endif #ifndef E1_CS_PIN #define E1_CS_PIN PD12 #endif @@ -205,9 +219,15 @@ // // Temperature Sensors // -#define TEMP_BED_PIN PA1 // TB -#define TEMP_0_PIN PA2 // TH0 -#define TEMP_1_PIN PA3 // TH1 +#ifndef TEMP_0_PIN + #define TEMP_0_PIN PA2 // TH0 +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN PA3 // TH1 +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN PA1 // TB +#endif #if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) #if TEMP_SENSOR_PROBE @@ -232,12 +252,22 @@ #ifndef FAN_PIN #define FAN_PIN PB7 // Fan0 #endif -#ifndef FAN1_PIN - #define FAN1_PIN PB6 // Fan1 -#endif -#ifndef FAN2_PIN - #define FAN2_PIN PB5 // Fan2 -#endif + +#if HAS_CUTTER + #ifndef SPINDLE_LASER_PWM_PIN + #define SPINDLE_LASER_PWM_PIN PB5 + #endif + #ifndef SPINDLE_LASER_ENA_PIN + #define SPINDLE_LASER_ENA_PIN PB6 + #endif +#else + #ifndef FAN1_PIN + #define FAN1_PIN PB6 // Fan1 + #endif + #ifndef FAN2_PIN + #define FAN2_PIN PB5 // Fan2 + #endif +#endif // SPINDLE_FEATURE || LASER_FEATURE // // Software SPI pins for TMC2130 stepper drivers @@ -273,6 +303,9 @@ //#define E3_HARDWARE_SERIAL Serial1 //#define E4_HARDWARE_SERIAL Serial1 + // + // Software serial + // #define X_SERIAL_TX_PIN PE0 #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN @@ -296,18 +329,18 @@ // SD Connection // #ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION LCD + #define SDCARD_CONNECTION ONBOARD #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 + * ------ ------ + * (BEEPER) PC5 |10 9 | PB0 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) + * (LCD_EN) PB1 | 8 7 | PE9 (LCD_RS) (BTN_EN1) PE7 | 8 7 | PA4 (SD_SS) + * (LCD_D4) PE10 | 6 5 PE11 (LCD_D5) (BTN_EN2) PB2 | 6 5 PA7 (MOSI) + * (LCD_D6) PE12 | 4 3 | PE13 (LCD_D7) (SD_DETECT) PC4 | 4 3 | RESET + * GND | 2 1 | 5V GND | 2 1 | -- + * ------ ------ + * EXP1 EXP2 */ #define EXP1_03_PIN PE13 #define EXP1_04_PIN PE12 @@ -331,33 +364,23 @@ // Onboard SD card // Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 // -#if SD_CONNECTION_IS(ONBOARD) - - #define SDIO_SUPPORT // Use SDIO for onboard SD - #define SDIO_D0_PIN PC8 - #define SDIO_D1_PIN PC9 - #define SDIO_D2_PIN PC10 - #define SDIO_D3_PIN PC11 - #define SDIO_CK_PIN PC12 - #define SDIO_CMD_PIN PD2 - -#elif SD_CONNECTION_IS(LCD) - - #define SDSS PA4 +#if SD_CONNECTION_IS(LCD) + #define SDSS EXP2_07_PIN #define SD_SS_PIN SDSS - #define SD_SCK_PIN PA5 - #define SD_MISO_PIN PA6 - #define SD_MOSI_PIN PA7 - #define SD_DETECT_PIN PC4 - + #define SD_SCK_PIN EXP2_09_PIN + #define SD_MISO_PIN EXP2_10_PIN + #define SD_MOSI_PIN EXP2_05_PIN + #define SD_DETECT_PIN EXP2_04_PIN +#elif SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT // Use SDIO for onboard SD #elif SD_CONNECTION_IS(CUSTOM_CABLE) - #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" + #error "No custom SD drive cable defined for this board." #endif #if ENABLED(BTT_MOTOR_EXPANSION) /** ----- ----- - * NC | . . | GND NC | . . | GND - * NC | . . | M1EN M2EN | . . | M3EN + * -- | . . | GND -- | . . | GND + * -- | . . | M1EN M2EN | . . | M3EN * M1STP | . . M1DIR M1RX | . . M1DIAG * M2DIR | . . | M2STP M2RX | . . | M2DIAG * M3DIR | . . | M3STP M3RX | . . | M3DIAG @@ -539,9 +562,9 @@ * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) * 3.3V | 11 | | 6 | PB14 (ESP-MISO) * (ESP-IO0) PB10 | 12 | | 5 | PB13 (ESP-CLK) - * (ESP-IO4) PB11 | 13 | | 4 | NC - * NC | 14 | | 3 | 3.3V (ESP-EN) - * (ESP-RX) PD8 | 15 | | 2 | NC + * (ESP-IO4) PB11 | 13 | | 4 | -- + * -- | 14 | | 3 | 3.3V (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- * (ESP-TX) PD9 | 16 | | 1 | PC14 (ESP-RST) * ------- * WIFI diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index 794649e4166e..514fad4b8924 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -33,8 +33,8 @@ #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME // Avoid conflict with fans and TIMER_TONE -#define TEMP_TIMER 3 -#define STEP_TIMER 5 +#define TEMP_TIMER 3 +#define STEP_TIMER 5 // // EEPROM Emulation @@ -181,7 +181,7 @@ * PE14 | 8 7 | PE12 PC5 | 8 7 | PF11 * PE10 6 5 | PE9 PC4 6 5 | PB15 * PE8 | 4 3 | PE7 PB2 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h index 054da6275465..29aff20ffd4f 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h @@ -139,26 +139,26 @@ #endif /** - * ----- ----- - * 5V | 1 2 | GND 5V | 1 2 | GND - * RESET | 3 4 | PC3 (SD_DETECT) (LCD_D7) PB7 | 3 4 | PB6 (LCD_D6) - * (SD_MOSI) PA7 5 6 | PC11 (BTN_EN2) (LCD_D5) PB14 5 6 | PB13 (LCD_D4) - * (SD_SS) PA4 | 7 8 | PC10 (BTN_EN1) (LCD_RS) PB12 | 7 8 | PB15 (LCD_EN) - * (SD_SCK) PA5 | 9 10| PA6 (SD_MISO) (BTN_ENC) PC12 | 9 10| PC9 (BEEPER) - * ----- ----- - * EXP2 EXP1 + * ------ ------ + * (SD_MISO) PA6 |10 9 | PA5 (SD_SCK) (BEEPER) PC9 |10 9 | PC12 (BTN_ENC) + * (BTN_EN1) PC10 | 8 7 | PA4 (SD_SS) (LCD_EN) PB15 | 8 7 | PB12 (LCD_RS) + * (BTN_EN2) PC11 6 5 | PA7 (SD_MOSI) (LCD_D4) PB13 6 5 | PB14 (LCD_D5) + * (SD_DETECT) PC3 | 4 3 | RESET (LCD_D6) PB6 | 4 3 | PB7 (LCD_D7) + * GND | 2 1 | 5V GND | 2 1 | 5V + * ------ ------ + * EXP2 EXP1 */ /** -* ----- -* (BEEPER) PC9 | 1 2 | PC12 (BTN_ENC) -* (BTN_EN1) PC10 | 3 4 | PB14 (LCD_D5/MISO) -* (BTN_EN2) PC11 5 6 | PB13 (LCD_D4/SCK) -* (LCD_RS) PB12 | 7 8 | PB15 (LCD_EN/MOSI) -* GND | 9 10| 5V -* ----- -* EXP3 -*/ + * ------ + * 5V |10 9 | GND + * (LCD_EN/MOSI) PB15 | 8 7 | PB12 (LCD_RS) + * (LCD_D4/SCK) PB13 6 5 | PC11 (BTN_EN2) + * (LCD_D5/MISO) PB14 | 4 3 | PC10 (BTN_EN1) + * (BTN_ENC) PC12 | 2 1 | PC9 (BEEPER) + * ------ + * EXP3 + */ #define EXP1_03_PIN PB7 #define EXP1_04_PIN PB6 diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 37a48cab7fdc..dfcb4217c9db 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 PC4 + #define Y_SERIAL_RX_PIN PE13 #endif #ifndef Z_SERIAL_TX_PIN #define Z_SERIAL_TX_PIN PD11 @@ -162,7 +162,9 @@ #define TEMP_0_PIN PC0 #define TEMP_1_PIN PC1 #define TEMP_2_PIN PC2 -#define TEMP_BED_PIN PC3 +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN PC3 +#endif // // Heaters / Fans @@ -180,8 +182,12 @@ #define HEATER_BED_PIN PC8 #endif -#define FAN_PIN PB0 -#define FAN1_PIN PB1 +#ifndef FAN_PIN + #define FAN_PIN PB0 +#endif +#ifndef FAN1_PIN + #define FAN1_PIN PB1 +#endif #define FAN2_PIN PB2 // @@ -197,7 +203,7 @@ * PC11 | 8 7 | PD2 PC6 | 8 7 | PA4 * PC10 6 5 | PC12 PC7 6 5 | PA7 * PD0 | 4 3 | PD1 PB10 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 5V + * GND | 2 1 | 5V GND | 2 1 | 5V * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h index 6f1c9be8f5b0..a9ce1383d8ca 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h @@ -39,11 +39,17 @@ #if HAS_TMC_UART #define X_SERIAL_TX_PIN PE8 + #define X_SERIAL_RX_PIN PE8 #define Y_SERIAL_TX_PIN PC4 + #define Y_SERIAL_RX_PIN PC4 #define Z_SERIAL_TX_PIN PD12 + #define Z_SERIAL_RX_PIN PD12 #define E0_SERIAL_TX_PIN PA15 + #define E0_SERIAL_RX_PIN PA15 #define E1_SERIAL_TX_PIN PC5 + #define E1_SERIAL_RX_PIN PC5 #define E2_SERIAL_TX_PIN PE0 + #define E2_SERIAL_RX_PIN PE0 #endif // diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER_V2_2.h b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER_V2_2.h new file mode 100644 index 000000000000..50a19fa3d3c3 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER_V2_2.h @@ -0,0 +1,34 @@ +/** + * 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 + +#define BOARD_INFO_NAME "FYSETC SPIDER V22" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +#define TEMP_3_PIN PC3 +#define TEMP_4_PIN PB1 +#define TEMP_BED_PIN PB0 + +#define FAN_PIN PA13 +#define FAN1_PIN PA14 + +#include "pins_FYSETC_SPIDER.h" diff --git a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h b/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h index 8761ca955a8f..977f4763437c 100644 --- a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h +++ b/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h @@ -42,6 +42,9 @@ #define SRAM_EEPROM_EMULATION #define MARLIN_EEPROM_SIZE 0x2000 // 8KB +// I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) +#define HAS_MCP3426_ADC + // // Servos // @@ -57,12 +60,12 @@ // None of these require limit switches by default, so we leave these commented // here for your reference. -// #define I_MIN_PIN PA8 -// #define I_MAX_PIN PA8 -// #define J_MIN_PIN PD13 -// #define J_MAX_PIN PD13 -// #define K_MIN_PIN PC9 -// #define K_MAX_PIN PC9 +//#define I_MIN_PIN PA8 +//#define I_MAX_PIN PA8 +//#define J_MIN_PIN PD13 +//#define J_MAX_PIN PD13 +//#define K_MIN_PIN PC9 +//#define K_MAX_PIN PC9 // // Steppers @@ -70,62 +73,108 @@ #define X_STEP_PIN PB15 #define X_DIR_PIN PB14 #define X_ENABLE_PIN PD9 -#define X_SERIAL_TX_PIN PD8 -#define X_SERIAL_RX_PIN PD8 #define Y_STEP_PIN PE15 #define Y_DIR_PIN PE14 #define Y_ENABLE_PIN PB13 -#define Y_SERIAL_TX_PIN PB12 -#define Y_SERIAL_RX_PIN PB12 #define Z_STEP_PIN PE7 #define Z_DIR_PIN PB1 #define Z_ENABLE_PIN PE9 -#define Z_SERIAL_TX_PIN PE8 -#define Z_SERIAL_RX_PIN PE8 #define I_STEP_PIN PC4 #define I_DIR_PIN PA4 #define I_ENABLE_PIN PB0 -#define I_SERIAL_TX_PIN PC5 -#define I_SERIAL_RX_PIN PC5 #define J_STEP_PIN PE11 #define J_DIR_PIN PE10 #define J_ENABLE_PIN PE13 -#define J_SERIAL_TX_PIN PE12 -#define J_SERIAL_RX_PIN PE12 -#define K_SERIAL_TX_PIN PA2 -#define K_SERIAL_RX_PIN PA2 #define K_STEP_PIN PD6 #define K_DIR_PIN PD7 #define K_ENABLE_PIN PA3 -// Reduce baud rate to improve software serial reliability -#define TMC_BAUD_RATE 19200 - -// Not required for this board. Fails to compile otherwise. -// PD0 is not connected on this board. -#define TEMP_0_PIN PD0 +#if HAS_TMC_SPI + /** + * Make sure to configure the jumpers on the back side of the Mobo according to + * this diagram: https://github.com/MarlinFirmware/Marlin/pull/23851 + */ + #error "SPI drivers require a custom jumper configuration, see comment above! Comment out this line to continue." + + #if AXIS_HAS_SPI(X) + #define X_CS_PIN PD8 + #endif + #if AXIS_HAS_SPI(Y) + #define Y_CS_PIN PB12 + #endif + #if AXIS_HAS_SPI(Z) + #define Z_CS_PIN PE8 + #endif + #if AXIS_HAS_SPI(I) + #define I_CS_PIN PC5 + #endif + #if AXIS_HAS_SPI(J) + #define J_CS_PIN PE12 + #endif + #if AXIS_HAS_SPI(K) + #define K_CS_PIN PA2 + #endif + +#elif HAS_TMC_UART + + #define X_SERIAL_TX_PIN PD8 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PB12 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE8 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define I_SERIAL_TX_PIN PC5 + #define I_SERIAL_RX_PIN I_SERIAL_TX_PIN + + #define J_SERIAL_TX_PIN PE12 + #define J_SERIAL_RX_PIN J_SERIAL_TX_PIN + + #define K_SERIAL_TX_PIN PA2 + #define K_SERIAL_RX_PIN K_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + +#endif -// General use mosfets, useful for things like pumps and solenoids +// +// Heaters / Fans +// #define FAN_PIN PE2 #define FAN1_PIN PE3 #define FAN2_PIN PE4 #define FAN3_PIN PE5 -// Neopixel Rings +#define FAN_SOFT_PWM_REQUIRED + +// +// Neopixel +// #define NEOPIXEL_PIN PC7 #define NEOPIXEL2_PIN PC8 +// // SPI +// #define MISO_PIN PB4 #define MOSI_PIN PB5 #define SCK_PIN PB3 +#define TMC_SW_MISO MISO_PIN +#define TMC_SW_MOSI MOSI_PIN +#define TMC_SW_SCK SCK_PIN + +// // I2C +// #define I2C_SDA_PIN PB7 #define I2C_SCL_PIN PB6 diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h index c686e19ccb29..e4fc97170c44 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h @@ -31,8 +31,8 @@ #define BOARD_INFO_NAME "Lerdge S" #define DEFAULT_MACHINE_NAME "LERDGE" -#define STEP_TIMER 4 -#define TEMP_TIMER 2 +#define STEP_TIMER 4 +#define TEMP_TIMER 2 #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support @@ -133,8 +133,10 @@ // // Průša i3 MK2 Multi Material Multiplexer Support // -//#define E_MUX0_PIN -1 -//#define E_MUX1_PIN -1 +#if HAS_PRUSA_MMU1 + //#define E_MUX0_PIN -1 + //#define E_MUX1_PIN -1 +#endif // // LED / Lighting diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h index 93526db4425c..5048933146fe 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h @@ -31,8 +31,8 @@ #define BOARD_INFO_NAME "Lerdge X" #define DEFAULT_MACHINE_NAME "LERDGE" -#define STEP_TIMER 4 -#define TEMP_TIMER 2 +#define STEP_TIMER 4 +#define TEMP_TIMER 2 #define I2C_EEPROM #define I2C_SCL_PIN PB8 diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h index a7f853185e1d..af71f0d562c8 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h @@ -38,7 +38,7 @@ //#define DISABLE_DEBUG // Avoid conflict with TIMER_TONE -#define STEP_TIMER 10 +#define STEP_TIMER 10 // Use one of these or SDCard-based Emulation will be used //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation @@ -239,7 +239,7 @@ * (LCD_EN) PE11 | 8 7 | PD10 (LCD_RS) (BTN_EN1) PE9 | 8 7 | PA4 (SPI1 CS) * (LCD_D4) PD9 6 5 | PD8 (LCD_D5) (BTN_EN2) PE8 6 5 | PA7 (SPI1 MOSI) * (LCD_D6) PE15 | 4 3 | PE7 (LCD_D7) (SPI1_RS) PB11 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * GND | 2 1 | 5V GND | 2 1 | 3.3V * ------ ------ * EXP1 EXP2 */ @@ -261,25 +261,26 @@ #define EXP2_09_PIN PA5 #define EXP2_10_PIN PA6 -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION ONBOARD -#endif - -#if SD_CONNECTION_IS(ONBOARD) - #define ENABLE_SPI3 - #define SD_SS_PIN -1 - #define SDSS PC9 - #define SD_SCK_PIN PC10 - #define SD_MISO_PIN PC11 - #define SD_MOSI_PIN PC12 - #define SD_DETECT_PIN PC4 // SD_DETECT_PIN doesn't work with NO_SD_HOST_DRIVE disabled -#elif SD_CONNECTION_IS(LCD) - #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN +#if ENABLED(SDSUPPORT) + #ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD + #endif + #if SD_CONNECTION_IS(ONBOARD) + #define ENABLE_SPI3 + #define SD_SS_PIN -1 + #define SDSS PC9 + #define SD_SCK_PIN PC10 + #define SD_MISO_PIN PC11 + #define SD_MOSI_PIN PC12 + #define SD_DETECT_PIN PC4 // SD_DETECT_PIN doesn't work with NO_SD_HOST_DRIVE disabled + #elif SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS EXP2_07_PIN + #define SD_SCK_PIN EXP2_09_PIN + #define SD_MISO_PIN EXP2_10_PIN + #define SD_MOSI_PIN EXP2_05_PIN + #define SD_DETECT_PIN EXP2_04_PIN + #endif #endif #if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI) @@ -339,17 +340,21 @@ // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #if ENABLED(MKS_MINI_12864) - //#define LCD_BACKLIGHT_PIN -1 - //#define LCD_RESET_PIN -1 - #define DOGLCD_A0 PD11 - #define DOGLCD_CS EXP1_04_PIN - //#define DOGLCD_SCK EXP2_09_PIN - //#define DOGLCD_MOSI EXP2_05_PIN - - #elif ENABLED(MKS_MINI_12864_V3) + + #define ENABLE_SPI1 + #define FORCE_SOFT_SPI + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_SCK EXP2_09_PIN + #define DOGLCD_MOSI EXP2_05_PIN + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 + + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #define LCD_PINS_DC EXP1_07_PIN #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN EXP1_06_PIN #define NEOPIXEL_PIN EXP1_05_PIN @@ -358,7 +363,7 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else 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 256439e654dc..032ce41bcb2f 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 @@ -29,7 +29,7 @@ #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // Avoid conflict with TIMER_TONE -#define STEP_TIMER 10 +#define STEP_TIMER 10 // Use one of these or SDCard-based Emulation will be used //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation @@ -145,10 +145,10 @@ #endif #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN MT_DET_1_PIN + #define FIL_RUNOUT_PIN PA4 #endif #ifndef FIL_RUNOUT2_PIN - #define FIL_RUNOUT2_PIN MT_DET_2_PIN + #define FIL_RUNOUT2_PIN PE6 #endif #ifndef POWER_LOSS_PIN @@ -165,7 +165,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW @@ -335,10 +337,10 @@ //#define MKS_LCD12864B //#undef SHOW_BOOTSCREEN - #elif ENABLED(MKS_MINI_12864_V3) + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define LCD_PINS_DC EXP1_07_PIN #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN EXP1_06_PIN #define NEOPIXEL_PIN EXP1_05_PIN @@ -347,7 +349,7 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else // !MKS_MINI_12864 @@ -366,9 +368,16 @@ #endif // HAS_WIRED_LCD +#if HAS_TFT_LVGL_UI + // Enable SPI DMA, this requires button pins, thus no buttons. Default is DISABLED. + //#define USE_SPI_DMA_TC +#endif + #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI, HAS_WIRED_LCD) #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #if DISABLED(USE_SPI_DMA_TC) + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_09_PIN + #endif #endif diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_BTT.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_BTT.h index 04dcc432cae1..28d2dfd1806f 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_BTT.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_BTT.h @@ -22,7 +22,7 @@ #pragma once /** - * No offical schematics have been found. + * No official schematics have been found. * But these differences where noted in https://github.com/bigtreetech/Rumba32/issues/1 */ @@ -30,7 +30,7 @@ #if NO_EEPROM_SELECTED #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24LC64T-I/OT) + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB (24LC32AT-I/OT) #endif #if ENABLED(FLASH_EEPROM_EMULATION) diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h index 00f49acbeb46..873a4d4ad382 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h @@ -35,7 +35,7 @@ // Use soft PWM for fans - PWM is not working properly when paired with STM32 Arduino Core v1.7.0 // This can be removed when Core version is updated and PWM behaviour is fixed. -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Configure Timers @@ -45,8 +45,8 @@ // This will be difficult to solve from the Arduino IDE, without modifying the RUMBA32 variant // included with the STM32 framework. -#define STEP_TIMER 10 -#define TEMP_TIMER 14 +#define STEP_TIMER 10 +#define TEMP_TIMER 14 // // Limit Switches diff --git a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h index 7ccb57e2387b..0b527a6fdb78 100644 --- a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h +++ b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h @@ -48,82 +48,82 @@ // // Limit Switches // -#define X_MIN_PIN 39 // PD8 X_STOP -#define Y_MIN_PIN 40 // PD9 Y_STOP -#define Z_MIN_PIN 41 // PD10 Z_STOP +#define X_MIN_PIN PD8 // X_STOP +#define Y_MIN_PIN PD9 // Y_STOP +#define Z_MIN_PIN PD10 // Z_STOP -#define X_MAX_PIN 44 // PD0 W_STOP -#define Y_MAX_PIN 43 // PA8 V_STOP -#define Z_MAX_PIN 42 // PD11 U_STOP +#define X_MAX_PIN PD0 // W_STOP +#define Y_MAX_PIN PA8 // V_STOP +#define Z_MAX_PIN PD11 // U_STOP // // Z Probe (when not Z_MIN_PIN) // //#ifndef Z_MIN_PROBE_PIN -// #define Z_MIN_PROBE_PIN 16 // PA4 +// #define Z_MIN_PROBE_PIN PA4 // SPI1_CS //#endif // // Filament runout // -//#define FIL_RUNOUT_PIN 53 // PA3 BED_THE +//#define FIL_RUNOUT_PIN PA3 // BED_THERMISTOR_3 // // Steppers // -#define X_STEP_PIN 61 // PE14 X_PWM -#define X_DIR_PIN 62 // PE15 X_DIR -#define X_ENABLE_PIN 60 // PE13 X_RES -#define X_CS_PIN 16 // PA4 SPI_CS +#define X_STEP_PIN PE14 // X_PWM +#define X_DIR_PIN PE15 // X_DIR +#define X_ENABLE_PIN PE13 // X_RESET +#define X_CS_PIN PA4 // SPI1_CS -#define Y_STEP_PIN 64 // PB10 Y_PWM -#define Y_DIR_PIN 65 // PE9 Y_DIR -#define Y_ENABLE_PIN 63 // PE10 Y_RES -#define Y_CS_PIN 16 // PA4 SPI_CS +#define Y_STEP_PIN PB10 // Y_PWM +#define Y_DIR_PIN PE9 // Y_DIR +#define Y_ENABLE_PIN PE10 // Y_RESET +#define Y_CS_PIN PA4 // SPI1_CS -#define Z_STEP_PIN 67 // PC6 Z_PWM -#define Z_DIR_PIN 68 // PC0 Z_DIR -#define Z_ENABLE_PIN 66 // PC15 Z_RES -#define Z_CS_PIN 16 // PA4 SPI_CS +#define Z_STEP_PIN PC6 // Z_PWM +#define Z_DIR_PIN PC0 // Z_DIR +#define Z_ENABLE_PIN PC15 // Z_RESET +#define Z_CS_PIN PA4 // SPI1_CS -#define E0_STEP_PIN 71 // PD12 E1_PW -#define E0_DIR_PIN 70 // PC13 E1_DIR -#define E0_ENABLE_PIN 69 // PC14 E1_RE -#define E0_CS_PIN 16 // PA4 SPI_CS +#define E0_STEP_PIN PD12 // E1_PW +#define E0_DIR_PIN PC13 // E1_DIR +#define E0_ENABLE_PIN PC14 // E1_RESET +#define E0_CS_PIN PA4 // SPI1_CS -#define E1_STEP_PIN 73 // PE5 E2_PWM -#define E1_DIR_PIN 74 // PE6 E2_DIR -#define E1_ENABLE_PIN 72 // PE4 E2_RESE -#define E1_CS_PIN 16 // PA4 SPI_CS +#define E1_STEP_PIN PE5 // E2_PWM +#define E1_DIR_PIN PE6 // E2_DIR +#define E1_ENABLE_PIN PE4 // E2_RESET +#define E1_CS_PIN PA4 // SPI1_CS -#define E2_STEP_PIN 77 // PB8 E3_PWM -#define E2_DIR_PIN 76 // PE2 E3_DIR -#define E2_ENABLE_PIN 75 // PE3 E3_RESE -#define E2_CS_PIN 16 // PA4 SPI_CS +#define E2_STEP_PIN PB8 // E3_PWM +#define E2_DIR_PIN PE2 // E3_DIR +#define E2_ENABLE_PIN PE3 // E3_RESET +#define E2_CS_PIN PA4 // SPI1_CS // needed to pass a sanity check -#define X2_CS_PIN 16 // PA4 SPI_CS -#define Y2_CS_PIN 16 // PA4 SPI_CS -#define Z2_CS_PIN 16 // PA4 SPI_CS -#define Z3_CS_PIN 16 // PA4 SPI_CS -#define E3_CS_PIN 16 // PA4 SPI_CS -#define E4_CS_PIN 16 // PA4 SPI_CS -#define E5_CS_PIN 16 // PA4 SPI_CS +#define X2_CS_PIN PA4 // SPI1_CS +#define Y2_CS_PIN PA4 // SPI1_CS +#define Z2_CS_PIN PA4 // SPI1_CS +#define Z3_CS_PIN PA4 // SPI1_CS +#define E3_CS_PIN PA4 // SPI1_CS +#define E4_CS_PIN PA4 // SPI1_CS +#define E5_CS_PIN PA4 // SPI1_CS #if HAS_L64XX - #define L6470_CHAIN_SCK_PIN 17 // PA5 - #define L6470_CHAIN_MISO_PIN 18 // PA6 - #define L6470_CHAIN_MOSI_PIN 19 // PA7 - #define L6470_CHAIN_SS_PIN 16 // PA4 + #define L6470_CHAIN_SCK_PIN PA5 // SPI1_SCK + #define L6470_CHAIN_MISO_PIN PA6 // SPI1_MISO + #define L6470_CHAIN_MOSI_PIN PA7 // SPI1_MOSI + #define L6470_CHAIN_SS_PIN PA4 // SPI1_CS //#define SD_SCK_PIN L6470_CHAIN_SCK_PIN //#define SD_MISO_PIN L6470_CHAIN_MISO_PIN //#define SD_MOSI_PIN L6470_CHAIN_MOSI_PIN #else - //#define SD_SCK_PIN 13 // PB13 SPI_S - //#define SD_MISO_PIN 12 // PB14 SPI_M - //#define SD_MOSI_PIN 11 // PB15 SPI_M + //#define SD_SCK_PIN PB13 // SPI2_SCK + //#define SD_MISO_PIN PB14 // SPI2_MISO + //#define SD_MOSI_PIN PB15 // SPI2_MOSI #endif /** @@ -144,215 +144,182 @@ // // Temperature Sensors // -#define TEMP_0_PIN 3 // Analog input 3, digital pin 54 PA0 E1_THERMISTOR -#define TEMP_1_PIN 4 // Analog input 4, digital pin 55 PA1 E2_THERMISTOR -#define TEMP_2_PIN 5 // Analog input 5, digital pin 56 PA2 E3_THERMISTOR -#define TEMP_BED_PIN 0 // Analog input 0, digital pin 51 PC2 BED_THERMISTOR_1 -#define TEMP_BED_1_PIN 1 // Analog input 1, digital pin 52 PC3 BED_THERMISTOR_2 -#define TEMP_BED_2_PIN 2 // Analog input 2, digital pin 53 PA3 BED_THERMISTOR_3 +#define TEMP_0_PIN PA0 // Analog Input 3 +#define TEMP_1_PIN PA1 // Analog Input 4 +#define TEMP_2_PIN PA2 // Analog Input 5 +#define TEMP_BED_PIN PC2 // Analog Input 0 +#define TEMP_BED_1_PIN PC3 // Analog Input 1 +#define TEMP_BED_2_PIN PA3 // Analog Input 2 // // Heaters / Fans // -#define HEATER_0_PIN 48 // PC7 E1_HEAT_PWM -#define HEATER_1_PIN 49 // PB0 E2_HEAT_PWM -#define HEATER_2_PIN 50 // PB1 E3_HEAT_PWM -#define HEATER_BED_PIN 46 // PD14 (BED_HEAT_1 FET -#define HEATER_BED_1_PIN 45 // PD13 (BED_HEAT_2 FET -#define HEATER_BED_2_PIN 47 // PD15 (BED_HEAT_3 FET +#define HEATER_0_PIN PC7 // E1_HEAT_PWM +#define HEATER_1_PIN PB0 // E2_HEAT_PWM +#define HEATER_2_PIN PB1 // E3_HEAT_PWM +#define HEATER_BED_PIN PD14 // BED_HEAT_1 FET +#define HEATER_BED_1_PIN PD13 // BED_HEAT_2 FET +#define HEATER_BED_2_PIN PD15 // BED_HEAT_3 FET -#define FAN_PIN 57 // PC4 E1_FAN PWM pin, Part cooling fan FET -#define FAN1_PIN 58 // PC5 E2_FAN PWM pin, Extruder fan FET -#define FAN2_PIN 59 // PE8 E3_FAN PWM pin, Controller fan FET +#define FAN_PIN PC4 // E1_FAN PWM pin, Part cooling fan FET +#define FAN1_PIN PC5 // E2_FAN PWM pin, Extruder fan FET +#define FAN2_PIN PE8 // E3_FAN PWM pin, Controller fan FET #ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN 58 // FAN1_PIN + #define E0_AUTO_FAN_PIN PC5 // FAN1_PIN #endif // // Misc functions // -#define LED_PIN -1 // 9 // PE1 green LED Heart beat -#define PS_ON_PIN -1 -#define KILL_PIN -1 -#define POWER_LOSS_PIN -1 // PWR_LOSS / nAC_FAULT +#define LED_PIN -1 // PE1 Green LED Heartbeat +#define PS_ON_PIN -1 +#define KILL_PIN -1 +#define POWER_LOSS_PIN -1 // PWR_LOSS / nAC_FAULT // // LCD / Controller // -//#define SD_DETECT_PIN 66 // PA15 SD_CA -//#define BEEPER_PIN 24 // PC9 SDIO_D1 -//#define LCD_PINS_RS 65 // PE9 Y_DIR -//#define LCD_PINS_ENABLE 59 // PE8 E3_FAN -//#define LCD_PINS_D4 10 // PB12 SPI_C -//#define LCD_PINS_D5 13 // PB13 SPI_S -//#define LCD_PINS_D6 12 // PB14 SPI_M -//#define LCD_PINS_D7 11 // PB15 SPI_M -//#define BTN_EN1 57 // PC4 E1_FAN -//#define BTN_EN2 58 // PC5 E2_FAN -//#define BTN_ENC 52 // PC3 BED_THE +//#define SD_DETECT_PIN PA15 // SD_CARD_DETECT +//#define BEEPER_PIN PC9 // SDIO_D1 +//#define LCD_PINS_RS PE9 // Y_DIR +//#define LCD_PINS_ENABLE PE8 // E3_FAN +//#define LCD_PINS_D4 PB12 // SPI2_CS +//#define LCD_PINS_D5 PB13 // SPI2_SCK +//#define LCD_PINS_D6 PB14 // SPI2_MISO +//#define LCD_PINS_D7 PB15 // SPI2_MOSI +//#define BTN_EN1 PC4 // E1_FAN +//#define BTN_EN2 PC5 // E2_FAN +//#define BTN_ENC PC3 // BED_THERMISTOR_2 // // Extension pins // -//#define EXT0_PIN 49 // PB0 E2_HEAT -//#define EXT1_PIN 50 // PB1 E3_HEAT -//#define EXT2_PIN // PB2 not used (tied to ground -//#define EXT3_PIN 39 // PD8 X_STOP -//#define EXT4_PIN 40 // PD9 Y_STOP -//#define EXT5_PIN 41 // PD10 Z_STOP -//#define EXT6_PIN 42 // PD11 -//#define EXT7_PIN 71 // PD12 E1_PW -//#define EXT8_PIN 64 // PB10 Y_PWM +//#define EXT0_PIN PB0 // E2_HEAT +//#define EXT1_PIN PB1 // E3_HEAT +//#define EXT2_PIN PB2 // not used (tied to ground) +//#define EXT3_PIN PD8 // X_STOP +//#define EXT4_PIN PD9 // Y_STOP +//#define EXT5_PIN PD10 // Z_STOP +//#define EXT6_PIN PD11 // U_STOP +//#define EXT7_PIN PD12 // E1_PWM +//#define EXT8_PIN PB10 // Y_PWM // WIFI -// 2 // PD3 CTS -// 3 // PD4 RTS -// 4 // PD5 TX -// 5 // PD6 RX -// 6 // PB5 WIFI_WAKEUP -// 7 // PE11 WIFI_RESET -// 8 // PE12 WIFI_BOOT +// PD3 CTS +// PD4 RTS +// PD5 TX +// PD6 RX +// PB5 WIFI_WAKEUP +// PE11 WIFI_RESET +// PE12 WIFI_BOOT // I2C USER -// 14 // PB7 SDA -// 15 // PB6 SCL +// PB7 SDA +// PB6 SCL // JTAG -// 20 // PA13 JTAG_TMS/SWDIO -// 21 // PA14 JTAG_TCK/SWCLK -// 22 // PB3 JTAG_TDO/SWO +// PA13 JTAG_TMS/SWDIO +// PA14 JTAG_TCK/SWCLK +// PB3 JTAG_TDO/SWO // // Onboard SD support // -#define SDIO_D0_PIN 23 // PC8 SDIO_D0 -#define SDIO_D1_PIN 24 // PC9 SDIO_D1 -//#define SD_CARD_DETECT_PIN 25 // PA15 SD_CARD_DETECT -#define SDIO_D2_PIN 26 // PC10 SDIO_D2 -#define SDIO_D3_PIN 27 // PC11 SDIO_D3 -#define SDIO_CK_PIN 28 // PC12 SDIO_CK -#define SDIO_CMD_PIN 29 // PD2 SDIO_CMD - #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif #if SD_CONNECTION_IS(ONBOARD) - #define SDIO_SUPPORT // Use SDIO for onboard SD - #ifndef SDIO_SUPPORT + #define SDIO_SUPPORT // Use SDIO for onboard SD + #if DISABLED(SDIO_SUPPORT) #define SOFTWARE_SPI // Use soft SPI for onboard SD - #define SDSS SDIO_D3_PIN - #define SD_SCK_PIN SDIO_CK_PIN - #define SD_MISO_PIN SDIO_D0_PIN - #define SD_MOSI_PIN SDIO_CMD_PIN + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 #endif + + //#define SD_DETECT_PIN PA15 + #endif #ifndef SDSS - #define SDSS 16 // PA4 SPI_CS + #define SDSS PA4 // SPI1_CS #endif // OTG -// 30 // PA11 OTG_DM -// 31 // PA12 OTG_DP +// PA11 OTG_DM +// PA12 OTG_DP // USER_PINS -// 34 // PD7 USER3 -// 35 // PB9 USER1 -// 36 // PE0 USER2 -// 37 // PB4 USER4 +// PD7 USER3 +// PB9 USER1 +// PE0 USER2 +// PB4 USER4 // USERKET -// 38 // PE7 USER_BUTTON +// PE7 USER_BUTTON -// 0 // PA9 TX -// 1 // PA10 RX +// PA9 TX +// PA10 RX // IR/PROBE -// 32 // PD1 IR_OUT -// 33 // PC1 IR_ON +// PD1 IR_OUT +// PC1 IR_ON /** * Logical pin vs. port/pin cross reference * - * PA0 54 // E1_THERMISTOR PA9 0 // TX - * PA1 55 // E2_THERMISTOR PA10 1 // RX - * PA2 56 // E3_THERMISTOR PD3 2 // CTS - * PA3 53 // BED_THERMISTOR_3 PD4 3 // RTS - * PA4 16 // SPI_CS PD5 4 // TX - * PA5 17 // SPI_SCK PD6 5 // RX - * PA6 18 // SPI_MISO PB5 6 // WIFI_WAKEUP - * PA7 19 // SPI_MOSI PE11 7 // WIFI_RESET - * PA8 43 // V_STOP PE12 8 // WIFI_BOOT - * PA9 0 // TX PE1 9 // STATUS_LED - * PA10 1 // RX PB12 10 // SPI_CS - * PA11 30 // OTG_DM PB15 11 // SPI_MOSI - * PA12 31 // OTG_DP PB14 12 // SPI_MISO - * PA13 20 // JTAG_TMS/SWDIO PB13 13 // SPI_SCK - * PA14 21 // JTAG_TCK/SWCLK PB7 14 // SDA - * PA15 25 // SD_CARD_DETECT PB6 15 // SCL - * PB0 49 // E2_HEAT_PWM PA4 16 // SPI_CS - * PB1 50 // E3_HEAT_PWM PA5 17 // SPI_SCK - * PB3 22 // JTAG_TDO/SWO PA6 18 // SPI_MISO - * PB4 37 // USER4 PA7 19 // SPI_MOSI - * PB5 6 // WIFI_WAKEUP PA13 20 // JTAG_TMS/SWDIO - * PB6 15 // SCL PA14 21 // JTAG_TCK/SWCLK - * PB7 14 // SDA PB3 22 // JTAG_TDO/SWO - * PB8 77 // E3_PWM PC8 23 // SDIO_D0 - * PB9 35 // USER1 PC9 24 // SDIO_D1 - * PB10 64 // Y_PWM PA15 25 // SD_CARD_DETECT - * PB12 10 // SPI_CS PC10 26 // SDIO_D2 - * PB13 13 // SPI_SCK PC11 27 // SDIO_D3 - * PB14 12 // SPI_MISO PC12 28 // SDIO_CK - * PB15 11 // SPI_MOSI PD2 29 // SDIO_CMD - * PC0 68 // Z_DIR PA11 30 // OTG_DM - * PC1 33 // IR_ON PA12 31 // OTG_DP - * PC2 51 // BED_THERMISTOR_1 PD1 32 // IR_OUT - * PC3 52 // BED_THERMISTOR_2 PC1 33 // IR_ON - * PC4 57 // E1_FAN PD7 34 // USER3 - * PC5 58 // E2_FAN PB9 35 // USER1 - * PC6 67 // Z_PWM PE0 36 // USER2 - * PC7 48 // E1_HEAT_PWM PB4 37 // USER4 - * PC8 23 // SDIO_D0 PE7 38 // USER_BUTTON - * PC9 24 // SDIO_D1 PD8 39 // X_STOP - * PC10 26 // SDIO_D2 PD9 40 // Y_STOP - * PC11 27 // SDIO_D3 PD10 41 // Z_STOP - * PC12 28 // SDIO_CK PD11 42 // U_STOP - * PC13 70 // E1_DIR PA8 43 // V_STOP - * PC14 69 // E1_RESET PD0 44 // W_STOP - * PC15 66 // Z_RESET PD13 45 // BED_HEAT_2 - * PD0 44 // W_STOP PD14 46 // BED_HEAT_1 - * PD1 32 // IR_OUT PD15 47 // BED_HEAT_3 - * PD2 29 // SDIO_CMD PC7 48 // E1_HEAT_PWM - * PD3 2 // CTS PB0 49 // E2_HEAT_PWM - * PD4 3 // RTS PB1 50 // E3_HEAT_PWM - * PD5 4 // TX PC2 51 // BED_THERMISTOR_1 - * PD6 5 // RX PC3 52 // BED_THERMISTOR_2 - * PD7 34 // USER3 PA3 53 // BED_THERMISTOR_3 - * PD8 39 // X_STOP PA0 54 // E1_THERMISTOR - * PD9 40 // Y_STOP PA1 55 // E2_THERMISTOR - * PD10 41 // Z_STOP PA2 56 // E3_THERMISTOR - * PD11 42 // U_STOP PC4 57 // E1_FAN - * PD12 71 // E1_PWM PC5 58 // E2_FAN - * PD13 45 // BED_HEAT_2 PE8 59 // E3_FAN - * PD14 46 // BED_HEAT_1 PE13 60 // X_RESET - * PD15 47 // BED_HEAT_3 PE14 61 // X_PWM - * PE0 36 // USER2 PE15 62 // X_DIR - * PE1 9 // STATUS_LED PE10 63 // Y_RESET - * PE2 76 // E3_DIR PB10 64 // Y_PWM - * PE3 75 // E3_RESET PE9 65 // Y_DIR - * PE4 72 // E2_RESET PC15 66 // Z_RESET - * PE5 73 // E2_PWM PC6 67 // Z_PWM - * PE6 74 // E2_DIR PC0 68 // Z_DIR - * PE7 38 // USER_BUTTON PC14 69 // E1_RESET - * PE8 59 // E3_FAN PC13 70 // E1_DIR - * PE9 65 // Y_DIR PD12 71 // E1_PWM - * PE10 63 // Y_RESET PE4 72 // E2_RESET - * PE11 7 // WIFI_RESET PE5 73 // E2_PWM - * PE12 8 // WIFI_BOOT PE6 74 // E2_DIR - * PE13 60 // X_RESET PE3 75 // E3_RESET - * PE14 61 // X_PWM PE2 76 // E3_DIR - * PE15 62 // X_DIR PB8 77 // E3_PWM + * PA0 E1_THERMISTOR PD0 W_STOP + * PA1 E2_THERMISTOR PD1 IR_OUT + * PA2 E3_THERMISTOR PD2 SDIO_CMD + * PA3 BED_THERMISTOR_3 PD3 CTS + * PA4 SPI1_CS PD4 RTS + * PA5 SPI1_SCK PD5 TX + * PA6 SPI1_MISO PD6 RX + * PA7 SPI1_MOSI PD7 USER3 + * PA8 V_STOP PD8 X_STOP + * PA9 TX PD9 Y_STOP + * PA10 RX PD10 Z_STOP + * PA11 OTG_DM PD11 U_STOP + * PA12 OTG_DP PD12 E1_PWM + * PA13 JTAG_TMS/SWDIO PD13 BED_HEAT_2 + * PA14 JTAG_TCK/SWCLK PD14 BED_HEAT_1 + * PA15 SD_CARD_DETECT PD15 BED_HEAT_3 + * + * PB0 E2_HEAT_PWM PE0 USER2 + * PB1 E3_HEAT_PWM PE1 STATUS_LED + * PB2 --- PE2 E3_DIR + * PB3 JTAG_TDO/SWO PE3 E3_RESET + * PB4 USER4 PE4 E2_RESET + * PB5 WIFI_WAKEUP PE5 E2_PWM + * PB6 SCL PE6 E2_DIR + * PB7 SDA PE7 USER_BUTTON + * PB8 E3_PWM PE8 E3_FAN + * PB9 USER1 PE9 Y_DIR + * PB10 Y_PWM PE10 Y_RESET + * PB11 --- PE11 WIFI_RESET + * PB12 SPI2_CS PE12 WIFI_BOOT + * PB13 SPI2_SCK PE13 X_RESET + * PB14 SPI2_MISO PE14 X_PWM + * PB15 SPI2_MOSI PE15 X_DIR + * + * PC0 Z_DIR + * PC1 IR_ON + * PC2 BED_THERMISTOR_1 + * PC3 BED_THERMISTOR_2 + * PC4 E1_FAN + * PC5 E2_FAN + * PC6 Z_PWM + * PC7 E1_HEAT_PWM + * PC8 SDIO_D0 + * PC9 SDIO_D1 + * PC10 SDIO_D2 + * PC11 SDIO_D3 + * PC12 SDIO_CK + * PC13 E1_DIR + * PC14 E1_RESET + * PC15 Z_RESET */ diff --git a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h index 6368142c3427..fd6b96054214 100644 --- a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h +++ b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h @@ -130,6 +130,20 @@ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif #endif // @@ -184,12 +198,12 @@ // /** - * ______ - * 5V | 1 2 | GND - * PB15 | 3 4 | PB12 - * PB13 | 5 6 PC5 - * ---- | 7 8 | PC4 - * PB0 | 9 10 | PA14 + * ------ + * PA14 |10 9 | PB0 + * PC4 | 8 7 | -- + * PC5 | 6 5 PB13 + * PB12 | 4 3 | PB15 + * GND | 2 1 | 5V * ------ * EXP1 * @@ -209,12 +223,12 @@ #define EXP1_10_PIN PA14 #if ENABLED(CR10_STOCKDISPLAY) - /** ______ - * 5V | 1 2 | GND - * LCD_EN | 3 4 | LCD_RS - * LCD_D4 | 5 6 EN2 - * RESET | 7 8 | EN1 - * ENC | 9 10 | BEEPER + /** ------ + * BEEPER |10 9 | ENC + * EN1 | 8 7 | RESET + * EN2 | 6 5 LCD_D4 + * LCD_RS | 4 3 | LCD_EN + * GND | 2 1 | 5V * ------ */ #ifdef DISABLE_JTAGSWD @@ -230,12 +244,12 @@ #define BOARD_ST7920_DELAY_3 750 #elif ENABLED(MKS_MINI_12864) - /** ______ - * 5V | 1 2 | GND - * SPI-MOSI | 3 4 | SPI-CS - * A0 | 5 6 EN2 - * -- | 7 8 | EN1 - * ENC | 9 10 | SPI-SCK + /** ------ + * SCK |10 9 | ENC + * EN1 | 8 7 | -- + * EN2 | 6 5 A0 + * CS | 4 3 | MOSI + * GND | 2 1 | 5V * ------ */ #define DOGLCD_CS EXP1_04_PIN diff --git a/Marlin/src/pins/stm32f4/pins_VAKE403D.h b/Marlin/src/pins/stm32f4/pins_VAKE403D.h index bb5507b29a06..c6b24f9eca61 100644 --- a/Marlin/src/pins/stm32f4/pins_VAKE403D.h +++ b/Marlin/src/pins/stm32f4/pins_VAKE403D.h @@ -150,8 +150,10 @@ // // Průša i3 MK2 Multi Material Multiplexer Support // -//#define E_MUX0_PIN PG3 -//#define E_MUX1_PIN PG4 +#if HAS_PRUSA_MMU1 + //#define E_MUX0_PIN PG3 + //#define E_MUX1_PIN PG4 +#endif #define LED_PIN PB14 // Alive #define PS_ON_PIN PE0 diff --git a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h index c41b5ab1dec2..48f986e2ca70 100644 --- a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h +++ b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h @@ -57,8 +57,8 @@ * TIM14 - TEMP_TIMER (Marlin) * */ -#define STEP_TIMER 4 -#define TEMP_TIMER 14 +#define STEP_TIMER 4 +#define TEMP_TIMER 14 /** * These pin assignments are arbitrary and intending for testing purposes. @@ -69,7 +69,7 @@ * (X_DIR) PB15 | · · | PB9 (X_CS) * (LCD_D4) PB13 | · · | AVDD * _CN8_ PB12 | · · | GND - * NC | · · | PC8 (HEATER_0) PA15 | · · | PA5 (SCLK) + * -- | · · | PC8 (HEATER_0) PA15 | · · | PA5 (SCLK) * IOREF | · · | PC9 (BEEPER) PC7 | · · | PA6 (MISO) * RESET | · · | PC10 (SERVO1_PIN) PB5 | · · | PA7 (MOSI) * +3.3V | · · | PC11 (HEATER_BED) PB3 | · · | PD14 (SD_DETECT) @@ -86,7 +86,7 @@ * PF3 | · · | PD4 PF4 | · · | PF15 * PF5 | · · | PD3 (E_STEP) PB6 | · · | PG14 (E_EN) * PF10 | · · | GND (E_DIR) PB2 | · · | PG9 (E_CS) - * NC | · · | PE2 GND | · · | PE8 + * -- | · · | PE2 GND | · · | PE8 * PA7 | · · | PE4 PD13 | · · | PE7 * PF2 | · · | PE5 PD12 | · · | GND * (Y_STEP) PF1 | · · | PE6 (Y_EN) (Z_STEP) PD11 | · · | PE10 (Z_EN) diff --git a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h index dbf2593c481d..5bfc2551acfa 100644 --- a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h +++ b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h @@ -44,14 +44,13 @@ #define X_MAX_PIN 59 #define Y_MIN_PIN 60 #define Y_MAX_PIN 61 - #define Z_MIN_PIN 62 #define Z_MAX_PIN 63 #else #define X_STOP_PIN 36 #define Y_STOP_PIN 39 - #define Z_MIN_PIN 62 #define Z_MAX_PIN 42 #endif +#define Z_MIN_PIN 62 // // Z Probe (when not Z_MIN_PIN) @@ -134,4 +133,4 @@ // Timers // -#define STEP_TIMER 2 +#define STEP_TIMER 2 diff --git a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h new file mode 100644 index 000000000000..2589a316b6b1 --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h @@ -0,0 +1,332 @@ +/** + * 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 + +//#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR Mini E3 V3.0" +#endif + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#define LED_PIN PD8 + +// Onboard I2C EEPROM +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #undef NO_EEPROM_SELECTED + #define I2C_EEPROM + #define SOFT_I2C_EEPROM // Force the use of Software I2C + #define I2C_SCL_PIN PB6 + #define I2C_SDA_PIN PB7 + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// +// Servos +// +#define SERVO0_PIN PA1 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PC0 // X-STOP +#define Y_STOP_PIN PC1 // Y-STOP +#define Z_STOP_PIN PC2 // Z-STOP + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC14 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // E0-STOP +#endif + +// +// Power-loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET +#endif + +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA8 // LED driving pin +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN PC13 // Power Supply Control +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PB14 +#define X_STEP_PIN PB13 +#define X_DIR_PIN PB12 + +#define Y_ENABLE_PIN PB11 +#define Y_STEP_PIN PB10 +#define Y_DIR_PIN PB2 + +#define Z_ENABLE_PIN PB1 +#define Z_STEP_PIN PB0 +#define Z_DIR_PIN PC5 + +#define E0_ENABLE_PIN PD1 +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * Hardware serial communication ports + */ + #define X_HARDWARE_SERIAL MSerial4 + #define Y_HARDWARE_SERIAL MSerial4 + #define Z_HARDWARE_SERIAL MSerial4 + #define E0_HARDWARE_SERIAL MSerial4 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input "TH0" +#define TEMP_BED_PIN PC4 // Analog Input "TB0" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC8 // "HE" +#define HEATER_BED_PIN PC9 // "HB" +#define FAN_PIN PC6 // "FAN0" +#define FAN1_PIN PC7 // "FAN1" +#define FAN2_PIN PB15 // "FAN2" + +/** + * SKR Mini E3 V3.0 + * ------ + * (BEEPER) PB5 |10 9 | PA15 (BTN_ENC) + * (BTN_EN1) PA9 | 8 7 | RESET + * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 4 3 | PD6 (LCD_EN) + * GND | 2 1 | 5V + * ------ + * EXP1 + */ +#define EXP1_09_PIN PA15 +#define EXP1_03_PIN PD6 + +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + /** + * ------ ------ ------ + * (ENT) |10 9 | (BEEP) |10 9 | |10 9 | + * (RX) | 8 7 | (RX) | 8 7 | (TX) RX | 8 7 | TX + * (TX) 6 5 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP + * (B) | 4 3 | (A) (B) | 4 3 | (A) B | 4 3 | A + * GND | 2 1 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) + * + * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. + */ + + #error "DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. Comment out this line to continue." + + #define BEEPER_PIN EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 PB8 + #define BTN_ENC PB5 + +#elif HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN PB5 + #define BTN_ENC EXP1_09_PIN + + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 PB9 + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." + + #define LCD_PINS_RS PB9 + #define LCD_PINS_ENABLE EXP1_09_PIN + #define LCD_PINS_D4 PB8 + #define LCD_PINS_D5 PA10 + #define LCD_PINS_D6 PA9 + #define LCD_PINS_D7 PB5 + #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define DOGLCD_CS PB8 + #define DOGLCD_A0 PB9 + #define DOGLCD_SCK PB5 + #define DOGLCD_MOSI EXP1_03_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + + #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." + + /** + * TFTGLCD_PANEL_SPI display pinout + * + * Board Display + * ------ ------ + * (BEEPER) PB6 |10 9 | PB5 (SD_DET) 5V |10 9 | GND + * RESET | 8 7 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET) + * PB9 6 5 | PA10 (SD_CS) (MOSI) | 6 5 | -- + * PB7 | 4 3 | PB8 (LCD_CS) (SD_CS) | 4 3 | (LCD_CS) + * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Display + * + * EXP1-1 ----------- EXP1-10 + * EXP1-2 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-4 ----------- FREE + * SPI1-3 ----------- EXP1-2 + * EXP1-6 ----------- EXP1-4 + * EXP1-7 ----------- FREE + * EXP1-8 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-10 ----------- EXP1-7 + */ + + #define TFTGLCD_CS PA9 + + #endif + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #endif + +#endif // HAS_WIRED_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." + + /** + * FYSETC TFT TFT81050 display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 6 5 | PB9 (FREE) (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 4 3 | PB7 (FREE) (SD_CS) | 4 3 | (MOD_RESET) + * 5V | 2 1 | GND (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * _________ + * EXP1-1 ----------- EXP1-10 + * EXP1-2 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-4 ----------- EXP1-5 + * SPI1-3 ----------- EXP1-2 + * EXP1-6 ----------- EXP1-4 + * EXP1-7 ----------- EXP1-8 + * EXP1-8 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-10 ----------- EXP1-7 + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN EXP1_09_PIN + + #define CLCD_MOD_RESET PA9 + #define CLCD_SPI_CS PB8 + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN PC3 +#elif SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) + #define SD_DETECT_PIN PB5 + #define SD_SS_PIN PA10 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." +#endif + +#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card + +#define ENABLE_SPI1 +#define SDSS ONBOARD_SD_CS_PIN +#define SD_SS_PIN ONBOARD_SD_CS_PIN +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h index cb038fe73702..c813287866dd 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h @@ -135,7 +135,6 @@ #define DOGLCD_A0 40 // F2 JP2-2 #define DOGLCD_CS 41 // F3 JP2-4 - #define LCD_SCREEN_ROT_180 #define BTN_EN1 2 // D2 TX1 JP2-5 #define BTN_EN2 3 // D3 RX1 JP2-7 @@ -146,6 +145,8 @@ #define STAT_LED_RED_PIN 12 // C2 JP11-14 #define STAT_LED_BLUE_PIN 10 // C0 JP11-12 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(LCD_I2C_PANELOLU2) #define BTN_EN1 3 // D3 RX1 JP2-7 diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 76b98ccbeb33..1ac953c89f8b 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -212,7 +212,6 @@ #define BEEPER_PIN 8 // E0 JP11-10 #define DOGLCD_A0 40 // F2 JP2-2 #define DOGLCD_CS 41 // F3 JP2-4 - #define LCD_SCREEN_ROT_180 #define BTN_EN1 2 // D2 TX1 JP2-5 #define BTN_EN2 3 // D3 RX1 JP2-7 @@ -223,6 +222,8 @@ #define STAT_LED_RED_PIN 12 // C2 JP11-14 #define STAT_LED_BLUE_PIN 10 // C0 JP11-12 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(MINIPANEL) #if DISABLED(USE_INTERNAL_SD) diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index a81932d49485..3402bfaee382 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -392,50 +392,51 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { #if ENABLED(SD_CHECK_AND_RETRY) #ifdef FAST_CRC - static const uint16_t crctab16[] PROGMEM = { - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, - 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, - 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, - 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, - 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, - 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, - 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, - 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, - 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, - 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, - 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, - 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, - 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, - 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, - 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, - 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, - 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, - 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, - 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, - 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, - 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, - 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, - 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 - }; + static const uint16_t crctab16[] PROGMEM = { + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, + 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, + 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, + 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, + 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, + 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, + 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, + 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, + 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, + 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, + 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, + 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, + 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, + 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, + 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, + 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, + 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, + 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, + 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, + 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, + 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, + 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 + }; // faster CRC-CCITT // uses the x^16,x^12,x^5,x^1 polynomial. - static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { - uint16_t crc = 0; - for (size_t i = 0; i < n; i++) { - crc = pgm_read_word(&crctab16[(crc >> 8 ^ data[i]) & 0xFF]) ^ (crc << 8); + static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { + uint16_t crc = 0; + for (size_t i = 0; i < n; i++) + crc = pgm_read_word(&crctab16[(crc >> 8 ^ data[i]) & 0xFF]) ^ (crc << 8); + return crc; } - return crc; - } + #else + // slower CRC-CCITT // uses the x^16,x^12,x^5,x^1 polynomial. static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { @@ -449,7 +450,9 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { } return crc; } + #endif + #endif // SD_CHECK_AND_RETRY bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) { diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index b357495a3edb..1c1e0c7d145a 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -89,6 +89,7 @@ bool SdBaseFile::addDirCluster() { } // cache a file's directory entry +// cache the current "dirBlock_" and return the entry at index "dirIndex_" // return pointer to cached entry or null for failure dir_t* SdBaseFile::cacheDirEntry(uint8_t action) { if (!vol_->cacheRawBlock(dirBlock_, action)) return nullptr; @@ -384,6 +385,20 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) { return DIR_IS_FILE(&dir) ? 1 : 2; } +/** + * Calculate a checksum for an 8.3 filename + * + * \param name The 8.3 file name to calculate + * + * \return The checksum byte + */ +uint8_t lfn_checksum(const uint8_t *name) { + uint8_t sum = 0; + for (uint8_t i = 11; i; i--) + sum = ((sum & 1) << 7) + (sum >> 1) + *name++; + return sum; +} + // Format directory name field from a 8.3 name string bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char **ptr) { uint8_t n = 7, // Max index until a dot is found @@ -430,6 +445,10 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { SdBaseFile *sub = &dir1; SdBaseFile *start = parent; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + uint8_t dlname[LONG_FILENAME_LENGTH]; + #endif + if (!parent || isOpen()) return false; if (*path == '/') { @@ -439,28 +458,31 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { parent = &dir2; } } - while (1) { - if (!make83Name(path, dname, &path)) return false; + + for (;;) { + if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false; while (*path == '/') path++; if (!*path) break; - if (!sub->open(parent, dname, O_READ)) { - if (!pFlag || !sub->mkdir(parent, dname)) + if (!sub->open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), O_READ)) { + if (!pFlag || !sub->mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname))) return false; } if (parent != start) parent->close(); parent = sub; sub = parent != &dir1 ? &dir1 : &dir2; } - return mkdir(parent, dname); + return mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname)); } -bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11]) { +bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) +) { if (ENABLED(SDCARD_READONLY)) return false; if (!parent->isDir()) return false; // create a normal file - if (!open(parent, dname, O_CREAT | O_EXCL | O_RDWR)) return false; + if (!open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), O_CREAT | O_EXCL | O_RDWR)) return false; // convert file to directory flags_ = O_READ; @@ -578,6 +600,10 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { SdBaseFile dir1, dir2; SdBaseFile *parent = dirFile, *sub = &dir1; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + uint8_t dlname[LONG_FILENAME_LENGTH]; + #endif + if (!dirFile || isOpen()) return false; if (*path == '/') { // Path starts with '/' @@ -589,90 +615,244 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { } for (;;) { - if (!make83Name(path, dname, &path)) return false; + if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false; while (*path == '/') path++; if (!*path) break; - if (!sub->open(parent, dname, O_READ)) return false; + if (TERN0(LONG_FILENAME_WRITE_SUPPORT, !sub->open(parent, dname, dlname, O_READ))) return false; if (parent != dirFile) parent->close(); parent = sub; sub = parent != &dir1 ? &dir1 : &dir2; } - return open(parent, dname, oflag); + return open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), oflag); } -// open with filename in dname -bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag) { +// open with filename in dname and long filename in dlname +bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) + , uint8_t oflag +) { bool emptyFound = false, fileFound = false; - uint8_t index; + uint8_t index = 0; dir_t *p; - vol_ = dirFile->vol_; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // LFN - Long File Name support + const bool useLFN = dlname[0] != 0; + bool lfnFileFound = false; + vfat_t *pvFat; + uint8_t emptyCount = 0, + emptyIndex = 0, + reqEntriesNum = useLFN ? getLFNEntriesNum((char*)dlname) + 1 : 1, + lfnNameLength = useLFN ? strlen((char*)dlname) : 0, + lfnName[LONG_FILENAME_LENGTH], + lfnSequenceNumber = 0, + lfnChecksum = 0; + #endif + // Rewind this dir + vol_ = dirFile->vol_; dirFile->rewind(); - // search for file + // search for file while (dirFile->curPosition_ < dirFile->fileSize_) { - index = 0xF & (dirFile->curPosition_ >> 5); - p = dirFile->readDirCache(); - if (!p) return false; + // Get absolute index position + index = (dirFile->curPosition_ >> 5) IF_DISABLED(LONG_FILENAME_WRITE_SUPPORT, & 0x0F); + // Get next entry + if (!(p = dirFile->readDirCache())) return false; + + // Check empty status: Is entry empty? if (p->name[0] == DIR_NAME_FREE || p->name[0] == DIR_NAME_DELETED) { - // remember first empty slot + // Count the contiguous available entries in which (eventually) fit the new dir entry, if it's a write operation if (!emptyFound) { - dirBlock_ = dirFile->vol_->cacheBlockNumber(); - dirIndex_ = index; - emptyFound = true; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + if (emptyCount == 0) emptyIndex = index; + // Incr empty entries counter + // If found the required empty entries, mark it + if (++emptyCount == reqEntriesNum) { + dirBlock_ = dirFile->vol_->cacheBlockNumber(); + dirIndex_ = index & 0xF; + emptyFound = true; + } + #else + dirBlock_ = dirFile->vol_->cacheBlockNumber(); + dirIndex_ = index; + emptyFound = true; + #endif } - // done if no entries follow + // Done if no entries follow if (p->name[0] == DIR_NAME_FREE) break; } - else if (!memcmp(dname, p->name, 11)) { - fileFound = true; - break; + else { // Entry not empty + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // Reset empty counter + if (!emptyFound) emptyCount = 0; + // Search for SFN or LFN? + if (!useLFN) { + // Check using SFN: file found? + if (!memcmp(dname, p->name, 11)) { + fileFound = true; + break; + } + } + else { + // Check using LFN: LFN not found? continue search for LFN + if (!lfnFileFound) { + // Is this dir a LFN? + if (isDirLFN(p)) { + // Get VFat dir entry + pvFat = (vfat_t *) p; + // Get checksum from the last entry of the sequence + if (pvFat->sequenceNumber & 0x40) lfnChecksum = pvFat->checksum; + // Get LFN sequence number + lfnSequenceNumber = pvFat->sequenceNumber & 0x1F; + if WITHIN(lfnSequenceNumber, 1, reqEntriesNum) { + // Check checksum for all other entries with the starting checksum fetched before + if (lfnChecksum == pvFat->checksum) { + // Set chunk of LFN from VFAT entry into lfnName + getLFNName(pvFat, (char *)lfnName, lfnSequenceNumber); + // LFN found? + if (!strncasecmp((char*)dlname, (char*)lfnName, lfnNameLength)) lfnFileFound = true; + } + } + } + } + else { // Complete LFN found, check for related SFN + // Check if only the SFN checksum match because the filename may be different due to different truncation methods + if (!isDirLFN(p) && (lfnChecksum == lfn_checksum(p->name))) { + fileFound = true; + break; + } + else lfnFileFound = false; // SFN not valid for the LFN found, reset LFN FileFound + } + } + #else + + if (!memcmp(dname, p->name, 11)) { + fileFound = true; + break; + } + + #endif // LONG_FILENAME_WRITE_SUPPORT } } + if (fileFound) { // don't open existing file if O_EXCL if (oflag & O_EXCL) return false; + TERN_(LONG_FILENAME_WRITE_SUPPORT, index &= 0xF); } else { // don't create unless O_CREAT and O_WRITE if ((oflag & (O_CREAT | O_WRITE)) != (O_CREAT | O_WRITE)) return false; - if (emptyFound) { - index = dirIndex_; - p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); - if (!p) return false; - } - else { - if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) return false; - // add and zero cluster for dirFile - first cluster is in cache for write - if (!dirFile->addDirCluster()) return false; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) - // use first entry in cluster - p = dirFile->vol_->cache()->dir; - index = 0; - } - // initialize as empty file - memset(p, 0, sizeof(*p)); - memcpy(p->name, dname, 11); + // Use bookmark index if found empty entries + if (emptyFound) index = emptyIndex; - // set timestamps - if (dateTime_) { - // call user date/time function - dateTime_(&p->creationDate, &p->creationTime); - } - else { - // use default date/time - p->creationDate = FAT_DEFAULT_DATE; - p->creationTime = FAT_DEFAULT_TIME; - } - p->lastAccessDate = p->creationDate; - p->lastWriteDate = p->creationDate; - p->lastWriteTime = p->creationTime; + // Make room for needed entries + while (emptyCount < reqEntriesNum) { + p = dirFile->readDirCache(); + if (!p) break; + emptyCount++; + } + while (emptyCount < reqEntriesNum) { + if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) return false; + // add and zero cluster for dirFile - first cluster is in cache for write + if (!dirFile->addDirCluster()) return false; + emptyCount += dirFile->vol_->blocksPerCluster() * 16; + } + + // Move to 1st entry to write + if (!dirFile->seekSet(32 * index)) return false; + + // Dir entries write loop: [LFN] + SFN(1) + LOOP_L_N(dirWriteIdx, reqEntriesNum) { + index = (dirFile->curPosition_ / 32) & 0xF; + p = dirFile->readDirCache(); + // LFN or SFN Entry? + if (dirWriteIdx < reqEntriesNum - 1) { + // Write LFN Entries + pvFat = (vfat_t *) p; + // initialize as empty file + memset(pvFat, 0, sizeof(*pvFat)); + lfnSequenceNumber = (reqEntriesNum - dirWriteIdx - 1) & 0x1F; + pvFat->attributes = DIR_ATT_LONG_NAME; + pvFat->checksum = lfn_checksum(dname); + // Set sequence number and mark as last LFN entry if it's the 1st loop + pvFat->sequenceNumber = lfnSequenceNumber | (dirWriteIdx == 0 ? 0x40 : 0); + // Set LFN name block + setLFNName(pvFat, (char*)dlname, lfnSequenceNumber); + } + else { + // Write SFN Entry + // initialize as empty file + memset(p, 0, sizeof(*p)); + memcpy(p->name, dname, 11); + + // set timestamps + if (dateTime_) { + // call user date/time function + dateTime_(&p->creationDate, &p->creationTime); + } + else { + // use default date/time + p->creationDate = FAT_DEFAULT_DATE; + p->creationTime = FAT_DEFAULT_TIME; + } + p->lastAccessDate = p->creationDate; + p->lastWriteDate = p->creationDate; + p->lastWriteTime = p->creationTime; + } + + // write entry to SD + dirFile->vol_->cacheSetDirty(); + if (!dirFile->vol_->cacheFlush()) return false; + } + + #else // !LONG_FILENAME_WRITE_SUPPORT + + if (emptyFound) { + index = dirIndex_; + p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!p) return false; + } + else { + if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) return false; + + // add and zero cluster for dirFile - first cluster is in cache for write + if (!dirFile->addDirCluster()) return false; + + // use first entry in cluster + p = dirFile->vol_->cache()->dir; + index = 0; + } + + // initialize as empty file + memset(p, 0, sizeof(*p)); + memcpy(p->name, dname, 11); + + // set timestamps + if (dateTime_) { + // call user date/time function + dateTime_(&p->creationDate, &p->creationTime); + } + else { + // use default date/time + p->creationDate = FAT_DEFAULT_DATE; + p->creationTime = FAT_DEFAULT_TIME; + } + + p->lastAccessDate = p->creationDate; + p->lastWriteDate = p->creationDate; + p->lastWriteTime = p->creationTime; + + // write entry to SD + if (!dirFile->vol_->cacheFlush()) return false; + + #endif // !LONG_FILENAME_WRITE_SUPPORT - // write entry to SD - if (!dirFile->vol_->cacheFlush()) return false; } // open entry in cache return openCachedEntry(index, oflag); @@ -808,6 +988,191 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { return false; } +#if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + + /** + * Check if dir is a long file name entry (LFN) + * + * \param[in] dir Parent of this directory will be opened. Must not be root. + * \return true if the dir is a long file name entry (LFN) + */ + bool SdBaseFile::isDirLFN(const dir_t* dir) { + if (DIR_IS_LONG_NAME(dir)) { + vfat_t *VFAT = (vfat_t*)dir; + // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 + if ((VFAT->firstClusterLow == 0) && WITHIN((VFAT->sequenceNumber & 0x1F), 1, MAX_VFAT_ENTRIES)) return true; + } + return false; + } + + /** + * Check if dirname string is a long file name (LFN) + * + * \param[in] dirname The string to check + * \return true if the dirname is a long file name (LFN) + * \return false if the dirname is a short file name 8.3 (SFN) + */ + bool SdBaseFile::isDirNameLFN(const char *dirname) { + uint8_t length = strlen(dirname); + uint8_t idx = length; + bool dotFound = false; + if (idx > 12) return true; // LFN due to filename length > 12 ("filename.ext") + // Check dot(s) position + while (idx) { + if (dirname[--idx] == '.') { + if (!dotFound) { + // Last dot (extension) is allowed only + // in position [1..8] from start or [0..3] from end for SFN else it's a LFN + // A filename starting with "." is a LFN (eg. ".file" ->in SFN-> "file~1 ") + // A filename ending with "." is a SFN (if length <= 9) (eg. "file." ->in SFN-> "file ") + if (idx > 8 || idx == 0 || (length - idx - 1) > 3) return true; // LFN due to dot extension position + dotFound = true; + } + else { + // Found another dot, is a LFN + return true; + } + } + } + // If no dots found, the filename must be of max 8 characters + if ((!dotFound) && length > 8) return true; // LFN due to max filename (without extension) length + return false; + } + + /** + * Parse path and return 8.3 format and LFN filenames (if the parsed path is a LFN) + * The SFN is without dot ("FILENAMEEXT") + * The LFN is complete ("Filename.ext") + */ + bool SdBaseFile::parsePath(const char *path, uint8_t *name, uint8_t *lname, const char **ptrNextPath) { + // Init randomizer for SFN generation + randomSeed(millis()); + // Parse the LFN + uint8_t ilfn = 0; + bool lastDotFound = false; + const char *pLastDot = 0; + const char *lfnpath = path; + uint8_t c; + + while (*lfnpath && *lfnpath != '/') { + if (ilfn == LONG_FILENAME_LENGTH - 1) return false; // Name too long + c = *lfnpath++; // Get char and advance + // Fail for illegal characters + PGM_P p = PSTR("|<>^+=?/[];:,*\"\\"); + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; // Check reserved characters + if (c < 0x20 || c == 0x7F) return false; // Check non-printable characters + if (c == '.' && (lfnpath - 1) > path) { // Skip dot '.' check in 1st position + // Save last dot pointer (skip if starts with '.') + pLastDot = lfnpath - 1; + lastDotFound = true; + } + lname[ilfn++] = c; // Set LFN character + } + // Terminate LFN + lname[ilfn] = 0; + + // Parse/generate 8.3 SFN. Will take + // until 8 characters for the filename part + // until 3 characters for the extension part (if exists) + // Add 4 more characters if name part < 3 + // Add '~cnt' characters if it's a LFN + const bool isLFN = isDirNameLFN((char*)lname); + + uint8_t n = isLFN ? 5 : 7, // Max index for each component of the file: + // starting with 7 or 5 (if LFN) + // switch to 10 for extension if the last dot is found + i = 11; + while (i) name[--i] = ' '; // Set whole FILENAMEEXT to spaces + while (*path && *path != '/') { + c = *path++; // Get char and advance + // Skip spaces and dots (if it's not the last dot) + if (c == ' ') continue; + if (c == '.' && (!lastDotFound || (lastDotFound && path < pLastDot))) continue; + // Fail for illegal characters + PGM_P p = PSTR("|<>^+=?/[];:,*\"\\"); + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; // Check reserved characters + if (c < 0x21 || c == 0x7F) return false; // Check non-printable characters + // Is last dot? + if (c == '.') { + // Switch to extension part + n = 10; + i = 8; + } + // If in valid range add the character + else if (i <= n) // Check size for 8.3 format + name[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name + } + // If it's a LFN then the SFN always need: + // - A minimal of 3 characters (otherwise 4 chars are added) + // - The '~cnt' at the end + if (isLFN) { + // Get the 1st free character + uint8_t iFree = 0; + while (1) if (name[iFree++] == ' ' || iFree == 11) break; + iFree--; + // Check minimal length + if (iFree < 3) { + // Append 4 extra characters + name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(0,24) + 'A'; + name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(0,24) + 'A'; + } + // Append '~cnt' characters + if (iFree > 5) iFree = 5; // Force the append in the last 3 characters of name part + name[iFree++] = '~'; + name[iFree++] = random(1,9) + '0'; + name[iFree++] = random(1,9) + '0'; + } + + // Check if LFN is needed + if (!isLFN) lname[0] = 0; // Zero LFN + *ptrNextPath = path; // Set passed pointer to the end + return name[0] != ' '; // Return true if any name was set + } + + /** + * Get the LFN filename block from a dir. Get the block in lname at startOffset + */ + void SdBaseFile::getLFNName(vfat_t *pFatDir, char *lname, uint8_t sequenceNumber) { + uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH; + LOOP_L_N(i, FILENAME_LENGTH) { + const uint16_t utf16_ch = (i >= 11) ? pFatDir->name3[i - 11] : (i >= 5) ? pFatDir->name2[i - 5] : pFatDir->name1[i]; + #if ENABLED(UTF_FILENAME_SUPPORT) + // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks + // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. + uint16_t idx = (startOffset + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding + lname[idx] = utf16_ch & 0xFF; + lname[idx + 1] = (utf16_ch >> 8) & 0xFF; + #else + // Replace all multibyte characters to '_' + lname[startOffset + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); + #endif + } + } + + /** + * Set the LFN filename block lname to a dir. Put the block based on sequence number + */ + void SdBaseFile::setLFNName(vfat_t *pFatDir, char *lname, uint8_t sequenceNumber) { + uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH; + uint8_t nameLength = strlen(lname); + LOOP_L_N(i, FILENAME_LENGTH) { + uint16_t ch = 0; + if ((startOffset + i) < nameLength) + ch = lname[startOffset + i]; + else if ((startOffset + i) > nameLength) + ch = 0xFFFF; + // Set char + if (i < 5) + pFatDir->name1[i] = ch; + else if (i < 11) + pFatDir->name2[i - 5] = ch; + else + pFatDir->name3[i - 11] = ch; + } + } + +#endif // LONG_FILENAME_WRITE_SUPPORT + #if 0 /** * Open a directory's parent directory. @@ -1049,20 +1414,6 @@ int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { return nbyte; } -/** - * Calculate a checksum for an 8.3 filename - * - * \param name The 8.3 file name to calculate - * - * \return The checksum byte - */ -uint8_t lfn_checksum(const uint8_t *name) { - uint8_t sum = 0; - for (uint8_t i = 11; i; i--) - sum = ((sum & 1) << 7) + (sum >> 1) + *name++; - return sum; -} - /** * Read the next entry in a directory. * @@ -1110,30 +1461,40 @@ int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) { if (VFAT->firstClusterLow == 0) { const uint8_t seq = VFAT->sequenceNumber & 0x1F; if (WITHIN(seq, 1, MAX_VFAT_ENTRIES)) { - n = (seq - 1) * (FILENAME_LENGTH); - if (n == 0) { + if (seq == 1) { checksum = VFAT->checksum; checksum_error = 0; } else if (checksum != VFAT->checksum) // orphan detected checksum_error = 1; - LOOP_L_N(i, FILENAME_LENGTH) { - const uint16_t utf16_ch = (i >= 11) ? VFAT->name3[i - 11] : (i >= 5) ? VFAT->name2[i - 5] : VFAT->name1[i]; - #if ENABLED(UTF_FILENAME_SUPPORT) - // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks - // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. - uint16_t idx = (n + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding - longFilename[idx] = utf16_ch & 0xFF; - longFilename[idx + 1] = (utf16_ch >> 8) & 0xFF; - #else - // Replace all multibyte characters to '_' - longFilename[n + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); - #endif - } + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + + getLFNName(VFAT, longFilename, seq); // Get chunk of LFN from VFAT entry + + #else // !LONG_FILENAME_WRITE_SUPPORT + + n = (seq - 1) * (FILENAME_LENGTH); + + LOOP_L_N(i, FILENAME_LENGTH) { + const uint16_t utf16_ch = (i >= 11) ? VFAT->name3[i - 11] : (i >= 5) ? VFAT->name2[i - 5] : VFAT->name1[i]; + #if ENABLED(UTF_FILENAME_SUPPORT) + // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks + // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. + uint16_t idx = (n + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding + longFilename[idx] = utf16_ch & 0xFF; + longFilename[idx + 1] = (utf16_ch >> 8) & 0xFF; + #else + // Replace all multibyte characters to '_' + longFilename[n + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); + #endif + } + + #endif // !LONG_FILENAME_WRITE_SUPPORT + // If this VFAT entry is the last one, add a NUL terminator at the end of the string if (VFAT->sequenceNumber & 0x40) - longFilename[(n + FILENAME_LENGTH) * LONG_FILENAME_CHARSIZE] = '\0'; + longFilename[LONG_FILENAME_CHARSIZE * TERN(LONG_FILENAME_WRITE_SUPPORT, seq * FILENAME_LENGTH, (n + FILENAME_LENGTH))] = '\0'; } } } @@ -1227,6 +1588,11 @@ bool SdBaseFile::remove() { dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); if (!d) return false; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // get SFN checksum before name rewrite (needed for LFN deletion) + const uint8_t sfn_checksum = lfn_checksum(d->name); + #endif + // mark entry deleted d->name[0] = DIR_NAME_DELETED; @@ -1234,8 +1600,48 @@ bool SdBaseFile::remove() { type_ = FAT_FILE_TYPE_CLOSED; // write entry to SD - return vol_->cacheFlush(); - return true; + #if DISABLED(LONG_FILENAME_WRITE_SUPPORT) + + return vol_->cacheFlush(); + + #else // LONG_FILENAME_WRITE_SUPPORT + + flags_ = 0; + + if (!vol_->cacheFlush()) return false; + + // Check if the entry has a LFN + bool lastEntry = false; + // loop back to search for any LFN entries related to this file + LOOP_S_LE_N(sequenceNumber, 1, MAX_VFAT_ENTRIES) { + dirIndex_ = (dirIndex_ - 1) & 0xF; + if (dirBlock_ == 0) break; + if (dirIndex_ == 0xF) dirBlock_--; + dir_t *dir = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!dir) return false; + + // check for valid LFN: not deleted, not top dirs (".", ".."), must be a LFN + if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.' || !isDirLFN(dir)) break; + // check coherent LFN: checksum and sequenceNumber must match + vfat_t* dirlfn = (vfat_t*) dir; + if (dirlfn->checksum != sfn_checksum || (dirlfn->sequenceNumber & 0x1F) != sequenceNumber) break; // orphan entry + // is last entry of LFN ? + lastEntry = (dirlfn->sequenceNumber & 0x40); + // mark as deleted + dirlfn->sequenceNumber = DIR_NAME_DELETED; + // Flush to SD + if (!vol_->cacheFlush()) return false; + // exit on last entry of LFN deleted + if (lastEntry) break; + } + + // Restore current index + //if (!seekSet(32UL * dirIndex_)) return false; + //dirIndex_ += prevDirIndex; + + return true; + + #endif // LONG_FILENAME_WRITE_SUPPORT } /** diff --git a/Marlin/src/sd/SdBaseFile.h b/Marlin/src/sd/SdBaseFile.h index 342edefb7079..bda44c6bd5c3 100644 --- a/Marlin/src/sd/SdBaseFile.h +++ b/Marlin/src/sd/SdBaseFile.h @@ -377,8 +377,26 @@ class SdBaseFile { dir_t* cacheDirEntry(uint8_t action); int8_t lsPrintNext(uint8_t flags, uint8_t indent); static bool make83Name(const char *str, uint8_t *name, const char **ptr); - bool mkdir(SdBaseFile *parent, const uint8_t dname[11]); - bool open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag); + bool mkdir(SdBaseFile *parent, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) + ); + bool open(SdBaseFile *dirFile, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) + , uint8_t oflag + ); bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags); dir_t* readDirCache(); + + // Long Filename create/write support + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + static bool isDirLFN(const dir_t* dir); + static bool isDirNameLFN(const char *dirname); + static bool parsePath(const char *str, uint8_t *name, uint8_t *lname, const char **ptr); + /** + * Return the number of entries needed in the FAT for this LFN + */ + static inline uint8_t getLFNEntriesNum(const char *lname) { return (strlen(lname) + 12) / 13; } + static void getLFNName(vfat_t *vFatDir, char *lname, uint8_t startOffset); + static void setLFNName(vfat_t *vFatDir, char *lname, uint8_t lfnSequenceNumber); + #endif }; diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 513d682de68b..724de8f82a2f 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -33,8 +33,8 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif #include "../module/planner.h" // for synchronize @@ -195,11 +195,15 @@ char *createFilename(char * const buffer, const dir_t &p) { } // -// Return 'true' if the item is a folder or G-code file +// Return 'true' if the item is a folder, G-code file or Binary file // -bool CardReader::is_dir_or_gcode(const dir_t &p) { +bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/)) { //uint8_t pn0 = p.name[0]; + #if DISABLED(CUSTOM_FIRMWARE_UPLOAD) + constexpr bool onlyBin = false; + #endif + if ( (p.attributes & DIR_ATT_HIDDEN) // Hidden by attribute // When readDir() > 0 these must be false: //|| pn0 == DIR_NAME_FREE || pn0 == DIR_NAME_DELETED // Clear or Deleted entry @@ -208,10 +212,15 @@ bool CardReader::is_dir_or_gcode(const dir_t &p) { ) return false; flag.filenameIsDir = DIR_IS_SUBDIR(&p); // We know it's a File or Folder + setBinFlag(p.name[8] == 'B' && // List .bin files (a firmware file for flashing) + p.name[9] == 'I' && + p.name[10]== 'N'); return ( flag.filenameIsDir // All Directories are ok - || (p.name[8] == 'G' && p.name[9] != '~') // Non-backup *.G* files are accepted + || fileIsBinary() // BIN files are accepted + || (!onlyBin && p.name[8] == 'G' + && p.name[9] != '~') // Non-backup *.G* files are accepted ); } @@ -222,7 +231,7 @@ int CardReader::countItems(SdFile dir) { dir_t p; int c = 0; while (dir.readDir(&p, longFilename) > 0) - c += is_dir_or_gcode(p); + c += is_visible_entity(p); #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) nrFiles = c; @@ -237,7 +246,7 @@ int CardReader::countItems(SdFile dir) { void CardReader::selectByIndex(SdFile dir, const uint8_t index) { dir_t p; for (uint8_t cnt = 0; dir.readDir(&p, longFilename) > 0;) { - if (is_dir_or_gcode(p)) { + if (is_visible_entity(p)) { if (cnt == index) { createFilename(filename, p); return; // 0 based index @@ -253,7 +262,7 @@ void CardReader::selectByIndex(SdFile dir, const uint8_t index) { void CardReader::selectByName(SdFile dir, const char * const match) { dir_t p; for (uint8_t cnt = 0; dir.readDir(&p, longFilename) > 0; cnt++) { - if (is_dir_or_gcode(p)) { + if (is_visible_entity(p)) { createFilename(filename, p); if (strcasecmp(match, filename) == 0) return; } @@ -271,9 +280,9 @@ void CardReader::selectByName(SdFile dir, const char * const match) { * good addition. */ void CardReader::printListing( - SdFile parent + SdFile parent, const char * const prepend + OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/) OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) - , const char * const prepend/*=nullptr*/ OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/) ) { dir_t p; @@ -283,61 +292,47 @@ void CardReader::printListing( size_t lenPrepend = prepend ? strlen(prepend) + 1 : 0; // Allocate enough stack space for the full path including / separator char path[lenPrepend + FILENAME_LENGTH]; - if (prepend) { - strcpy(path, prepend); - path[lenPrepend - 1] = '/'; - } + if (prepend) { strcpy(path, prepend); path[lenPrepend - 1] = '/'; } char* dosFilename = path + lenPrepend; createFilename(dosFilename, p); // Get a new directory object using the full path // and dive recursively into it. SdFile child; // child.close() in destructor - if (child.open(&parent, dosFilename, O_READ)) + if (child.open(&parent, dosFilename, O_READ)) { #if ENABLED(LONG_FILENAME_HOST_SUPPORT) if (includeLongNames) { size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0; // Allocate enough stack space for the full long path including / separator char pathLong[lenPrependLong + strlen(longFilename) + 1]; - if (prependLong) { - strcpy(pathLong, prependLong); - pathLong[lenPrependLong - 1] = '/'; - } + if (prependLong) { strcpy(pathLong, prependLong); pathLong[lenPrependLong - 1] = '/'; } strcpy(pathLong + lenPrependLong, longFilename); - printListing(child, true, path, pathLong); + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin), true, pathLong); } else - printListing(child, false, path); + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); #else - printListing(child, path); + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); #endif + } else { SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); return; } } - else if (is_dir_or_gcode(p)) { - if (prepend) { - SERIAL_ECHO(prepend); - SERIAL_CHAR('/'); - } + else if (is_visible_entity(p OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin))) { + if (prepend) { SERIAL_ECHO(prepend); SERIAL_CHAR('/'); } SERIAL_ECHO(createFilename(filename, p)); SERIAL_CHAR(' '); + SERIAL_ECHO(p.fileSize); #if ENABLED(LONG_FILENAME_HOST_SUPPORT) - if (!includeLongNames) - #endif - SERIAL_ECHOLN(p.fileSize); - #if ENABLED(LONG_FILENAME_HOST_SUPPORT) - else { - SERIAL_ECHO(p.fileSize); + if (includeLongNames) { SERIAL_CHAR(' '); - if (prependLong) { - SERIAL_ECHO(prependLong); - SERIAL_CHAR('/'); - } - SERIAL_ECHOLN(longFilename[0] ? longFilename : "???"); + if (prependLong) { SERIAL_ECHO(prependLong); SERIAL_CHAR('/'); } + SERIAL_ECHO(longFilename[0] ? longFilename : filename); } #endif + SERIAL_EOL(); } } } @@ -345,10 +340,16 @@ void CardReader::printListing( // // List all files on the SD card // -void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=false*/)) { +void CardReader::ls( + TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/) + #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) + , + #endif + TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) +) { if (flag.mounted) { root.rewind(); - printListing(root OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); + printListing(root, nullptr OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin) OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); } } @@ -359,7 +360,7 @@ void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=fa // void CardReader::printLongPath(char * const path) { - int i, pathLen = strlen(path); + int i, pathLen = path ? strlen(path) : 0; // SERIAL_ECHOPGM("Full Path: "); SERIAL_ECHOLN(path); @@ -385,9 +386,9 @@ void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=fa diveDir.rewind(); selectByName(diveDir, segment); - // Print /LongNamePart to serial output + // Print /LongNamePart to serial output or the short name if not available SERIAL_CHAR('/'); - SERIAL_ECHO(longFilename[0] ? longFilename : "???"); + SERIAL_ECHO(longFilename[0] ? longFilename : filename); // If the filename was printed then that's it if (!flag.filenameIsDir) break; @@ -457,7 +458,7 @@ void CardReader::mount() { cdroot(); #if ENABLED(USB_FLASH_DRIVE_SUPPORT) || PIN_EXISTS(SD_DETECT) else if (marlin_state != MF_INITIALIZING) - ui.set_status(GET_TEXT_F(MSG_SD_INIT_FAIL), -1); + ui.set_status(GET_TEXT_F(MSG_MEDIA_INIT_FAIL), -1); #endif ui.refresh(); @@ -867,6 +868,7 @@ void CardReader::selectFileByIndex(const uint16_t nr) { strcpy(filename, sortshort[nr]); strcpy(longFilename, sortnames[nr]); flag.filenameIsDir = IS_DIR(nr); + setBinFlag(strcmp_P(strrchr(filename, '.'), PSTR(".BIN")) == 0); return; } #endif @@ -884,6 +886,7 @@ void CardReader::selectFileByName(const char * const match) { strcpy(filename, sortshort[nr]); strcpy(longFilename, sortnames[nr]); flag.filenameIsDir = IS_DIR(nr); + setBinFlag(strcmp_P(strrchr(filename, '.'), PSTR(".BIN")) == 0); return; } #endif diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 97003e1d1376..483ab8139584 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -80,6 +80,9 @@ typedef struct { filenameIsDir:1, workDirIsRoot:1, abort_sd_printing:1 + #if DO_LIST_BIN_FILES + , filenameIsBin:1 + #endif #if ENABLED(BINARY_FILE_TRANSFER) , binary_mode:1 #endif @@ -115,7 +118,7 @@ class CardReader { static void mount(); static void release(); - static inline bool isMounted() { return flag.mounted; } + static bool isMounted() { return flag.mounted; } // Handle media insert/remove static void manage_media(); @@ -128,7 +131,7 @@ class CardReader { static uint8_t autofile_index; // Next auto#.g index to run, plus one. Ignored by autofile_check when zero. static void autofile_begin(); // Begin check. Called automatically after boot-up. static bool autofile_check(); // Check for the next auto-start file and run it. - static inline void autofile_cancel() { autofile_index = 0; } + static void autofile_cancel() { autofile_index = 0; } #endif // Basic file ops @@ -138,7 +141,7 @@ class CardReader { static bool fileExists(const char * const name); static void removeFile(const char * const name); - static inline char* longest_filename() { return longFilename[0] ? longFilename : filename; } + static char* longest_filename() { return longFilename[0] ? longFilename : filename; } #if ENABLED(LONG_FILENAME_HOST_SUPPORT) static void printLongPath(char * const path); // Used by M33 #endif @@ -163,18 +166,18 @@ class CardReader { static void endFilePrintNow(TERN_(SD_RESORT, const bool re_sort=false)); static void abortFilePrintNow(TERN_(SD_RESORT, const bool re_sort=false)); static void fileHasFinished(); - static inline void abortFilePrintSoon() { flag.abort_sd_printing = true; } - static inline void pauseSDPrint() { flag.sdprinting = false; } - static inline bool isPrinting() { return flag.sdprinting; } - static inline bool isPaused() { return isFileOpen() && !isPrinting(); } + static void abortFilePrintSoon() { flag.abort_sd_printing = isFileOpen(); } + static void pauseSDPrint() { flag.sdprinting = false; } + static bool isPrinting() { return flag.sdprinting; } + static bool isPaused() { return isFileOpen() && !isPrinting(); } #if HAS_PRINT_PROGRESS_PERMYRIAD - static inline uint16_t permyriadDone() { + static uint16_t permyriadDone() { if (flag.sdprintdone) return 10000; if (isFileOpen() && filesize) return sdpos / ((filesize + 9999) / 10000); return 0; } #endif - static inline uint8_t percentDone() { + static uint8_t percentDone() { if (flag.sdprintdone) return 100; if (isFileOpen() && filesize) return sdpos / ((filesize + 99) / 100); return 0; @@ -204,7 +207,13 @@ class CardReader { FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); } #endif - static void ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames=false)); + static void ls( + TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) + #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) + , + #endif + TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) + ); #if ENABLED(POWER_LOSS_RECOVERY) static bool jobRecoverFileExists(); @@ -212,21 +221,25 @@ class CardReader { static void removeJobRecoveryFile(); #endif + // Binary flag for the current file + static bool fileIsBinary() { return TERN0(DO_LIST_BIN_FILES, flag.filenameIsBin); } + static void setBinFlag(const bool bin) { TERN(DO_LIST_BIN_FILES, flag.filenameIsBin = bin, UNUSED(bin)); } + // Current Working Dir - Set by cd, cdup, cdroot, and diveToFile(true, ...) - static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; } - static inline SdFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } + static char* getWorkDirName() { workDir.getDosName(filename); return filename; } + static SdFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } // Print File stats - static inline uint32_t getFileSize() { return filesize; } - static inline uint32_t getIndex() { return sdpos; } - static inline bool isFileOpen() { return isMounted() && file.isOpen(); } - static inline bool eof() { return getIndex() >= getFileSize(); } + static uint32_t getFileSize() { return filesize; } + static uint32_t getIndex() { return sdpos; } + static bool isFileOpen() { return isMounted() && file.isOpen(); } + static bool eof() { return getIndex() >= getFileSize(); } // File data operations - static inline int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; } - static inline int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } - static inline int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } - static inline void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); } + static int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; } + static int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } + static int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } + static void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); } // TODO: rename to diskIODriver() static DiskIODriver* diskIODriver() { return driver; } @@ -331,14 +344,14 @@ class CardReader { // // Directory items // - static bool is_dir_or_gcode(const dir_t &p); + static bool is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false)); static int countItems(SdFile dir); static void selectByIndex(SdFile dir, const uint8_t index); static void selectByName(SdFile dir, const char * const match); static void printListing( - SdFile parent + SdFile parent, const char * const prepend + OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) - , const char * const prepend=nullptr OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr) ); diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp index a1a3b7d50ead..9ff9cd77bc8b 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp @@ -47,7 +47,7 @@ void MAX3421e::regWr(uint8_t reg, uint8_t data) { spiSend(reg | 0x02); spiSend(data); ncs(); -}; +} // multiple-byte write // return a pointer to memory position after last written diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 9a58ba9cfcd2..77e53ff9ace4 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -150,7 +150,7 @@ if ((AUTO_BUILD)); then *) SYS='uni' ;; esac echo ; echo -n "Auto " ; ((AUTO_BUILD == 2)) && echo "Upload..." || echo "Build..." - MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//' ) + MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//;s/\r//' ) [[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; } BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h ) BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" ) diff --git a/buildroot/bin/restore_configs b/buildroot/bin/restore_configs index b2d0ea19ac8c..61aa3f9ee18e 100755 --- a/buildroot/bin/restore_configs +++ b/buildroot/bin/restore_configs @@ -2,4 +2,4 @@ git checkout Marlin/Configuration*.h 2>/dev/null git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null -rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h +rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h marlin_config.json .pio/build/mc.zip diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json b/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json new file mode 100644 index 000000000000..faf32c200e47 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json @@ -0,0 +1,56 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F407xx -DSTM32F4", + "f_cpu": "168000000L", + "hwids": [ + [ + "0x1EAF", + "0x0003" + ], + [ + "0x0483", + "0x3748" + ] + ], + "mcu": "stm32f407vet6", + "product_line": "STM32F407xx", + "variant": "Generic_F4x7Vx" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32F407VE", + "openocd_extra_args": [ + "-c", + "reset_config none" + ], + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "stm32cube", + "libopencm3" + ], + "name": "STM32F407VE (128k RAM, 64k CCM RAM, 512k Flash", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32-high-performance-mcus/stm32f4-series/stm32f407-417/stm32f407vg.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F429VGT6.json b/buildroot/share/PlatformIO/boards/marlin_STM32F429VGT6.json new file mode 100644 index 000000000000..3ad2d9d99fcb --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F429VGT6.json @@ -0,0 +1,50 @@ +{ + "build": { + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F4 -DSTM32F429xx", + "f_cpu": "168000000L", + "mcu": "stm32f429vgt6", + "product_line": "STM32F429xx", + "variant": "MARLIN_F4x7Vx" + }, + "connectivity": [ + "can" + ], + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32F429VG", + "onboard_tools": [ + "stlink" + ], + "openocd_board": "stm32f429", + "openocd_target": "stm32f4x", + "svd_path": "STM32F429x.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "mbed", + "stm32cube", + "libopencm3", + "zephyr" + ], + "name": "STM32F429VG (128k RAM, 64k CCM RAM, 1024k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 1048576, + "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/microcontrollers-microprocessors/stm32f429-439.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json b/buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json new file mode 100644 index 000000000000..28c3451b4cdb --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m0plus", + "extra_flags": "-DSTM32G0xx -DSTM32G0B1xx", + "f_cpu": "64000000L", + "framework_extra_flags": { + "arduino": "-D__CORTEX_SC=0" + }, + "mcu": "stm32g0b1ret6", + "product_line": "STM32G0B1xx", + "variant": "MARLIN_G0B1RE" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32G0B1RE", + "onboard_tools": [ + "stlink" + ], + "openocd_target": "stm32g0x", + "svd_path": "STM32G0B1.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "libopencm3", + "stm32cube", + "zephyr" + ], + "name": "STM32G0B1RE", + "upload": { + "maximum_ram_size": 147456, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "jlink", + "cmsis-dap", + "blackmagic", + "mbed" + ] + }, + "url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32g0-series/stm32g0x1.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json b/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json index c65f1dd70356..ef5ebfa56066 100644 --- a/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json +++ b/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json @@ -5,6 +5,10 @@ "extra_flags": "-DSTM32F407xx", "f_cpu": "168000000L", "hwids": [ + [ + "0x0483", + "0xdf11" + ], [ "0x1EAF", "0x0003" @@ -12,10 +16,6 @@ [ "0x0483", "0x3748" - ], - [ - "0x0483", - "0xdf11" ] ], "mcu": "stm32f407vet6", @@ -35,7 +35,7 @@ "disable_flushing": false, "maximum_ram_size": 131072, "maximum_size": 524288, - "protocol": "stlink", + "protocol": "dfu", "protocols": [ "stlink", "dfu", diff --git a/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py b/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py index be2c87266acc..e7442f2485b8 100644 --- a/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py +++ b/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py @@ -6,7 +6,6 @@ if pioutil.is_pio_build(): from os.path import join, isfile import shutil - from pprint import pprint Import("env") diff --git a/buildroot/share/PlatformIO/scripts/__init__.py b/buildroot/share/PlatformIO/scripts/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index a88e7084670b..f004c54adb85 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -53,7 +53,7 @@ #define HAS_SMART_EFF_MOD #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #if ENABLED(BACKLASH_GCODE) #define HAS_MENU_BACKLASH #endif diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index 004f78f19b62..24e780d9b670 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -192,63 +192,6 @@ def apply_features_config(): 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 # @@ -257,25 +200,8 @@ def load_marlin_features(): 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() + from preprocessor import run_preprocessor + define_list = run_preprocessor(env) marlin_features = {} for define in define_list: feature = define[8:].strip().decode().split(' ') @@ -310,9 +236,18 @@ def MarlinFeatureIsEnabled(env, feature): except: pass + # # 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() + + #print(env.Dump()) + + from signature import compute_build_signature + compute_build_signature(env) diff --git a/buildroot/share/PlatformIO/scripts/generic_create_variant.py b/buildroot/share/PlatformIO/scripts/generic_create_variant.py index 52473c752ac6..d572873ad764 100644 --- a/buildroot/share/PlatformIO/scripts/generic_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -30,7 +30,7 @@ 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" ]: + 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", "biqu-bx-workaround", "main" ]: platform_name = "framework-arduinoststm32" FRAMEWORK_DIR = platform.get_package_dir(platform_name) diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index b8a6283cedf1..8ac36b7d59b5 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -48,6 +48,10 @@ def encrypt_mks(source, target, env, new_name): key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] + # If FIRMWARE_BIN is defined by config, override all + mf = env["MARLIN_FEATURES"] + if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] + fwpath = target[0].path fwfile = open(fwpath, "rb") enfile = open(target[0].dir.path + "/" + new_name, "wb") diff --git a/buildroot/share/PlatformIO/scripts/mc-apply.py b/buildroot/share/PlatformIO/scripts/mc-apply.py new file mode 100755 index 000000000000..f71d192679d3 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/mc-apply.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# Create a Configuration from marlin_config.json +# +import json +import sys +import shutil +import re + +opt_output = '--opt' in sys.argv +output_suffix = '.sh' if opt_output else '' if '--bare-output' in sys.argv else '.gen' + +try: + with open('marlin_config.json', 'r') as infile: + conf = json.load(infile) + for key in conf: + # We don't care about the hash when restoring here + if key == '__INITIAL_HASH': + continue + if key == 'VERSION': + for k, v in sorted(conf[key].items()): + print(k + ': ' + v) + continue + # The key is the file name, so let's build it now + outfile = open('Marlin/' + key + output_suffix, 'w') + for k, v in sorted(conf[key].items()): + # Make define line now + if opt_output: + if v != '': + if '"' in v: + v = "'%s'" % v + elif ' ' in v: + v = '"%s"' % v + define = 'opt_set ' + k + ' ' + v + '\n' + else: + define = 'opt_enable ' + k + '\n' + else: + define = '#define ' + k + ' ' + v + '\n' + outfile.write(define) + outfile.close() + + # Try to apply changes to the actual configuration file (in order to keep useful comments) + if output_suffix != '': + # Move the existing configuration so it doesn't interfere + shutil.move('Marlin/' + key, 'Marlin/' + key + '.orig') + infile_lines = open('Marlin/' + key + '.orig', 'r').read().split('\n') + outfile = open('Marlin/' + key, 'w') + for line in infile_lines: + sline = line.strip(" \t\n\r") + if sline[:7] == "#define": + # Extract the key here (we don't care about the value) + kv = sline[8:].strip().split(' ') + if kv[0] in conf[key]: + outfile.write('#define ' + kv[0] + ' ' + conf[key][kv[0]] + '\n') + # Remove the key from the dict, so we can still write all missing keys at the end of the file + del conf[key][kv[0]] + else: + outfile.write(line + '\n') + else: + outfile.write(line + '\n') + # Process any remaining defines here + for k, v in sorted(conf[key].items()): + define = '#define ' + k + ' ' + v + '\n' + outfile.write(define) + outfile.close() + + print('Output configuration written to: ' + 'Marlin/' + key + output_suffix) +except: + print('No marlin_config.json found.') diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 00803b722eff..581a06e91e7f 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -57,7 +57,6 @@ def encrypt(source, target, env): 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) + os.rename(target[0].path, firmware) marlin.add_post_action(rename_target) diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 1837a7580d24..9f38ffe8bfa2 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -81,10 +81,19 @@ def sanity_check_target(): # # Give warnings on every build # - warnfile = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src", "inc", "Warnings.cpp.o") + srcpath = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src") + warnfile = os.path.join(srcpath, "inc", "Warnings.cpp.o") if os.path.exists(warnfile): os.remove(warnfile) + # + # Rebuild 'settings.cpp' for EEPROM_INIT_NOW + # + if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']: + setfile = os.path.join(srcpath, "module", "settings.cpp.o") + if os.path.exists(setfile): + os.remove(setfile) + # # Check for old files indicating an entangled Marlin (mixing old and new code) # diff --git a/buildroot/share/PlatformIO/scripts/preprocessor.py b/buildroot/share/PlatformIO/scripts/preprocessor.py new file mode 100644 index 000000000000..6f4ed900cab1 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/preprocessor.py @@ -0,0 +1,99 @@ +# +# preprocessor.py +# +import subprocess,os,re + +verbose = 0 + +def blab(str): + if verbose: + print(str) + +################################################################################ +# +# Invoke GCC to run the preprocessor and extract enabled features +# +preprocessor_cache = {} +def run_preprocessor(env, fn=None): + filename = fn or 'buildroot/share/PlatformIO/scripts/common-dependencies.h' + if filename in preprocessor_cache: + return preprocessor_cache[filename] + + # Process defines + build_flags = env.get('BUILD_FLAGS') + build_flags = env.ParseFlagsExtended(build_flags) + + cxx = search_compiler(env) + 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++'] + depcmd = cmd + [ filename ] + cmd = ' '.join(depcmd) + blab(cmd) + define_list = subprocess.check_output(cmd, shell=True).splitlines() + preprocessor_cache[filename] = define_list + return define_list + + +################################################################################ +# +# Find a compiler, considering the OS +# +def search_compiler(env): + + ENV_BUILD_PATH = os.path.join(env.Dictionary('PROJECT_BUILD_DIR'), env['PIOENV']) + GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path") + + try: + filepath = env.GetProjectOption('custom_gcc') + blab("Getting compiler from env") + return filepath + except: + pass + + if os.path.exists(GCC_PATH_CACHE): + blab("Getting g++ path from 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']) + 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): + blab("Caching g++ for current env") + with open(GCC_PATH_CACHE, 'w+') as f: + f.write(filepath) + + return filepath + + filepath = env.get('CXX') + blab("Couldn't find a compiler! Fallback to %s" % filepath) + return filepath diff --git a/buildroot/share/PlatformIO/scripts/signature.py b/buildroot/share/PlatformIO/scripts/signature.py new file mode 100644 index 000000000000..593f9580b330 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/signature.py @@ -0,0 +1,178 @@ +# +# signature.py +# +import os,subprocess,re,json,hashlib + +# +# The dumbest preprocessor in the world +# Extract macro name from an header file and store them in an array +# No processing is done here, so they are raw values here and it does not match what actually enabled +# in the file (since you can have #if SOMETHING_UNDEFINED / #define BOB / #endif) +# But it's useful to filter the useful macro spit out by the preprocessor from noise from the system +# headers. +# +def extract_defines(filepath): + f = open(filepath, encoding="utf8").read().split("\n") + a = [] + for line in f: + sline = line.strip(" \t\n\r") + if sline[:7] == "#define": + # Extract the key here (we don't care about the value) + kv = sline[8:].strip().split(' ') + a.append(kv[0]) + return a + +# Compute the SHA256 hash of a file +def get_file_sha256sum(filepath): + sha256_hash = hashlib.sha256() + with open(filepath,"rb") as f: + # Read and update hash string value in blocks of 4K + for byte_block in iter(lambda: f.read(4096),b""): + sha256_hash.update(byte_block) + return sha256_hash.hexdigest() + +# +# Compress a JSON file into a zip file +# +import zipfile +def compress_file(filepath, outputbase): + with zipfile.ZipFile(outputbase + '.zip', 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: + zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9) + +# +# Compute the build signature. The idea is to extract all defines in the configuration headers +# to build a unique reversible signature from this build so it can be included in the binary +# We can reverse the signature to get a 1:1 equivalent configuration file +# +def compute_build_signature(env): + if 'BUILD_SIGNATURE' in env: + return + + # Definitions from these files will be kept + files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ] + + build_dir=os.path.join(env['PROJECT_BUILD_DIR'], env['PIOENV']) + + # Check if we can skip processing + hashes = '' + for header in files_to_keep: + hashes += get_file_sha256sum(header)[0:10] + + marlin_json = os.path.join(build_dir, 'marlin_config.json') + marlin_zip = os.path.join(build_dir, 'mc') + + # Read existing config file + try: + with open(marlin_json, 'r') as infile: + conf = json.load(infile) + if conf['__INITIAL_HASH'] == hashes: + # Same configuration, skip recomputing the building signature + compress_file(marlin_json, marlin_zip) + return + except: + pass + + # Get enabled config options based on preprocessor + from preprocessor import run_preprocessor + complete_cfg = run_preprocessor(env) + + # Dumb #define extraction from the configuration files + real_defines = {} + all_defines = [] + for header in files_to_keep: + defines = extract_defines(header) + # To filter only the define we want + all_defines = all_defines + defines + # To remember from which file it cames from + real_defines[header.split('/')[-1]] = defines + + r = re.compile(r"\(+(\s*-*\s*_.*)\)+") + + # First step is to collect all valid macros + defines = {} + for line in complete_cfg: + + # Split the define from the value + key_val = line[8:].strip().decode().split(' ') + key, value = key_val[0], ' '.join(key_val[1:]) + + # Ignore values starting with two underscore, since it's low level + if len(key) > 2 and key[0:2] == "__" : + continue + # Ignore values containing a parenthesis (likely a function macro) + if '(' in key and ')' in key: + continue + + # Then filter dumb values + if r.match(value): + continue + + defines[key] = value if len(value) else "" + + if not 'CONFIGURATION_EMBEDDING' in defines: + return + + # Second step is to filter useless macro + resolved_defines = {} + for key in defines: + # Remove all boards now + if key[0:6] == "BOARD_" and key != "BOARD_INFO_NAME": + continue + # Remove all keys ending by "_NAME" as it does not make a difference to the configuration + if key[-5:] == "_NAME" and key != "CUSTOM_MACHINE_NAME": + continue + # Remove all keys ending by "_T_DECLARED" as it's a copy of not important system stuff + if key[-11:] == "_T_DECLARED": + continue + # Remove keys that are not in the #define list in the Configuration list + if not (key in all_defines) and key != "DETAILED_BUILD_VERSION" and key != "STRING_DISTRIBUTION_DATE": + continue + + # Don't be that smart guy here + resolved_defines[key] = defines[key] + + # Generate a build signature now + # We are making an object that's a bit more complex than a basic dictionary here + data = {} + data['__INITIAL_HASH'] = hashes + # First create a key for each header here + for header in real_defines: + data[header] = {} + + # Then populate the object where each key is going to (that's a O(N^2) algorithm here...) + for key in resolved_defines: + for header in real_defines: + if key in real_defines[header]: + data[header][key] = resolved_defines[key] + + # Append the source code version and date + data['VERSION'] = {} + data['VERSION']['DETAILED_BUILD_VERSION'] = resolved_defines['DETAILED_BUILD_VERSION'] + data['VERSION']['STRING_DISTRIBUTION_DATE'] = resolved_defines['STRING_DISTRIBUTION_DATE'] + try: + curver = subprocess.check_output(["git", "describe", "--match=NeVeRmAtCh", "--always"]).strip() + data['VERSION']['GIT_REF'] = curver.decode() + except: + pass + + with open(marlin_json, 'w') as outfile: + json.dump(data, outfile, separators=(',', ':')) + + # Compress the JSON file as much as we can + compress_file(marlin_json, marlin_zip) + + # Generate a C source file for storing this array + with open('Marlin/src/mczip.h','wb') as result_file: + result_file.write(b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n') + result_file.write(b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n') + result_file.write(b'#endif\n') + result_file.write(b'const unsigned char mc_zip[] PROGMEM = {\n ') + count = 0 + for b in open(os.path.join(build_dir, 'mc.zip'), 'rb').read(): + result_file.write(b' 0x%02X,' % b) + count += 1 + if (count % 16 == 0): + result_file.write(b'\n ') + if (count % 16): + result_file.write(b'\n') + result_file.write(b'};\n') diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S new file mode 100644 index 000000000000..81999dda6a42 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S @@ -0,0 +1,124 @@ + /** + ****************************************************************************** + * @file startup_stm32f401xc.s + * @author MCD Application Team + * @version V2.4.2 + * @date 13-November-2015 + * @brief STM32F401xCxx Devices vector table for GCC based toolchains. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2015 STMicroelectronics

+ * + * 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 STMicroelectronics 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. + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None + */ + + .section .text.Reset_Handler + .globl Reset_Handler + .type Reset_Handler, %function +Reset_Handler: +/* Check for magic code at the end of SRAM to detemine whether to jump to DFU */ + ldr r0, =0x2000FFF0 // End of SRAM for your CPU + ldr r1, =0xDEADBEEF + ldr r2, [r0, #0] + str r0, [r0, #0] // Invalidate + cmp r2, r1 + beq Jump_To_DFU + +/* Original Reset_Handler code */ + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr + +Jump_To_DFU: + ldr r0, =0x40023844 // RCC_APB2ENR + ldr r1, =0x00004000 // ENABLE SYSCFG CLOCK + str r1, [r0, #0] + ldr r0, =0x40013800 // SYSCFG_MEMRMP + ldr r1, =0x00000001 // MAP ROM AT ZERO + str r1, [r0, #0] + ldr r0, =0x1FFF0000 // ROM BASE + ldr sp, [r0, #0] // SP @ +0 + ldr r0, [r0, #4] // PC @ +4 + bx r0 +.size Reset_Handler, .-Reset_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h index 0c66ae89b88a..ca7a53d7827b 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h @@ -107,8 +107,8 @@ extern "C" { // TIM9 - STEP_TIMER // TIM10 - TEMP_TIMER // TIM11 - -#define TIMER_SERVO TIM2 -#define TIMER_TONE TIM5 +#define TIMER_SERVO TIM2 // TIMER_SERVO must be defined in this file +#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file // UART Definitions #define SERIAL_UART_INSTANCE 1 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h index 56574501002d..068d0b9ee587 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h @@ -245,9 +245,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM7 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM2 +#define TIMER_TONE TIM7 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM2 // TIMER_SERIAL must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h index 646d635679f6..edc1c91c5374 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h @@ -245,9 +245,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM7 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM8 +#define TIMER_TONE TIM7 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM8 // TIMER_SERIAL must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h index 41e46411022c..2c70693991ed 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h @@ -255,9 +255,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM10 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#define TIMER_TONE TIM10 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file // UART Definitions //#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/variant.h index 0147ece0ab20..1870e779297a 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/variant.h @@ -165,9 +165,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pin. See PinMap_PWM. -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file // UART Definitions //#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h index f512a311e32c..424538b3950f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h @@ -165,9 +165,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pin. See PinMap_PWM. -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file // UART Definitions //#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h index 11ebf561f36c..b5cf0bad9d50 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h @@ -255,9 +255,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM2 -#define TIMER_SERVO TIM5 // Only 1 Servo PIN on SKR-PRO, so use the same timer as defined in PeripheralPins -#define TIMER_SERIAL TIM7 +#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // Only 1 Servo PIN on SKR-PRO, so use the same timer as defined in PeripheralPins +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file // UART Definitions //#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h index 74f29514a885..285ad662e0fe 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h @@ -157,9 +157,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM2 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file // UART1 for TFT port #define ENABLE_HWSERIAL1 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h index 41b194abe031..8f17d052bba9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h @@ -105,14 +105,14 @@ extern "C" { // SPI Definitions #if DEFAULT_SPI == 3 #define PIN_SPI_SS PA15 - #define PIN_SPI_MOSI PB3 + #define PIN_SPI_MOSI PB5 #define PIN_SPI_MISO PB4 - #define PIN_SPI_SCK PB5 + #define PIN_SPI_SCK PB3 #elif DEFAULT_SPI == 2 #define PIN_SPI_SS PB12 - #define PIN_SPI_MOSI PB13 + #define PIN_SPI_MOSI PB15 #define PIN_SPI_MISO PB14 - #define PIN_SPI_SCK PB15 + #define PIN_SPI_SCK PB13 #else #define PIN_SPI_SS PA4 #define PIN_SPI_MOSI PA7 @@ -126,10 +126,10 @@ extern "C" { // Timer Definitions #ifndef TIMER_TONE - #define TIMER_TONE TIM3 + #define TIMER_TONE TIM3 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO - #define TIMER_SERVO TIM2 + #define TIMER_SERVO TIM2 // TIMER_SERVO must be defined in this file #endif // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h index 3a6b7037adf0..3440343ffa1e 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h @@ -118,7 +118,7 @@ extern "C" { #endif #ifndef LSE_STARTUP_TIMEOUT - #define LSE_STARTUP_TIMEOUT 50U // No 32.7KHz LSE on this board, reduced to avoid delays + #define LSE_STARTUP_TIMEOUT 50U // No 32.7kHz LSE on this board, reduced to avoid delays #endif /* Tip: To avoid modifying this file each time you need to use different HSE, diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h index 56ae719077ce..e64272745b9d 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h @@ -121,9 +121,9 @@ extern "C" { #define TEMP_TIMER 3 // Leave TIMER 4 for TFT backlight PWM or Servo freq... #define STEP_TIMER 5 -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM7 -#define TIMER_SERIAL TIM8 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM8 // TIMER_SERIAL must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h index 496d8817a181..e01d67fd59c1 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h @@ -133,10 +133,10 @@ extern "C" { // Timer Definitions (optional) // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin #ifndef TIMER_TONE - #define TIMER_TONE TIM6 + #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO - #define TIMER_SERVO TIM7 + #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file #endif // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h index fb878f8b78f3..330a7efbf83a 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h @@ -177,8 +177,8 @@ extern "C" { // Timer Definitions (optional) // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM7 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h index 3eed1473093c..df8bf064fca1 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h @@ -299,10 +299,10 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM6 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file // Do not use basic timer: OC is required -#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +#define TIMER_SERVO TIM2 // TODO: advanced-control timers don't work // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h index f00cc5f61235..855616f66b4a 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h @@ -134,15 +134,15 @@ extern "C" { // Timer Definitions // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin #ifndef TIMER_TONE -#define TIMER_TONE TIM6 + #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO -#define TIMER_SERVO TIM7 + #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file #endif #ifndef TIMER_SERIAL -#define TIMER_SERIAL TIM9 + #define TIMER_SERIAL TIM9 // TIMER_SERIAL must be defined in this file #endif // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h index 94fa79c065d8..ba145d058cb3 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h @@ -153,13 +153,13 @@ extern "C" { // Timer Definitions // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin #ifndef TIMER_TONE - #define TIMER_TONE TIM6 + #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO - #define TIMER_SERVO TIM7 + #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file #endif #ifndef TIMER_SERIAL - #define TIMER_SERIAL TIM5 + #define TIMER_SERIAL TIM5 // TIMER_SERIAL must be defined in this file #endif // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h index fd9a5c7741b4..2bfce85e21f9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h @@ -185,10 +185,10 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM6 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file // Do not use basic timer: OC is required -#define TIMER_SERVO TIM1 //TODO: advanced-control timers don't work +#define TIMER_SERVO TIM1 // TODO: advanced-control timers don't work // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h index bcd5aa378edf..d4982113a010 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h @@ -93,17 +93,15 @@ extern "C" { #define PIN_SPI_MISO PA6 #define PIN_SPI_SCK PA5 - // Timer Definitions -#define TIMER_TONE TIM2 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM11 +#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM11 // TIMER_SERIAL must be defined in this file // UART Definitions //#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below #define ENABLE_HWSERIAL2 - // Define here Serial instance number to map on Serial generic name (if not already used by SerialUSB) #define SERIAL_UART_INSTANCE 1 //1 for Serial = Serial1 (USART1) @@ -148,4 +146,4 @@ extern "C" { #define SERIAL_PORT_HARDWARE_OPEN Serial2 #endif -#endif /* _VARIANT_ARDUINO_STM32_ */ \ No newline at end of file +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c index ec28776ebe66..f63000e88a52 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c @@ -60,9 +60,9 @@ const PinMap PinMap_ADC[] = { //{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 - //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 //{PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 - //{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 //{PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 //{PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h index 4bd5b63dfe56..4f77dc688f35 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h @@ -133,9 +133,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pin. See PinMap_PWM. -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file // UART Definitions //#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c new file mode 100644 index 000000000000..0abfc70700d8 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c @@ -0,0 +1,428 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, 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 STM32G0B1R(B-C-E)IxN.xml, STM32G0B1R(B-C-E)TxN.xml + * STM32G0C1R(C-E)IxN.xml, STM32G0C1R(C-E)TxN.xml + * CubeMX DB release 6.0.30 + */ +#if !defined(CUSTOM_PERIPHERAL_PINS) +#include "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Notes: + * - The pins mentioned Px_y_ALTz are alternative possibilities which use other + * HW peripheral instances. You can use them the same way as any other "normal" + * pin (i.e. analogWrite(PA7_ALT1, 128);). + * + * - 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 + {PB_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PB_10, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PB_11, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + {PB_12, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, // ADC1_IN17 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC1_IN18 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +WEAK const PinMap PinMap_DAC[] = { + {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC1_OUT1 + {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PA_6, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_6_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PA_10, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_10_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_10_R, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_10_R_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_4, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PB_4_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_14, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PC_1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_7, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_7_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PA_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_9_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_9_R, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_9_R_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PB_3_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_13, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PC_0, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {NC, NP, 0} +}; +#endif + +//*** TIM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_TIM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 1)}, // TIM15_CH1N + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 0)}, // TIM15_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 2, 0)}, // TIM15_CH2 + {PA_4, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PA_6_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM16, 1, 0)}, // TIM16_CH1 + {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PA_7_ALT2, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_7_ALT3, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM17, 1, 0)}, // TIM17_CH1 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_9_R, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_10_R, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1_ALT2, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM14, 1, 0)}, // TIM14_CH1 + {PB_3, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PB_3_ALT1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PB_6_ALT1, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 1, 0)}, // TIM4_CH1 + {PB_6_ALT2, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 1)}, // TIM16_CH1N + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 2, 0)}, // TIM4_CH2 + {PB_7_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 1)}, // TIM17_CH1N + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 0)}, // TIM16_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 0)}, // TIM17_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PB_13_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 1)}, // TIM15_CH1N + {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_14_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 0)}, // TIM15_CH1 + {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_15_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {PB_15_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 2, 0)}, // TIM15_CH2 + {PC_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 1, 0)}, // TIM15_CH1 + {PC_2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 2, 0)}, // TIM15_CH2 + {PC_4, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PC_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PC_6, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PC_6_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PC_7, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PC_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PC_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 0)}, // TIM1_CH1 + {PC_8_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 3, 0)}, // TIM3_CH3 + {PC_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PC_9_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 4, 0)}, // TIM3_CH4 + {PC_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PC_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 4, 0)}, // TIM1_CH4 + {PC_12, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM14, 1, 0)}, // TIM14_CH1 + {PD_0, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 0)}, // TIM16_CH1 + {PD_1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 0)}, // TIM17_CH1 + {PD_2, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PD_3, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PD_4, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PF_0, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM14, 1, 0)}, // TIM14_CH1 + {PF_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 1, 1)}, // TIM15_CH1N + {NC, NP, 0} +}; +#endif + +//*** UART *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_0, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PA_2, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_2_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_4, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_9_R, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_14, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PA_14_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PB_0, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PB_6, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_6_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {PB_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_8_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PC_0, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PC_0_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART6)}, + {PC_1, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PC_4, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PC_4_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PC_6, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PC_10_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART4)}, + {PC_12, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PD_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PA_3, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_3_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_5, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_10_R, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_13, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PB_0, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_1, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_4, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PB_7, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_7_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {PB_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_9_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PC_0, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PC_1, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PC_1_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART6)}, + {PC_5, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PC_5_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PC_7, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PC_11_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART4)}, + {PD_2, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {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_AF1_USART2)}, + {PA_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_15, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_USART3)}, + {PA_15_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PB_1, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PB_1_ALT1, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_1_ALT2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_3, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PB_5, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_12, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_14_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PC_9, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PD_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PD_4_ALT1, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {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_AF1_USART2)}, + {PA_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_6_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PA_6_ALT2, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PB_0, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_4, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PB_6, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_7, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PB_13, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_13_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PC_8, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PD_5, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_2, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_10_R, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_5_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI3)}, + {PD_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PD_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PA_9_R, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PA_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_6, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI3)}, + {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PD_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_0, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_1, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {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_AF0_SPI2)}, + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI3)}, + {PD_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {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_AF0_SPI1)}, + {PA_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PA_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_15_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_0, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {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_AF0_SPI2)}, + {PD_0, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** FDCAN *** + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + {PA_11, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_0, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_5, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_8, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_12, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PC_2, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PC_4, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PD_0, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_TD[] = { + {PA_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_1, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_6, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_9, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_13, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PC_3, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PC_5, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PD_1, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {NC, NP, 0} +}; +#endif + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) +WEAK const PinMap PinMap_USB_DRD_FS[] = { + // {PA_4, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + {PA_11, USB_DRD_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DM + {PA_12, USB_DRD_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DP + // {PA_13, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + // {PA_15, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USB)}, // USB_NOE + // {PC_9, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USB)}, // USB_NOE + {NC, NP, 0} +}; +#endif + +//*** No SD *** + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PinNamesVar.h new file mode 100644 index 000000000000..9fc0b87c9015 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PinNamesVar.h @@ -0,0 +1,90 @@ +/* Remap pin name */ +PA_9_R = PA_9 | PREMAP, +PA_10_R = PA_10 | PREMAP, + +/* Alternate pin name */ +PA_1_ALT1 = PA_1 | ALT1, +PA_2_ALT1 = PA_2 | ALT1, +PA_3_ALT1 = PA_3 | ALT1, +PA_4_ALT1 = PA_4 | ALT1, +PA_6_ALT1 = PA_6 | ALT1, +PA_6_ALT2 = PA_6 | ALT2, +PA_7_ALT1 = PA_7 | ALT1, +PA_7_ALT2 = PA_7 | ALT2, +PA_7_ALT3 = PA_7 | ALT3, +PA_9_ALT1 = PA_9 | ALT1, +PA_9_R_ALT1 = PA_9_R | ALT1, +PA_10_ALT1 = PA_10 | ALT1, +PA_10_R_ALT1 = PA_10_R | ALT1, +PA_14_ALT1 = PA_14 | ALT1, +PA_15_ALT1 = PA_15 | ALT1, +PB_0_ALT1 = PB_0 | ALT1, +PB_1_ALT1 = PB_1 | ALT1, +PB_1_ALT2 = PB_1 | ALT2, +PB_3_ALT1 = PB_3 | ALT1, +PB_4_ALT1 = PB_4 | ALT1, +PB_5_ALT1 = PB_5 | ALT1, +PB_6_ALT1 = PB_6 | ALT1, +PB_6_ALT2 = PB_6 | ALT2, +PB_7_ALT1 = PB_7 | ALT1, +PB_8_ALT1 = PB_8 | ALT1, +PB_9_ALT1 = PB_9 | ALT1, +PB_13_ALT1 = PB_13 | ALT1, +PB_14_ALT1 = PB_14 | ALT1, +PB_15_ALT1 = PB_15 | ALT1, +PB_15_ALT2 = PB_15 | ALT2, +PC_0_ALT1 = PC_0 | ALT1, +PC_1_ALT1 = PC_1 | ALT1, +PC_4_ALT1 = PC_4 | ALT1, +PC_5_ALT1 = PC_5 | ALT1, +PC_6_ALT1 = PC_6 | ALT1, +PC_7_ALT1 = PC_7 | ALT1, +PC_8_ALT1 = PC_8 | ALT1, +PC_9_ALT1 = PC_9 | ALT1, +PC_10_ALT1 = PC_10 | ALT1, +PC_11_ALT1 = PC_11 | ALT1, +PD_4_ALT1 = PD_4 | ALT1, + +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = PC_13, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = PA_2, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = PC_5, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = PB_5, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif + +/* USB */ +#ifdef USBCON + USB_DM = PA_11, + USB_DP = PA_12, + #ifdef USB_NOE_PA_4 + USB_NOE = PA_4, + #endif + #ifdef USB_NOE_PA_13 + USB_NOE = PA_13, + #endif + #ifdef USB_NOE_PA_15 + USB_NOE = PA_15, + #endif + #ifdef USB_NOE_PC_9 + USB_NOE = PC_9, + #endif +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld new file mode 100644 index 000000000000..3b619b6a97e8 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld @@ -0,0 +1,177 @@ +/** + ****************************************************************************** + * @file LinkerScript.ld + * @author Auto-generated by STM32CubeIDE + * @brief Linker script for STM32G0B1RETx Device from STM32G0 series + * 512Kbytes FLASH + * 144Kbytes RAM + * + * Set heap size, stack size and stack location according + * to application requirements. + * + * Set memory bank area and size if external memory is used + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 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 + * + ****************************************************************************** + */ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ + +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Sections */ +SECTIONS +{ + /* The startup code into "FLASH" Rom type memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data into "FLASH" Rom type memory */ + .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 into "FLASH" Rom type memory */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM : { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into "RAM" Ram type memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + + } >RAM AT> FLASH + + /* Uninitialized data section into "RAM" Ram type memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _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" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp new file mode 100644 index 000000000000..8af7150dc781 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp @@ -0,0 +1,186 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, 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 + * + ******************************************************************************* + */ + +#if defined(STM32G0B1xx) +#include "pins_arduino.h" + +// Digital PinName array +const PinName digitalPin[] = { + PA_0, // D0/A0 + PA_1, // D1/A1 + PA_2, // D2/A2 + PA_3, // D3/A3 + PA_4, // D4/A4 + PA_5, // D5/A5 + PA_6, // D6/A6 + PA_7, // D7/A7 + 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/A8 + PB_1, // D17/A9 + PB_2, // D18/A10 + PB_3, // D19 + PB_4, // D20 + PB_5, // D21 + PB_6, // D22 + PB_7, // D23 + PB_8, // D24 + PB_9, // D25 + PB_10, // D26/A11 + PB_11, // D27/A12 + PB_12, // D28/A13 + PB_13, // D29 + PB_14, // D30 + PB_15, // D31 + PC_0, // D32 + PC_1, // D33 + PC_2, // D34 + PC_3, // D35 + PC_4, // D36/A14 + PC_5, // D37/A15 + PC_6, // D38 + PC_7, // D39 + PC_8, // D40 + PC_9, // D41 + PC_10, // D42 + PC_11, // D43 + PC_12, // D44 + PC_13, // D45 + PC_14, // D46 + PC_15, // D47 + PD_0, // D48 + PD_1, // D49 + PD_2, // D50 + PD_3, // D51 + PD_4, // D52 + PD_5, // D53 + PD_6, // D54 + PD_8, // D55 + PD_9, // D56 + PF_0, // D57 + PF_1, // D58 + PF_2, // D59 + PA_9_R, // D60 + PA_10_R // D61 +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 0, // A0, PA0 + 1, // A1, PA1 + 2, // A2, PA2 + 3, // A3, PA3 + 4, // A4, PA4 + 5, // A5, PA5 + 6, // A6, PA6 + 7, // A7, PA7 + 16, // A8, PB0 + 17, // A9, PB1 + 18, // A10, PB2 + 26, // A11, PB10 + 27, // A12, PB11 + 28, // A13, PB12 + 36, // A14, PC4 + 37 // A15, PC5 +}; + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * The system Clock is configured as follows : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 64000000 + * HCLK(Hz) = 64000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 1 + * PLL_M = 1 + * PLL_N = 24 + * PLL_R = 3 + * PLL_P = 2 + * PLL_Q = 4 + * USB(Hz) = 48000000 (PLLQ) + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; + + // Reset clock registers (in case bootloader has changed them) + RCC->CR |= RCC_CR_HSION; + while (!(RCC->CR & RCC_CR_HSIRDY)) + ; + RCC->CFGR = 0x00000000; + RCC->CR = RCC_CR_HSION; + while (RCC->CR & RCC_CR_PLLRDY) + ; + RCC->PLLCFGR = 0x00001000; + + /** Configure the main internal regulator output voltage + */ + HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + 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 = RCC_PLLM_DIV1; + RCC_OscInitStruct.PLL.PLLN = 24; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4; + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV3; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the peripherals clocks + */ + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) + { + Error_Handler(); + } +} + +#ifdef __cplusplus +} +#endif +#endif /* STM32G0B1xx */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h new file mode 100644 index 000000000000..9cb3d45a0d95 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h @@ -0,0 +1,199 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, 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 + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA0 PIN_A0 +#define PA1 PIN_A1 +#define PA2 PIN_A2 +#define PA3 PIN_A3 +#define PA4 PIN_A4 +#define PA5 PIN_A5 +#define PA6 PIN_A6 +#define PA7 PIN_A7 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PA11 11 +#define PA12 12 +#define PA13 13 +#define PA14 14 +#define PA15 15 +#define PB0 PIN_A8 +#define PB1 PIN_A9 +#define PB2 PIN_A10 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 PIN_A11 +#define PB11 PIN_A12 +#define PB12 PIN_A13 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC0 32 +#define PC1 33 +#define PC2 34 +#define PC3 35 +#define PC4 PIN_A14 +#define PC5 PIN_A15 +#define PC6 38 +#define PC7 39 +#define PC8 40 +#define PC9 41 +#define PC10 42 +#define PC11 43 +#define PC12 44 +#define PC13 45 +#define PC14 46 +#define PC15 47 +#define PD0 48 +#define PD1 49 +#define PD2 50 +#define PD3 51 +#define PD4 52 +#define PD5 53 +#define PD6 54 +#define PD8 55 +#define PD9 56 +#define PF0 57 +#define PF1 58 +#define PF2 59 +#define PA9_R 60 +#define PA10_R 61 + +// Alternate pins number +#define PA1_ALT1 (PA1 | ALT1) +#define PA2_ALT1 (PA2 | ALT1) +#define PA3_ALT1 (PA3 | ALT1) +#define PA4_ALT1 (PA4 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA6_ALT2 (PA6 | ALT2) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA9_ALT1 (PA9 | ALT1) +#define PA9_R_ALT1 (PA9_R | ALT1) +#define PA10_ALT1 (PA10 | ALT1) +#define PA10_R_ALT1 (PA10_R | ALT1) +#define PA14_ALT1 (PA14 | ALT1) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB6_ALT1 (PB6 | ALT1) +#define PB6_ALT2 (PB6 | ALT2) +#define PB7_ALT1 (PB7 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) +#define PB13_ALT1 (PB13 | ALT1) +#define PB14_ALT1 (PB14 | ALT1) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC0_ALT1 (PC0 | ALT1) +#define PC1_ALT1 (PC1 | ALT1) +#define PC4_ALT1 (PC4 | ALT1) +#define PC5_ALT1 (PC5 | ALT1) +#define PC6_ALT1 (PC6 | ALT1) +#define PC7_ALT1 (PC7 | ALT1) +#define PC8_ALT1 (PC8 | ALT1) +#define PC9_ALT1 (PC9 | ALT1) +#define PC10_ALT1 (PC10 | ALT1) +#define PC11_ALT1 (PC11 | ALT1) +#define PD4_ALT1 (PD4 | ALT1) + +#define NUM_DIGITAL_PINS 62 +#define NUM_REMAP_PINS 2 +#define NUM_ANALOG_INPUTS 16 + +// SPI definitions +#ifndef PIN_SPI_SS + #define PIN_SPI_SS PA4 +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA7 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA5 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PB6 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB7 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 2 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA3 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA2 +#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. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + #define SERIAL_PORT_HARDWARE Serial2 + #endif +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h index d82f0006553f..e7bc7c0bc1db 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h @@ -183,7 +183,7 @@ extern "C" { // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c // FANs may require PWM timers 3 10 11 13 // The LED/RGB connectors timer 4 -// Beware: STEP_TIMER default is 6 and TEMP_TIMER 14 for the F407 +// Beware: MCU_TIMER_STEP default is 6 and MCU_TIMER_TEMP 14 for the F407 #ifndef TIMER_TONE #define TIMER_TONE TIM8 // TIM3 or TIM8 for SPEAKER compat on the lerdge K (PC6) #endif // TIM4 for that on the Lerdge S (PD11) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h index ec6e498b2179..30c3d953494f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h @@ -103,8 +103,8 @@ extern "C" { // Timer Definitions // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin -#define TIMER_TONE TIM5 -#define TIMER_SERVO TIM7 +#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM4 // TIMER_SERVO must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/dwin/bin/DWIN_ICO.py b/buildroot/share/dwin/bin/DWIN_ICO.py new file mode 100644 index 000000000000..8ac680c61e7c --- /dev/null +++ b/buildroot/share/dwin/bin/DWIN_ICO.py @@ -0,0 +1,342 @@ +# DWIN_ICO +# - Dissect and create DWIN .ico files for their LCD displays. +# +# Copyright (c) 2020 Brent Burton +# +# 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 . +#---------------------------------------------------------------- +# +# This is not a normal Microsoft .ICO file, but it has a similar +# structure for containing a number of icon images. Each icon is +# a small JPG file. +# +# The file has a directory header containing fixed-length +# records, and each record points to its data at an offset later +# in the file. +# +# The directory entries are 16 bytes each, and the entire +# directory is 4KB (0 - 0x1000). This supports 256 entries. +# +# Multibyte values are in Big Endian format. +# +# Header: (offset 0x0) +# W H offset ?? len ?? ?? +# Entry 0: xxxx xxxx 00001000 xx 10a2 00 00000000 +# Entry 1: xxxx xxxx 000020a2 xx 0eac 00 00000000 +# Entry 2: xxxx xxxx 00002f4e xx 0eaa 00 00000000 +# ... +# 0x00001000: ffd8 ffe1 0018 ... jpeg exif and data follow .. ffd9 +# 0x000020a2: ffd8 ffe1 ... +# ...rest of ICO entries' data... +# +# Header structure: +# Offset Len What +# 0 2 width +# 2 2 height +# 4 4 file byte position from SEEK_BEG +# 8 3 length of data +# 11 5 ??? all zeroes +# +# Other notes: +# * The index of each icon corresponds to the Icon number in dwin.h +# * One exception is number 39: that header entry is blank, and dwin.h +# does not define a name for 39. This is specially handled to +# prevent reordering stock icons. + +import os +import struct +from PIL import Image + +def getJpegResolution(jpegFile): + """Returns a 2-tuple containing the jpegFile's (width, height). + """ + img = Image.open(jpegFile) + return img.size + +class DWIN_ICO_File(): + def __init__(self): + self.entries = [] # list of header entries + + def splitFile(self, filename, outDir): + if not filename[-4:].lower() == '.ico': + raise RuntimeError('Input file must end in .ico') + + with open(filename, 'rb') as infile: + self._parseHeader(infile) + self._splitEntryData(infile, outDir) + + return + + def _parseHeader(self, infile): + maxEntries = 256 + count = 0 + validEntries = 0 + while count < maxEntries: + rawBytes = infile.read(16) + entry = Entry() + entry.parseRawData(rawBytes) + # check that it is valid: is offset nonzero? + # Special case: treat 39 as valid + if (entry.offset > 0) or (count == 39): + validEntries += 1 + self.entries.append(entry) + count += 1 + return + + def _splitEntryData(self, infile, outDir): + print('Splitting Entry Data...') + if 0 == len(self.entries): + raise RuntimeError('.ico file is not loaded yet') + + # check for output dir: + if not os.path.exists(outDir): + os.mkdir(outDir) + + # keep a count + count = 0 + for entry in self.entries: + # Skip any empty entries. (Special handling of 39.) + if entry.length == 0: + count += 1 + continue + # Seek file position, read length bytes, and write to new output file. + print('%02d: offset: 0x%06x len: 0x%04x width: %d height: %d' % + (count, entry.offset, entry.length, entry.width, entry.height)) + outfilename = os.path.join(outDir, + '%03d-%s.jpg' % (count, _iconNames[count])) + with open(outfilename, 'wb') as outfile: + infile.seek(entry.offset) + blob = infile.read(entry.length) + outfile.write(blob) + print('Wrote %d bytes to %s' % (entry.length, outfilename)) + + count += 1 + return + + def createFile(self, iconDir, filename): + '''Create a new .ico file from the contents of iconDir. + + The contents of iconDir are processed to get image + resolution, and a new entry is created for each. + + Each filename must have a leading number followed by a + dash, which is the icon index. E.g., "071-ICON_StepX.jpg". + ''' + self.entries = [Entry() for i in range(0,256)] + # 1. Scan icon directory and record all valid files + print('Scanning icon directory', iconDir) + count = 0 + for dirEntry in os.scandir(iconDir): + if not dirEntry.is_file(): + print('...Ignoring', dirEntry.path) + continue + # process each file: + try: + index = int(dirEntry.name[0:3]) + if (index < 0) or (index > 255): + print('...Ignoring invalid index on', dirEntry.path) + continue + #dirEntry.path is iconDir/name + w,h = getJpegResolution(dirEntry.path) + length = dirEntry.stat().st_size + e = self.entries[index] + e.width = w + e.height = h + e.length = length + e.filename = dirEntry.path + count += 1 + except Exception as e: + print('Whoops: ', e) + pass + print('...Scanned %d icon files' % (count)) + + # 2. Scan over valid header entries and update offsets + self._updateHeaderOffsets() + + # 3. Write out header to .ico file, the append each icon file + self._combineAndWriteIcoFile(filename) + print('Scanning done. %d icons included.' % (count)) + + def _updateHeaderOffsets(self): + """Iterate over all header entries and update their offsets. + """ + offset = 256 * 16 + for i in range(0,256): + e = self.entries[i] + if e.length == 0: + continue + e.offset = offset + offset += e.length + #print('%03d: (%d x %d) len=%d off=%d' % + # (i, e.width, e.height, e.length, e.offset)) + return + + def _combineAndWriteIcoFile(self, filename): + """Write out final .ico file. + All header entries are updated, so write out + the final header contents, and concat each icon + file to the .ico. + """ + with open(filename, 'wb') as outfile: + # 1. Write header directory + for e in self.entries: + outfile.write( e.serialize() ) + if outfile.tell() != 4096: + raise RuntimeError('Header directory write failed. Not 4096 bytes') + # 2. For each entry, concat the icon file data + for e in self.entries: + if 0 == e.length: continue + guts = self._getFileContents(e.filename, e.length) + outfile.write(guts) + return + + def _getFileContents(self, filename, length): + """Read contents of filename, and return bytes""" + with open(filename, 'rb') as infile: + contents = infile.read(length) + if len(contents) != length: + raise RuntimeError('Failed to read contents of', filename) + return contents + +class Entry(): + '''Entry objects record resolution and size information + about each icon stored in an ICO file. + ''' + __slots__ = ('width', 'height', 'offset', 'length', 'filename') + + def __init__(self, w=0, h=0, length=0, offset=0): + self.width = w + self.height = h + self.offset = offset + self.length = length + self.filename = None + + def parseRawData(self, rawEntryBytes): + if len(rawEntryBytes) != 16: + raise RuntimeError('Entry: data must be 16 bytes long') + + # Split data into bigendian fields + (w, h, off, len3, len21, b1,b2,b3,b4,b5) = \ + struct.unpack('>HHLBHBBBBB', rawEntryBytes) + self.width = w + self.height = h + self.offset = off + self.length = len3 * 65536 + len21 + return + + def serialize(self): + """Convert this Entry's information into a 16-byte + .ico directory entry record. Return bytes object. + """ + len21 = self.length % 65536 + len3 = self.length // 65536 + rawdata = struct.pack('>HHLBHBBBBB', self.width, self.height, + self.offset, len3, len21, + 0, 0, 0, 0, 0) + return rawdata + +_iconNames = { + 0 : 'ICON_LOGO', + 1 : 'ICON_Print_0', + 2 : 'ICON_Print_1', + 3 : 'ICON_Prepare_0', + 4 : 'ICON_Prepare_1', + 5 : 'ICON_Control_0', + 6 : 'ICON_Control_1', + 7 : 'ICON_Leveling_0', + 8 : 'ICON_Leveling_1', + 9 : 'ICON_HotendTemp', + 10 : 'ICON_BedTemp', + 11 : 'ICON_Speed', + 12 : 'ICON_Zoffset', + 13 : 'ICON_Back', + 14 : 'ICON_File', + 15 : 'ICON_PrintTime', + 16 : 'ICON_RemainTime', + 17 : 'ICON_Setup_0', + 18 : 'ICON_Setup_1', + 19 : 'ICON_Pause_0', + 20 : 'ICON_Pause_1', + 21 : 'ICON_Continue_0', + 22 : 'ICON_Continue_1', + 23 : 'ICON_Stop_0', + 24 : 'ICON_Stop_1', + 25 : 'ICON_Bar', + 26 : 'ICON_More', + 27 : 'ICON_Axis', + 28 : 'ICON_CloseMotor', + 29 : 'ICON_Homing', + 30 : 'ICON_SetHome', + 31 : 'ICON_PLAPreheat', + 32 : 'ICON_ABSPreheat', + 33 : 'ICON_Cool', + 34 : 'ICON_Language', + 35 : 'ICON_MoveX', + 36 : 'ICON_MoveY', + 37 : 'ICON_MoveZ', + 38 : 'ICON_Extruder', + # no 39 + 40 : 'ICON_Temperature', + 41 : 'ICON_Motion', + 42 : 'ICON_WriteEEPROM', + 43 : 'ICON_ReadEEPROM', + 44 : 'ICON_ResumeEEPROM', + 45 : 'ICON_Info', + 46 : 'ICON_SetEndTemp', + 47 : 'ICON_SetBedTemp', + 48 : 'ICON_FanSpeed', + 49 : 'ICON_SetPLAPreheat', + 50 : 'ICON_SetABSPreheat', + 51 : 'ICON_MaxSpeed', + 52 : 'ICON_MaxAccelerated', + 53 : 'ICON_MaxJerk', + 54 : 'ICON_Step', + 55 : 'ICON_PrintSize', + 56 : 'ICON_Version', + 57 : 'ICON_Contact', + 58 : 'ICON_StockConfiguraton', + 59 : 'ICON_MaxSpeedX', + 60 : 'ICON_MaxSpeedY', + 61 : 'ICON_MaxSpeedZ', + 62 : 'ICON_MaxSpeedE', + 63 : 'ICON_MaxAccX', + 64 : 'ICON_MaxAccY', + 65 : 'ICON_MaxAccZ', + 66 : 'ICON_MaxAccE', + 67 : 'ICON_MaxSpeedJerkX', + 68 : 'ICON_MaxSpeedJerkY', + 69 : 'ICON_MaxSpeedJerkZ', + 70 : 'ICON_MaxSpeedJerkE', + 71 : 'ICON_StepX', + 72 : 'ICON_StepY', + 73 : 'ICON_StepZ', + 74 : 'ICON_StepE', + 75 : 'ICON_Setspeed', + 76 : 'ICON_SetZOffset', + 77 : 'ICON_Rectangle', + 78 : 'ICON_BLTouch', + 79 : 'ICON_TempTooLow', + 80 : 'ICON_AutoLeveling', + 81 : 'ICON_TempTooHigh', + 82 : 'ICON_NoTips_C', + 83 : 'ICON_NoTips_E', + 84 : 'ICON_Continue_C', + 85 : 'ICON_Continue_E', + 86 : 'ICON_Cancel_C', + 87 : 'ICON_Cancel_E', + 88 : 'ICON_Confirm_C', + 89 : 'ICON_Confirm_E', + 90 : 'ICON_Info_0', + 91 : 'ICON_Info_1' + } diff --git a/buildroot/share/dwin/bin/LICENSE b/buildroot/share/dwin/bin/LICENSE new file mode 100644 index 000000000000..f288702d2fa1 --- /dev/null +++ b/buildroot/share/dwin/bin/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/buildroot/share/dwin/bin/README.md b/buildroot/share/dwin/bin/README.md new file mode 100644 index 000000000000..9d513bc0c8f5 --- /dev/null +++ b/buildroot/share/dwin/bin/README.md @@ -0,0 +1,92 @@ +# DWIN Icon Tools + +Tools for processing `.ICO` files used by DWIN displays. + +## Introduction + +The DWIN LCDs that come with the Creality Ender 3 v2 and other 3D printers contain image and container files stored on them which are used to draw various the UI elements. + +Standard `.JPG` files can be installed for things like the boot screen, and `.ICO` files can contain several images within a structured file format. + +## DWIN Banks + +Each JPEG and ICO file starts with a number that tells DWIN which bank it should be stored in. Each numbered bank is 32K in size, so a single JPEG or ICO file can be up to 32kB before it starts to overwrite the next bank. For example, if the file loaded into bank 0 is over 32K, the next file should be numbered "2" so it loads into bank 2. The limit to the total size of all files installed on the display is usually 512KB, corresponding to 16 banks. All JPEG images, ICO containers, and fonts must fit into this space, so you may need to apply a lot of JPEG compression. + +## The Tools + +This folder includes two useful scripts, one to convert JPEG images into ICO files and another to extract JPEGs from ICO files. + +### splitIco.py + +The `splitIco.py` script reads an ICO file and extracts the component JPEG images, saving them in a new folder. Each icon is named by its index in the ICO, also using symbol names from Marlin's `dwin.h` header file for the display. + +### makeIco.py + +The `makeIco.py` script reads all the images in a folder and combines them into a single `.ICO` file. + +## Dependencies + +These tools are written in Python 3 using the [Pillow image library](https://pillow.readthedocs.io/en/latest/index.html). + +## Credits + +Created by Brent Burton [[@b-pub](https://github.com/b-pub)] + +## License + +These tools are provided under the GPL 3 license. See the `LICENSE` file for details. + +# Usage & Dependencies + +These tools must be run from a terminal with access to an installed Python 3 and the Pillow image library. + +Pillow is most easily installed with pip: + + python3 -m pip install pillow + +## Examples + +These tools process an `.ICO` file that you specify. The safest method is to create a folder and copy your `.ICO` file there. For example: + + $ mkdir hackicons + $ cp 9.ICO hackicons + $ cd hackicons + +The following explanations will refer back to this layout. + +### `splitIco.py` - Split the ICO archive + +If you want to edit the individual icons stored in an ICO file (or add more images) you'll first need to extract all the images from the archive using `splitIco.py`. + +**Usage:** `splitIco.py #.ICO foldername`. + +**Example:** + +In this example we're extracting the constituent JPEG files from `9.ICO` and storing them in a folder named `icons`. As each file is extracted the script reports its index number, byte offset, size, dimensions, and filename: + + $ cd buildroot/share/dwin + $ ./bin/splitIco.py 9.ICO icons-9 + Splitting 9.ICO into dir icons + Splitting Entry Data... + 00: offset: 0x001000 len: 0x10a2 width: 130 height: 17 + Wrote 4258 bytes to icons/000-ICON_LOGO.jpg + 01: offset: 0x0020a2 len: 0x0eac width: 110 height: 100 + Wrote 3756 bytes to icons/001-ICON_Print_0.jpg + 02: offset: 0x002f4e len: 0x0eaa width: 110 height: 100 + Wrote 3754 bytes to icons/002-ICON_Print_1.jpg + ... + 91: offset: 0x0345fc len: 0x0d89 width: 110 height: 100 + Wrote 3465 bytes to icons/091-ICON_Info_1.jpg + +Once the individual JPEG files have been saved they can be edited using common graphics applications like Photoshop. JPEG files are inherently lossy and will usually contain ugly artifacts, so cleanup may be needed before they are re-exported. Keep the limits of bank size in mind when exporting images and try to find the best balance between compressed size and image quality. + +### `makeIco.py` - Combine JPEGs into `ICO` archive + +After editing images you'll create a new `9.ICO` archive with `makeIco.py` like so: + + $ cd buildroot/share/dwin + $ ./bin/makeIco.py icons-3 3.ICO + Making .ico file '3.ICO' from contents of 'icons-3' + Scanning icon directory icons-3 + ...Scanned 16 icon files + Scanning done. 16 icons included. diff --git a/buildroot/share/dwin/bin/makeIco.py b/buildroot/share/dwin/bin/makeIco.py new file mode 100755 index 000000000000..274082acee87 --- /dev/null +++ b/buildroot/share/dwin/bin/makeIco.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# +# Make a DWIN .ico file from a directory of JPEG icon files. +# +# Copyright (c) 2020 Brent Burton +# +# 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 . +#---------------------------------------------------------------- + +import os +import os.path +import argparse +import DWIN_ICO + +version = '2.0.7' + +#---------------- +if __name__ == '__main__': + try: + parser = argparse.ArgumentParser(description='Make .ico from JPEG files') + parser.add_argument('iconDir', type=str, nargs=1, + help='name of directory containing icon JPGs') + parser.add_argument('filename', type=str, nargs=1, + help='name of new .ico file to create') + args = parser.parse_args() + + filename = args.filename[0] + iconDir = args.iconDir[0] + + if os.path.isfile(filename): + raise RuntimeError("ICO file '%s' already exists." % (filename)) + + if not os.path.exists(iconDir): + raise RuntimeError("Icon directory '%s' doesn't exist." % (iconDir)) + + print("Making .ico file '%s' from contents of '%s'" % (filename, iconDir)) + ico = DWIN_ICO.DWIN_ICO_File() + ico.createFile(iconDir, filename) + + except Exception as e: + print('Error: ', e) + diff --git a/buildroot/share/dwin/bin/splitIco.py b/buildroot/share/dwin/bin/splitIco.py new file mode 100755 index 000000000000..ce6ba89749c9 --- /dev/null +++ b/buildroot/share/dwin/bin/splitIco.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# +# Split a DWIN .ico file into separate images. +# +# Copyright (c) 2020 Brent Burton +# +# 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 . +#---------------------------------------------------------------- + +import os +import os.path +import argparse +import DWIN_ICO + +version = '2.0.7' + +#---------------- +if __name__ == '__main__': + try: + parser = argparse.ArgumentParser(description='Split .ico into JPEG files') + parser.add_argument('filename', type=str, nargs=1, + help='name of input .ico file to split') + parser.add_argument('outputDir', type=str, nargs=1, + help='name of output directory to create') + args = parser.parse_args() + + filename = args.filename[0] + outputDir = args.outputDir[0] + + if not os.path.isfile(filename): + raise RuntimeError("ICO file '%s' doesn't exist" % (filename)) + + if os.path.exists(outputDir): + raise RuntimeError("Output directory '%s' already exists." % (outputDir)) + + print('Splitting %s into dir %s' % (filename, outputDir)) + ico = DWIN_ICO.DWIN_ICO_File() + ico.splitFile(filename, outputDir) + + except Exception as e: + print('Error: ', e) diff --git a/buildroot/share/dwin/icons-2/000-ICON_BootLogo.jpg b/buildroot/share/dwin/icons-2/000-ICON_BootLogo.jpg new file mode 100644 index 000000000000..3ca4d1cf55cc Binary files /dev/null and b/buildroot/share/dwin/icons-2/000-ICON_BootLogo.jpg differ diff --git a/buildroot/share/dwin/icons-2/001-ICON_OpenSourceFirmware.jpg b/buildroot/share/dwin/icons-2/001-ICON_OpenSourceFirmware.jpg new file mode 100644 index 000000000000..a2c43da314b1 Binary files /dev/null and b/buildroot/share/dwin/icons-2/001-ICON_OpenSourceFirmware.jpg differ diff --git a/buildroot/share/dwin/icons-2/002-ICON_GitHub.jpg b/buildroot/share/dwin/icons-2/002-ICON_GitHub.jpg new file mode 100644 index 000000000000..0be90fa9bd94 Binary files /dev/null and b/buildroot/share/dwin/icons-2/002-ICON_GitHub.jpg differ diff --git a/buildroot/share/dwin/icons-2/003-ICON_Website.jpg b/buildroot/share/dwin/icons-2/003-ICON_Website.jpg new file mode 100644 index 000000000000..4e0e08a5fa1b Binary files /dev/null and b/buildroot/share/dwin/icons-2/003-ICON_Website.jpg differ diff --git a/buildroot/share/dwin/icons-2/004-ICON_Copyright.jpg b/buildroot/share/dwin/icons-2/004-ICON_Copyright.jpg new file mode 100644 index 000000000000..a3691d68c244 Binary files /dev/null and b/buildroot/share/dwin/icons-2/004-ICON_Copyright.jpg differ diff --git a/buildroot/share/dwin/icons-3/000-ICON_LOGO_Marlin.jpg b/buildroot/share/dwin/icons-3/000-ICON_LOGO_Marlin.jpg new file mode 100644 index 000000000000..f3e81f2284f1 Binary files /dev/null and b/buildroot/share/dwin/icons-3/000-ICON_LOGO_Marlin.jpg differ diff --git a/buildroot/share/dwin/icons-3/001-ICON_HotendOff.jpg b/buildroot/share/dwin/icons-3/001-ICON_HotendOff.jpg new file mode 100644 index 000000000000..08e18413ec0f Binary files /dev/null and b/buildroot/share/dwin/icons-3/001-ICON_HotendOff.jpg differ diff --git a/buildroot/share/dwin/icons-3/002-ICON_HotendOn.jpg b/buildroot/share/dwin/icons-3/002-ICON_HotendOn.jpg new file mode 100644 index 000000000000..5b501bd6d995 Binary files /dev/null and b/buildroot/share/dwin/icons-3/002-ICON_HotendOn.jpg differ diff --git a/buildroot/share/dwin/icons-3/003-ICON_BedOff.jpg b/buildroot/share/dwin/icons-3/003-ICON_BedOff.jpg new file mode 100644 index 000000000000..db9b546b3303 Binary files /dev/null and b/buildroot/share/dwin/icons-3/003-ICON_BedOff.jpg differ diff --git a/buildroot/share/dwin/icons-3/004-ICON_BedOn.jpg b/buildroot/share/dwin/icons-3/004-ICON_BedOn.jpg new file mode 100644 index 000000000000..c934b2fb99ac Binary files /dev/null and b/buildroot/share/dwin/icons-3/004-ICON_BedOn.jpg differ diff --git a/buildroot/share/dwin/icons-3/005-ICON_Fan0.jpg b/buildroot/share/dwin/icons-3/005-ICON_Fan0.jpg new file mode 100644 index 000000000000..c5c9957040b1 Binary files /dev/null and b/buildroot/share/dwin/icons-3/005-ICON_Fan0.jpg differ diff --git a/buildroot/share/dwin/icons-3/006-ICON_Fan1.jpg b/buildroot/share/dwin/icons-3/006-ICON_Fan1.jpg new file mode 100644 index 000000000000..8111a3db7485 Binary files /dev/null and b/buildroot/share/dwin/icons-3/006-ICON_Fan1.jpg differ diff --git a/buildroot/share/dwin/icons-3/007-ICON_Fan2.jpg b/buildroot/share/dwin/icons-3/007-ICON_Fan2.jpg new file mode 100644 index 000000000000..80a220be6376 Binary files /dev/null and b/buildroot/share/dwin/icons-3/007-ICON_Fan2.jpg differ diff --git a/buildroot/share/dwin/icons-3/008-ICON_Fan3.jpg b/buildroot/share/dwin/icons-3/008-ICON_Fan3.jpg new file mode 100644 index 000000000000..ba0cae54b012 Binary files /dev/null and b/buildroot/share/dwin/icons-3/008-ICON_Fan3.jpg differ diff --git a/buildroot/share/dwin/icons-3/009-ICON_Halted.jpg b/buildroot/share/dwin/icons-3/009-ICON_Halted.jpg new file mode 100644 index 000000000000..f13fae954773 Binary files /dev/null and b/buildroot/share/dwin/icons-3/009-ICON_Halted.jpg differ diff --git a/buildroot/share/dwin/icons-3/010-ICON_Question.jpg b/buildroot/share/dwin/icons-3/010-ICON_Question.jpg new file mode 100644 index 000000000000..a8d0cddaa8eb Binary files /dev/null and b/buildroot/share/dwin/icons-3/010-ICON_Question.jpg differ diff --git a/buildroot/share/dwin/icons-3/011-ICON_Alert.jpg b/buildroot/share/dwin/icons-3/011-ICON_Alert.jpg new file mode 100644 index 000000000000..603648e86433 Binary files /dev/null and b/buildroot/share/dwin/icons-3/011-ICON_Alert.jpg differ diff --git a/buildroot/share/dwin/icons-3/012-ICON_RotateCW.jpg b/buildroot/share/dwin/icons-3/012-ICON_RotateCW.jpg new file mode 100644 index 000000000000..36f404b9c963 Binary files /dev/null and b/buildroot/share/dwin/icons-3/012-ICON_RotateCW.jpg differ diff --git a/buildroot/share/dwin/icons-3/013-ICON_RotateCCW.jpg b/buildroot/share/dwin/icons-3/013-ICON_RotateCCW.jpg new file mode 100644 index 000000000000..3dc443c193cc Binary files /dev/null and b/buildroot/share/dwin/icons-3/013-ICON_RotateCCW.jpg differ diff --git a/buildroot/share/dwin/icons-3/014-ICON_UpArrow.jpg b/buildroot/share/dwin/icons-3/014-ICON_UpArrow.jpg new file mode 100644 index 000000000000..26b08ca10c13 Binary files /dev/null and b/buildroot/share/dwin/icons-3/014-ICON_UpArrow.jpg differ diff --git a/buildroot/share/dwin/icons-3/015-ICON_DownArrow.jpg b/buildroot/share/dwin/icons-3/015-ICON_DownArrow.jpg new file mode 100644 index 000000000000..5587a3f7f2db Binary files /dev/null and b/buildroot/share/dwin/icons-3/015-ICON_DownArrow.jpg differ diff --git a/buildroot/share/dwin/icons-6/000-ICON_LOGO_Creality.jpg b/buildroot/share/dwin/icons-6/000-ICON_LOGO_Creality.jpg new file mode 100644 index 000000000000..2ceb758a881a Binary files /dev/null and b/buildroot/share/dwin/icons-6/000-ICON_LOGO_Creality.jpg differ diff --git a/buildroot/share/dwin/icons-6/001-ICON_Print_0.jpg b/buildroot/share/dwin/icons-6/001-ICON_Print_0.jpg new file mode 100644 index 000000000000..8729a753c180 Binary files /dev/null and b/buildroot/share/dwin/icons-6/001-ICON_Print_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/002-ICON_Print_1.jpg b/buildroot/share/dwin/icons-6/002-ICON_Print_1.jpg new file mode 100644 index 000000000000..f89841ad1c80 Binary files /dev/null and b/buildroot/share/dwin/icons-6/002-ICON_Print_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/003-ICON_Prepare_0.jpg b/buildroot/share/dwin/icons-6/003-ICON_Prepare_0.jpg new file mode 100644 index 000000000000..2722fa4352db Binary files /dev/null and b/buildroot/share/dwin/icons-6/003-ICON_Prepare_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/004-ICON_Prepare_1.jpg b/buildroot/share/dwin/icons-6/004-ICON_Prepare_1.jpg new file mode 100644 index 000000000000..627082b6fb31 Binary files /dev/null and b/buildroot/share/dwin/icons-6/004-ICON_Prepare_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/005-ICON_Control_0.jpg b/buildroot/share/dwin/icons-6/005-ICON_Control_0.jpg new file mode 100644 index 000000000000..dfe23a3d4f46 Binary files /dev/null and b/buildroot/share/dwin/icons-6/005-ICON_Control_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/006-ICON_Control_1.jpg b/buildroot/share/dwin/icons-6/006-ICON_Control_1.jpg new file mode 100644 index 000000000000..2a813b655e2b Binary files /dev/null and b/buildroot/share/dwin/icons-6/006-ICON_Control_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/007-ICON_Leveling_0.jpg b/buildroot/share/dwin/icons-6/007-ICON_Leveling_0.jpg new file mode 100644 index 000000000000..34d12c62f521 Binary files /dev/null and b/buildroot/share/dwin/icons-6/007-ICON_Leveling_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/008-ICON_Leveling_1.jpg b/buildroot/share/dwin/icons-6/008-ICON_Leveling_1.jpg new file mode 100644 index 000000000000..f75e3720043c Binary files /dev/null and b/buildroot/share/dwin/icons-6/008-ICON_Leveling_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/009-ICON_HotendTemp.jpg b/buildroot/share/dwin/icons-6/009-ICON_HotendTemp.jpg new file mode 100644 index 000000000000..0bf1437c646d Binary files /dev/null and b/buildroot/share/dwin/icons-6/009-ICON_HotendTemp.jpg differ diff --git a/buildroot/share/dwin/icons-6/010-ICON_BedTemp.jpg b/buildroot/share/dwin/icons-6/010-ICON_BedTemp.jpg new file mode 100644 index 000000000000..186d02ad3b92 Binary files /dev/null and b/buildroot/share/dwin/icons-6/010-ICON_BedTemp.jpg differ diff --git a/buildroot/share/dwin/icons-6/011-ICON_Speed.jpg b/buildroot/share/dwin/icons-6/011-ICON_Speed.jpg new file mode 100644 index 000000000000..387c166566b7 Binary files /dev/null and b/buildroot/share/dwin/icons-6/011-ICON_Speed.jpg differ diff --git a/buildroot/share/dwin/icons-6/012-ICON_Zoffset.jpg b/buildroot/share/dwin/icons-6/012-ICON_Zoffset.jpg new file mode 100644 index 000000000000..2e74ee3986d9 Binary files /dev/null and b/buildroot/share/dwin/icons-6/012-ICON_Zoffset.jpg differ diff --git a/buildroot/share/dwin/icons-6/013-ICON_Back.jpg b/buildroot/share/dwin/icons-6/013-ICON_Back.jpg new file mode 100644 index 000000000000..7ffb646b396e Binary files /dev/null and b/buildroot/share/dwin/icons-6/013-ICON_Back.jpg differ diff --git a/buildroot/share/dwin/icons-6/014-ICON_File.jpg b/buildroot/share/dwin/icons-6/014-ICON_File.jpg new file mode 100644 index 000000000000..44a2fa1fd2c0 Binary files /dev/null and b/buildroot/share/dwin/icons-6/014-ICON_File.jpg differ diff --git a/buildroot/share/dwin/icons-6/015-ICON_PrintTime.jpg b/buildroot/share/dwin/icons-6/015-ICON_PrintTime.jpg new file mode 100644 index 000000000000..9b7bfdbaf124 Binary files /dev/null and b/buildroot/share/dwin/icons-6/015-ICON_PrintTime.jpg differ diff --git a/buildroot/share/dwin/icons-6/016-ICON_RemainTime.jpg b/buildroot/share/dwin/icons-6/016-ICON_RemainTime.jpg new file mode 100644 index 000000000000..ad958d31af67 Binary files /dev/null and b/buildroot/share/dwin/icons-6/016-ICON_RemainTime.jpg differ diff --git a/buildroot/share/dwin/icons-6/017-ICON_Setup_0.jpg b/buildroot/share/dwin/icons-6/017-ICON_Setup_0.jpg new file mode 100644 index 000000000000..92fdc079c619 Binary files /dev/null and b/buildroot/share/dwin/icons-6/017-ICON_Setup_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/018-ICON_Setup_1.jpg b/buildroot/share/dwin/icons-6/018-ICON_Setup_1.jpg new file mode 100644 index 000000000000..6c6793452182 Binary files /dev/null and b/buildroot/share/dwin/icons-6/018-ICON_Setup_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/019-ICON_Pause_0.jpg b/buildroot/share/dwin/icons-6/019-ICON_Pause_0.jpg new file mode 100644 index 000000000000..2f6e83110965 Binary files /dev/null and b/buildroot/share/dwin/icons-6/019-ICON_Pause_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/020-ICON_Pause_1.jpg b/buildroot/share/dwin/icons-6/020-ICON_Pause_1.jpg new file mode 100644 index 000000000000..746b943c149f Binary files /dev/null and b/buildroot/share/dwin/icons-6/020-ICON_Pause_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/021-ICON_Continue_0.jpg b/buildroot/share/dwin/icons-6/021-ICON_Continue_0.jpg new file mode 100644 index 000000000000..929004bb786e Binary files /dev/null and b/buildroot/share/dwin/icons-6/021-ICON_Continue_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/022-ICON_Continue_1.jpg b/buildroot/share/dwin/icons-6/022-ICON_Continue_1.jpg new file mode 100644 index 000000000000..4c8c78f38fa3 Binary files /dev/null and b/buildroot/share/dwin/icons-6/022-ICON_Continue_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/023-ICON_Stop_0.jpg b/buildroot/share/dwin/icons-6/023-ICON_Stop_0.jpg new file mode 100644 index 000000000000..320b4e6b9934 Binary files /dev/null and b/buildroot/share/dwin/icons-6/023-ICON_Stop_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/024-ICON_Stop_1.jpg b/buildroot/share/dwin/icons-6/024-ICON_Stop_1.jpg new file mode 100644 index 000000000000..fdbc3686ca56 Binary files /dev/null and b/buildroot/share/dwin/icons-6/024-ICON_Stop_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/025-ICON_Bar.jpg b/buildroot/share/dwin/icons-6/025-ICON_Bar.jpg new file mode 100644 index 000000000000..1449d9a1827a Binary files /dev/null and b/buildroot/share/dwin/icons-6/025-ICON_Bar.jpg differ diff --git a/buildroot/share/dwin/icons-6/026-ICON_More.jpg b/buildroot/share/dwin/icons-6/026-ICON_More.jpg new file mode 100644 index 000000000000..6ee088a7f221 Binary files /dev/null and b/buildroot/share/dwin/icons-6/026-ICON_More.jpg differ diff --git a/buildroot/share/dwin/icons-6/027-ICON_Axis.jpg b/buildroot/share/dwin/icons-6/027-ICON_Axis.jpg new file mode 100644 index 000000000000..2eb19a0011ee Binary files /dev/null and b/buildroot/share/dwin/icons-6/027-ICON_Axis.jpg differ diff --git a/buildroot/share/dwin/icons-6/028-ICON_CloseMotor.jpg b/buildroot/share/dwin/icons-6/028-ICON_CloseMotor.jpg new file mode 100644 index 000000000000..cdb4f74d40f2 Binary files /dev/null and b/buildroot/share/dwin/icons-6/028-ICON_CloseMotor.jpg differ diff --git a/buildroot/share/dwin/icons-6/029-ICON_Homing.jpg b/buildroot/share/dwin/icons-6/029-ICON_Homing.jpg new file mode 100644 index 000000000000..ce263014ead9 Binary files /dev/null and b/buildroot/share/dwin/icons-6/029-ICON_Homing.jpg differ diff --git a/buildroot/share/dwin/icons-6/030-ICON_SetHome.jpg b/buildroot/share/dwin/icons-6/030-ICON_SetHome.jpg new file mode 100644 index 000000000000..14aedc0dd019 Binary files /dev/null and b/buildroot/share/dwin/icons-6/030-ICON_SetHome.jpg differ diff --git a/buildroot/share/dwin/icons-6/031-ICON_PLAPreheat.jpg b/buildroot/share/dwin/icons-6/031-ICON_PLAPreheat.jpg new file mode 100644 index 000000000000..7b8eb5857d6c Binary files /dev/null and b/buildroot/share/dwin/icons-6/031-ICON_PLAPreheat.jpg differ diff --git a/buildroot/share/dwin/icons-6/032-ICON_ABSPreheat.jpg b/buildroot/share/dwin/icons-6/032-ICON_ABSPreheat.jpg new file mode 100644 index 000000000000..274604d2f92b Binary files /dev/null and b/buildroot/share/dwin/icons-6/032-ICON_ABSPreheat.jpg differ diff --git a/buildroot/share/dwin/icons-6/033-ICON_Cool.jpg b/buildroot/share/dwin/icons-6/033-ICON_Cool.jpg new file mode 100644 index 000000000000..014e6f5dcbab Binary files /dev/null and b/buildroot/share/dwin/icons-6/033-ICON_Cool.jpg differ diff --git a/buildroot/share/dwin/icons-6/034-ICON_Language.jpg b/buildroot/share/dwin/icons-6/034-ICON_Language.jpg new file mode 100644 index 000000000000..055b4c1ae8e6 Binary files /dev/null and b/buildroot/share/dwin/icons-6/034-ICON_Language.jpg differ diff --git a/buildroot/share/dwin/icons-6/035-ICON_MoveX.jpg b/buildroot/share/dwin/icons-6/035-ICON_MoveX.jpg new file mode 100644 index 000000000000..54f834caaf12 Binary files /dev/null and b/buildroot/share/dwin/icons-6/035-ICON_MoveX.jpg differ diff --git a/buildroot/share/dwin/icons-6/036-ICON_MoveY.jpg b/buildroot/share/dwin/icons-6/036-ICON_MoveY.jpg new file mode 100644 index 000000000000..b82a5b25cd6f Binary files /dev/null and b/buildroot/share/dwin/icons-6/036-ICON_MoveY.jpg differ diff --git a/buildroot/share/dwin/icons-6/037-ICON_MoveZ.jpg b/buildroot/share/dwin/icons-6/037-ICON_MoveZ.jpg new file mode 100644 index 000000000000..487d6e4e4436 Binary files /dev/null and b/buildroot/share/dwin/icons-6/037-ICON_MoveZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/038-ICON_Extruder.jpg b/buildroot/share/dwin/icons-6/038-ICON_Extruder.jpg new file mode 100644 index 000000000000..155b9a58576d Binary files /dev/null and b/buildroot/share/dwin/icons-6/038-ICON_Extruder.jpg differ diff --git a/buildroot/share/dwin/icons-6/040-ICON_Temperature.jpg b/buildroot/share/dwin/icons-6/040-ICON_Temperature.jpg new file mode 100644 index 000000000000..eaea25bbd881 Binary files /dev/null and b/buildroot/share/dwin/icons-6/040-ICON_Temperature.jpg differ diff --git a/buildroot/share/dwin/icons-6/041-ICON_Motion.jpg b/buildroot/share/dwin/icons-6/041-ICON_Motion.jpg new file mode 100644 index 000000000000..472a6354e43d Binary files /dev/null and b/buildroot/share/dwin/icons-6/041-ICON_Motion.jpg differ diff --git a/buildroot/share/dwin/icons-6/042-ICON_WriteEEPROM.jpg b/buildroot/share/dwin/icons-6/042-ICON_WriteEEPROM.jpg new file mode 100644 index 000000000000..2a4dd5b9296c Binary files /dev/null and b/buildroot/share/dwin/icons-6/042-ICON_WriteEEPROM.jpg differ diff --git a/buildroot/share/dwin/icons-6/043-ICON_ReadEEPROM.jpg b/buildroot/share/dwin/icons-6/043-ICON_ReadEEPROM.jpg new file mode 100644 index 000000000000..53aab6b7578c Binary files /dev/null and b/buildroot/share/dwin/icons-6/043-ICON_ReadEEPROM.jpg differ diff --git a/buildroot/share/dwin/icons-6/044-ICON_ResumeEEPROM.jpg b/buildroot/share/dwin/icons-6/044-ICON_ResumeEEPROM.jpg new file mode 100644 index 000000000000..840bac572861 Binary files /dev/null and b/buildroot/share/dwin/icons-6/044-ICON_ResumeEEPROM.jpg differ diff --git a/buildroot/share/dwin/icons-6/045-ICON_Info.jpg b/buildroot/share/dwin/icons-6/045-ICON_Info.jpg new file mode 100644 index 000000000000..34e63e587a1c Binary files /dev/null and b/buildroot/share/dwin/icons-6/045-ICON_Info.jpg differ diff --git a/buildroot/share/dwin/icons-6/046-ICON_SetEndTemp.jpg b/buildroot/share/dwin/icons-6/046-ICON_SetEndTemp.jpg new file mode 100644 index 000000000000..33f50041836c Binary files /dev/null and b/buildroot/share/dwin/icons-6/046-ICON_SetEndTemp.jpg differ diff --git a/buildroot/share/dwin/icons-6/047-ICON_SetBedTemp.jpg b/buildroot/share/dwin/icons-6/047-ICON_SetBedTemp.jpg new file mode 100644 index 000000000000..09e5072ab9b4 Binary files /dev/null and b/buildroot/share/dwin/icons-6/047-ICON_SetBedTemp.jpg differ diff --git a/buildroot/share/dwin/icons-6/048-ICON_FanSpeed.jpg b/buildroot/share/dwin/icons-6/048-ICON_FanSpeed.jpg new file mode 100644 index 000000000000..6ed23f653fa9 Binary files /dev/null and b/buildroot/share/dwin/icons-6/048-ICON_FanSpeed.jpg differ diff --git a/buildroot/share/dwin/icons-6/049-ICON_SetPLAPreheat.jpg b/buildroot/share/dwin/icons-6/049-ICON_SetPLAPreheat.jpg new file mode 100644 index 000000000000..f69c6f454e19 Binary files /dev/null and b/buildroot/share/dwin/icons-6/049-ICON_SetPLAPreheat.jpg differ diff --git a/buildroot/share/dwin/icons-6/050-ICON_SetABSPreheat.jpg b/buildroot/share/dwin/icons-6/050-ICON_SetABSPreheat.jpg new file mode 100644 index 000000000000..07620e14eb12 Binary files /dev/null and b/buildroot/share/dwin/icons-6/050-ICON_SetABSPreheat.jpg differ diff --git a/buildroot/share/dwin/icons-6/051-ICON_MaxSpeed.jpg b/buildroot/share/dwin/icons-6/051-ICON_MaxSpeed.jpg new file mode 100644 index 000000000000..eaaa21255b62 Binary files /dev/null and b/buildroot/share/dwin/icons-6/051-ICON_MaxSpeed.jpg differ diff --git a/buildroot/share/dwin/icons-6/052-ICON_MaxAccelerated.jpg b/buildroot/share/dwin/icons-6/052-ICON_MaxAccelerated.jpg new file mode 100644 index 000000000000..4e9c3ad6e410 Binary files /dev/null and b/buildroot/share/dwin/icons-6/052-ICON_MaxAccelerated.jpg differ diff --git a/buildroot/share/dwin/icons-6/053-ICON_MaxJerk.jpg b/buildroot/share/dwin/icons-6/053-ICON_MaxJerk.jpg new file mode 100644 index 000000000000..119df1a03d64 Binary files /dev/null and b/buildroot/share/dwin/icons-6/053-ICON_MaxJerk.jpg differ diff --git a/buildroot/share/dwin/icons-6/054-ICON_Step.jpg b/buildroot/share/dwin/icons-6/054-ICON_Step.jpg new file mode 100644 index 000000000000..4a0da4a487cd Binary files /dev/null and b/buildroot/share/dwin/icons-6/054-ICON_Step.jpg differ diff --git a/buildroot/share/dwin/icons-6/055-ICON_PrintSize.jpg b/buildroot/share/dwin/icons-6/055-ICON_PrintSize.jpg new file mode 100644 index 000000000000..4f08d5f1f92c Binary files /dev/null and b/buildroot/share/dwin/icons-6/055-ICON_PrintSize.jpg differ diff --git a/buildroot/share/dwin/icons-6/056-ICON_Version.jpg b/buildroot/share/dwin/icons-6/056-ICON_Version.jpg new file mode 100644 index 000000000000..2d275d82b4a3 Binary files /dev/null and b/buildroot/share/dwin/icons-6/056-ICON_Version.jpg differ diff --git a/buildroot/share/dwin/icons-6/057-ICON_Contact.jpg b/buildroot/share/dwin/icons-6/057-ICON_Contact.jpg new file mode 100644 index 000000000000..5138789de89a Binary files /dev/null and b/buildroot/share/dwin/icons-6/057-ICON_Contact.jpg differ diff --git a/buildroot/share/dwin/icons-6/058-ICON_StockConfiguraton.jpg b/buildroot/share/dwin/icons-6/058-ICON_StockConfiguraton.jpg new file mode 100644 index 000000000000..8e2b6fedbe13 Binary files /dev/null and b/buildroot/share/dwin/icons-6/058-ICON_StockConfiguraton.jpg differ diff --git a/buildroot/share/dwin/icons-6/059-ICON_MaxSpeedX.jpg b/buildroot/share/dwin/icons-6/059-ICON_MaxSpeedX.jpg new file mode 100644 index 000000000000..c60504f326f7 Binary files /dev/null and b/buildroot/share/dwin/icons-6/059-ICON_MaxSpeedX.jpg differ diff --git a/buildroot/share/dwin/icons-6/060-ICON_MaxSpeedY.jpg b/buildroot/share/dwin/icons-6/060-ICON_MaxSpeedY.jpg new file mode 100644 index 000000000000..c3b3cc7ce18f Binary files /dev/null and b/buildroot/share/dwin/icons-6/060-ICON_MaxSpeedY.jpg differ diff --git a/buildroot/share/dwin/icons-6/061-ICON_MaxSpeedZ.jpg b/buildroot/share/dwin/icons-6/061-ICON_MaxSpeedZ.jpg new file mode 100644 index 000000000000..fe79df374681 Binary files /dev/null and b/buildroot/share/dwin/icons-6/061-ICON_MaxSpeedZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/062-ICON_MaxSpeedE.jpg b/buildroot/share/dwin/icons-6/062-ICON_MaxSpeedE.jpg new file mode 100644 index 000000000000..519f1b448c84 Binary files /dev/null and b/buildroot/share/dwin/icons-6/062-ICON_MaxSpeedE.jpg differ diff --git a/buildroot/share/dwin/icons-6/063-ICON_MaxAccX.jpg b/buildroot/share/dwin/icons-6/063-ICON_MaxAccX.jpg new file mode 100644 index 000000000000..9258c8618fa3 Binary files /dev/null and b/buildroot/share/dwin/icons-6/063-ICON_MaxAccX.jpg differ diff --git a/buildroot/share/dwin/icons-6/064-ICON_MaxAccY.jpg b/buildroot/share/dwin/icons-6/064-ICON_MaxAccY.jpg new file mode 100644 index 000000000000..1a163314560c Binary files /dev/null and b/buildroot/share/dwin/icons-6/064-ICON_MaxAccY.jpg differ diff --git a/buildroot/share/dwin/icons-6/065-ICON_MaxAccZ.jpg b/buildroot/share/dwin/icons-6/065-ICON_MaxAccZ.jpg new file mode 100644 index 000000000000..23255ce0e591 Binary files /dev/null and b/buildroot/share/dwin/icons-6/065-ICON_MaxAccZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/066-ICON_MaxAccE.jpg b/buildroot/share/dwin/icons-6/066-ICON_MaxAccE.jpg new file mode 100644 index 000000000000..5bd3fedd6e15 Binary files /dev/null and b/buildroot/share/dwin/icons-6/066-ICON_MaxAccE.jpg differ diff --git a/buildroot/share/dwin/icons-6/067-ICON_MaxSpeedJerkX.jpg b/buildroot/share/dwin/icons-6/067-ICON_MaxSpeedJerkX.jpg new file mode 100644 index 000000000000..c316c750b58c Binary files /dev/null and b/buildroot/share/dwin/icons-6/067-ICON_MaxSpeedJerkX.jpg differ diff --git a/buildroot/share/dwin/icons-6/068-ICON_MaxSpeedJerkY.jpg b/buildroot/share/dwin/icons-6/068-ICON_MaxSpeedJerkY.jpg new file mode 100644 index 000000000000..c7cda895033b Binary files /dev/null and b/buildroot/share/dwin/icons-6/068-ICON_MaxSpeedJerkY.jpg differ diff --git a/buildroot/share/dwin/icons-6/069-ICON_MaxSpeedJerkZ.jpg b/buildroot/share/dwin/icons-6/069-ICON_MaxSpeedJerkZ.jpg new file mode 100644 index 000000000000..be450cd460ac Binary files /dev/null and b/buildroot/share/dwin/icons-6/069-ICON_MaxSpeedJerkZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/070-ICON_MaxSpeedJerkE.jpg b/buildroot/share/dwin/icons-6/070-ICON_MaxSpeedJerkE.jpg new file mode 100644 index 000000000000..3c926b856519 Binary files /dev/null and b/buildroot/share/dwin/icons-6/070-ICON_MaxSpeedJerkE.jpg differ diff --git a/buildroot/share/dwin/icons-6/071-ICON_StepX.jpg b/buildroot/share/dwin/icons-6/071-ICON_StepX.jpg new file mode 100644 index 000000000000..f1015b82185f Binary files /dev/null and b/buildroot/share/dwin/icons-6/071-ICON_StepX.jpg differ diff --git a/buildroot/share/dwin/icons-6/072-ICON_StepY.jpg b/buildroot/share/dwin/icons-6/072-ICON_StepY.jpg new file mode 100644 index 000000000000..9bb3e6e6beb7 Binary files /dev/null and b/buildroot/share/dwin/icons-6/072-ICON_StepY.jpg differ diff --git a/buildroot/share/dwin/icons-6/073-ICON_StepZ.jpg b/buildroot/share/dwin/icons-6/073-ICON_StepZ.jpg new file mode 100644 index 000000000000..78dce2a36933 Binary files /dev/null and b/buildroot/share/dwin/icons-6/073-ICON_StepZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/074-ICON_StepE.jpg b/buildroot/share/dwin/icons-6/074-ICON_StepE.jpg new file mode 100644 index 000000000000..58eaff565032 Binary files /dev/null and b/buildroot/share/dwin/icons-6/074-ICON_StepE.jpg differ diff --git a/buildroot/share/dwin/icons-6/075-ICON_Setspeed.jpg b/buildroot/share/dwin/icons-6/075-ICON_Setspeed.jpg new file mode 100644 index 000000000000..94b808f716a2 Binary files /dev/null and b/buildroot/share/dwin/icons-6/075-ICON_Setspeed.jpg differ diff --git a/buildroot/share/dwin/icons-6/076-ICON_SetZOffset.jpg b/buildroot/share/dwin/icons-6/076-ICON_SetZOffset.jpg new file mode 100644 index 000000000000..14aedc0dd019 Binary files /dev/null and b/buildroot/share/dwin/icons-6/076-ICON_SetZOffset.jpg differ diff --git a/buildroot/share/dwin/icons-6/077-ICON_Rectangle.jpg b/buildroot/share/dwin/icons-6/077-ICON_Rectangle.jpg new file mode 100644 index 000000000000..3069eccd5048 Binary files /dev/null and b/buildroot/share/dwin/icons-6/077-ICON_Rectangle.jpg differ diff --git a/buildroot/share/dwin/icons-6/078-ICON_BLTouch.jpg b/buildroot/share/dwin/icons-6/078-ICON_BLTouch.jpg new file mode 100644 index 000000000000..b3234d45aa12 Binary files /dev/null and b/buildroot/share/dwin/icons-6/078-ICON_BLTouch.jpg differ diff --git a/buildroot/share/dwin/icons-6/079-ICON_TempTooLow.jpg b/buildroot/share/dwin/icons-6/079-ICON_TempTooLow.jpg new file mode 100644 index 000000000000..c403c328f5ed Binary files /dev/null and b/buildroot/share/dwin/icons-6/079-ICON_TempTooLow.jpg differ diff --git a/buildroot/share/dwin/icons-6/080-ICON_AutoLeveling.jpg b/buildroot/share/dwin/icons-6/080-ICON_AutoLeveling.jpg new file mode 100644 index 000000000000..837c5ee28161 Binary files /dev/null and b/buildroot/share/dwin/icons-6/080-ICON_AutoLeveling.jpg differ diff --git a/buildroot/share/dwin/icons-6/081-ICON_TempTooHigh.jpg b/buildroot/share/dwin/icons-6/081-ICON_TempTooHigh.jpg new file mode 100644 index 000000000000..07aae4e5ec33 Binary files /dev/null and b/buildroot/share/dwin/icons-6/081-ICON_TempTooHigh.jpg differ diff --git a/buildroot/share/dwin/icons-6/082-ICON_NoTips_C.jpg b/buildroot/share/dwin/icons-6/082-ICON_NoTips_C.jpg new file mode 100644 index 000000000000..b55706060c8b Binary files /dev/null and b/buildroot/share/dwin/icons-6/082-ICON_NoTips_C.jpg differ diff --git a/buildroot/share/dwin/icons-6/083-ICON_NoTips_E.jpg b/buildroot/share/dwin/icons-6/083-ICON_NoTips_E.jpg new file mode 100644 index 000000000000..470b88a52664 Binary files /dev/null and b/buildroot/share/dwin/icons-6/083-ICON_NoTips_E.jpg differ diff --git a/buildroot/share/dwin/icons-6/084-ICON_Continue_C.jpg b/buildroot/share/dwin/icons-6/084-ICON_Continue_C.jpg new file mode 100644 index 000000000000..718fd59591a4 Binary files /dev/null and b/buildroot/share/dwin/icons-6/084-ICON_Continue_C.jpg differ diff --git a/buildroot/share/dwin/icons-6/085-ICON_Continue_E.jpg b/buildroot/share/dwin/icons-6/085-ICON_Continue_E.jpg new file mode 100644 index 000000000000..2fb635d2bffa Binary files /dev/null and b/buildroot/share/dwin/icons-6/085-ICON_Continue_E.jpg differ diff --git a/buildroot/share/dwin/icons-6/086-ICON_Cancel_C.jpg b/buildroot/share/dwin/icons-6/086-ICON_Cancel_C.jpg new file mode 100644 index 000000000000..af203f508107 Binary files /dev/null and b/buildroot/share/dwin/icons-6/086-ICON_Cancel_C.jpg differ diff --git a/buildroot/share/dwin/icons-6/087-ICON_Cancel_E.jpg b/buildroot/share/dwin/icons-6/087-ICON_Cancel_E.jpg new file mode 100644 index 000000000000..db1642e00c59 Binary files /dev/null and b/buildroot/share/dwin/icons-6/087-ICON_Cancel_E.jpg differ diff --git a/buildroot/share/dwin/icons-6/088-ICON_Confirm_C.jpg b/buildroot/share/dwin/icons-6/088-ICON_Confirm_C.jpg new file mode 100644 index 000000000000..6f441efb82cb Binary files /dev/null and b/buildroot/share/dwin/icons-6/088-ICON_Confirm_C.jpg differ diff --git a/buildroot/share/dwin/icons-6/089-ICON_Confirm_E.jpg b/buildroot/share/dwin/icons-6/089-ICON_Confirm_E.jpg new file mode 100644 index 000000000000..5f424b67ea7c Binary files /dev/null and b/buildroot/share/dwin/icons-6/089-ICON_Confirm_E.jpg differ diff --git a/buildroot/share/dwin/icons-6/090-ICON_Info_0.jpg b/buildroot/share/dwin/icons-6/090-ICON_Info_0.jpg new file mode 100644 index 000000000000..d392a301ed8d Binary files /dev/null and b/buildroot/share/dwin/icons-6/090-ICON_Info_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/091-ICON_Info_1.jpg b/buildroot/share/dwin/icons-6/091-ICON_Info_1.jpg new file mode 100644 index 000000000000..cde9c0b064e2 Binary files /dev/null and b/buildroot/share/dwin/icons-6/091-ICON_Info_1.jpg differ diff --git a/buildroot/share/dwin/icons-svg/alert.svg b/buildroot/share/dwin/icons-svg/alert.svg new file mode 100644 index 000000000000..e98bd58bd8e1 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/alert.svg @@ -0,0 +1,85 @@ + + + + + + + + image/svg+xml + + + + + + + + ! + + diff --git a/buildroot/share/dwin/icons-svg/bed_flat_old.svg b/buildroot/share/dwin/icons-svg/bed_flat_old.svg new file mode 100644 index 000000000000..e4b860bc7158 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_flat_old.svg @@ -0,0 +1,72 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_flat_on.svg b/buildroot/share/dwin/icons-svg/bed_flat_on.svg new file mode 100644 index 000000000000..a87b0c0ff071 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_flat_on.svg @@ -0,0 +1,91 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_leveled_off.svg b/buildroot/share/dwin/icons-svg/bed_leveled_off.svg new file mode 100644 index 000000000000..161b8d11d457 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_leveled_off.svg @@ -0,0 +1,83 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_leveled_on.svg b/buildroot/share/dwin/icons-svg/bed_leveled_on.svg new file mode 100644 index 000000000000..bda0c77a9ebc --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_leveled_on.svg @@ -0,0 +1,103 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_off.svg b/buildroot/share/dwin/icons-svg/bed_off.svg new file mode 100644 index 000000000000..936710e49bda --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_off.svg @@ -0,0 +1,64 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_on.svg b/buildroot/share/dwin/icons-svg/bed_on.svg new file mode 100644 index 000000000000..61218e57a6a2 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_on.svg @@ -0,0 +1,84 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bedline.svg b/buildroot/share/dwin/icons-svg/bedline.svg new file mode 100644 index 000000000000..51670b7a196a --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bedline.svg @@ -0,0 +1,64 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/down_arrow.svg b/buildroot/share/dwin/icons-svg/down_arrow.svg new file mode 100644 index 000000000000..9c1d07efe064 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/down_arrow.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/fan.svg b/buildroot/share/dwin/icons-svg/fan.svg new file mode 100644 index 000000000000..0040f26b6b8e --- /dev/null +++ b/buildroot/share/dwin/icons-svg/fan.svg @@ -0,0 +1,155 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/halted.svg b/buildroot/share/dwin/icons-svg/halted.svg new file mode 100644 index 000000000000..38a78384bcdc --- /dev/null +++ b/buildroot/share/dwin/icons-svg/halted.svg @@ -0,0 +1,83 @@ + + + + + + + + image/svg+xml + + + + + + + + X + + diff --git a/buildroot/share/dwin/icons-svg/hotend_off.svg b/buildroot/share/dwin/icons-svg/hotend_off.svg new file mode 100644 index 000000000000..14da6a23ebfb --- /dev/null +++ b/buildroot/share/dwin/icons-svg/hotend_off.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/hotend_on.svg b/buildroot/share/dwin/icons-svg/hotend_on.svg new file mode 100644 index 000000000000..f112ba186b06 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/hotend_on.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/question.svg b/buildroot/share/dwin/icons-svg/question.svg new file mode 100644 index 000000000000..8d8849ca4e56 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/question.svg @@ -0,0 +1,75 @@ + + + + + + + + image/svg+xml + + + + + + + + ? + + diff --git a/buildroot/share/dwin/icons-svg/rotate_ccw.svg b/buildroot/share/dwin/icons-svg/rotate_ccw.svg new file mode 100644 index 000000000000..8b007725c674 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/rotate_ccw.svg @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/rotate_cw.svg b/buildroot/share/dwin/icons-svg/rotate_cw.svg new file mode 100644 index 000000000000..446ad519ec0c --- /dev/null +++ b/buildroot/share/dwin/icons-svg/rotate_cw.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/up_arrow.svg b/buildroot/share/dwin/icons-svg/up_arrow.svg new file mode 100644 index 000000000000..bc20be269339 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/up_arrow.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/make_jpgs.sh b/buildroot/share/dwin/make_jpgs.sh new file mode 100755 index 000000000000..0acace7388df --- /dev/null +++ b/buildroot/share/dwin/make_jpgs.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +mkdir -p icons-3 + +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/hotend_off.svg ./icons-3/001-ICON_HotendOff.jpg +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/hotend_on.svg ./icons-3/002-ICON_HotendOn.jpg + +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_off.svg ./icons-3/003-ICON_BedOff.jpg +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_on.svg ./icons-3/004-ICON_BedOn.jpg + +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/fan.svg ./icons-3/005-ICON_Fan0.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 22.5 ./icons-svg/fan.svg ./icons-3/006-ICON_Fan1.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 45 ./icons-svg/fan.svg ./icons-3/007-ICON_Fan2.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 67.5 ./icons-svg/fan.svg ./icons-3/008-ICON_Fan3.jpg + +convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/halted.svg ./icons-3/009-ICON_Halted.jpg +convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/question.svg ./icons-3/010-ICON_Question.jpg +convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/alert.svg ./icons-3/011-ICON_Alert.jpg + +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/rotate_cw.svg ./icons-3/012-ICON_RotateCW.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/rotate_ccw.svg ./icons-3/013-ICON_RotateCCW.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/up_arrow.svg ./icons-3/014-ICON_UpArrow.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/down_arrow.svg ./icons-3/015-ICON_DownArrow.jpg + +convert -size 48x8 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bedline.svg ./icons-3/016-ICON_Bedline.jpg + +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_leveled_off.svg ./icons-3/017-ICON_BedLeveledOff.jpg +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_leveled_on.svg ./icons-3/018-ICON_BedLeveledOn.jpg + +rm 3.ICO +./bin/makeIco.py icons-3 3.ICO diff --git a/buildroot/share/git/mffp b/buildroot/share/git/mffp index 0680b3dba562..ab4dd4c0b771 100755 --- a/buildroot/share/git/mffp +++ b/buildroot/share/git/mffp @@ -6,7 +6,7 @@ # By default: `git push upstream HEAD:bugfix-2.0.x` # -usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 } +usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 ; } [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage ; exit 1; } @@ -17,7 +17,7 @@ elif [[ $# == 1 ]]; then MFINFO=$(mfinfo) || exit 1 REF=${1:-HEAD} else - usage + usage ; exit 1 fi IFS=' ' read -a INFO <<< "$MFINFO" diff --git a/buildroot/share/git/mfnew b/buildroot/share/git/mfnew index 6d067a7f08e6..48703e67a14d 100755 --- a/buildroot/share/git/mfnew +++ b/buildroot/share/git/mfnew @@ -5,9 +5,7 @@ # Create a new branch from the default target with the given name # -usage() { - echo "usage: `basename $0` [1|2] [name]" 1>&2 -} +usage() { echo "usage: `basename $0` [1|2] [name]" 1>&2 ; } [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; } diff --git a/buildroot/share/git/mfprep b/buildroot/share/git/mfprep index 7a8e05ee317c..b329d7d8c5d9 100755 --- a/buildroot/share/git/mfprep +++ b/buildroot/share/git/mfprep @@ -60,5 +60,6 @@ cat "$LOGB" | while read line; do fi done mv "$TMPF" "$SCRF" +chmod ug+x "$SCRF" open "$TMPDIR" diff --git a/buildroot/share/scripts/MarlinBinaryProtocol.py b/buildroot/share/scripts/MarlinBinaryProtocol.py new file mode 100644 index 000000000000..4887ad991978 --- /dev/null +++ b/buildroot/share/scripts/MarlinBinaryProtocol.py @@ -0,0 +1,434 @@ +# +# MarlinBinaryProtocol.py +# Supporting Firmware upload via USB/Serial, saving to the attached media. +# +import serial +import math +import time +from collections import deque +import threading +import sys +import datetime +import random +try: + import heatshrink + heatshrink_exists = True +except ImportError: + heatshrink_exists = False + + +def millis(): + return time.perf_counter() * 1000 + +class TimeOut(object): + def __init__(self, milliseconds): + self.duration = milliseconds + self.reset() + + def reset(self): + self.endtime = millis() + self.duration + + def timedout(self): + return millis() > self.endtime + +class ReadTimeout(Exception): + pass +class FatalError(Exception): + pass +class SycronisationError(Exception): + pass +class PayloadOverflow(Exception): + pass +class ConnectionLost(Exception): + pass + +class Protocol(object): + device = None + baud = None + max_block_size = 0 + port = None + block_size = 0 + + packet_transit = None + packet_status = None + packet_ping = None + + errors = 0 + packet_buffer = None + simulate_errors = 0 + sync = 0 + connected = False + syncronised = False + worker_thread = None + + response_timeout = 1000 + + applications = [] + responses = deque() + + def __init__(self, device, baud, bsize, simerr, timeout): + print("pySerial Version:", serial.VERSION) + self.port = serial.Serial(device, baudrate = baud, write_timeout = 0, timeout = 1) + self.device = device + self.baud = baud + self.block_size = int(bsize) + self.simulate_errors = max(min(simerr, 1.0), 0.0); + self.connected = True + self.response_timeout = timeout + + self.register(['ok', 'rs', 'ss', 'fe'], self.process_input) + + self.worker_thread = threading.Thread(target=Protocol.receive_worker, args=(self,)) + self.worker_thread.start() + + def receive_worker(self): + while self.port.in_waiting: + self.port.reset_input_buffer() + + def dispatch(data): + for tokens, callback in self.applications: + for token in tokens: + if token == data[:len(token)]: + callback((token, data[len(token):])) + return + + def reconnect(): + print("Reconnecting..") + self.port.close() + for x in range(10): + try: + if self.connected: + self.port = serial.Serial(self.device, baudrate = self.baud, write_timeout = 0, timeout = 1) + return + else: + print("Connection closed") + return + except: + time.sleep(1) + raise ConnectionLost() + + while self.connected: + try: + data = self.port.readline().decode('utf8').rstrip() + if len(data): + #print(data) + dispatch(data) + except OSError: + reconnect() + except UnicodeDecodeError: + # dodgy client output or datastream corruption + self.port.reset_input_buffer() + + def shutdown(self): + self.connected = False + self.worker_thread.join() + self.port.close() + + def process_input(self, data): + #print(data) + self.responses.append(data) + + def register(self, tokens, callback): + self.applications.append((tokens, callback)) + + def send(self, protocol, packet_type, data = bytearray()): + self.packet_transit = self.build_packet(protocol, packet_type, data) + self.packet_status = 0 + self.transmit_attempt = 0 + + timeout = TimeOut(self.response_timeout * 20) + while self.packet_status == 0: + try: + if timeout.timedout(): + raise ConnectionLost() + self.transmit_packet(self.packet_transit) + self.await_response() + except ReadTimeout: + self.errors += 1 + #print("Packetloss detected..") + self.packet_transit = None + + def await_response(self): + timeout = TimeOut(self.response_timeout) + while not len(self.responses): + time.sleep(0.00001) + if timeout.timedout(): + raise ReadTimeout() + + while len(self.responses): + token, data = self.responses.popleft() + switch = {'ok' : self.response_ok, 'rs': self.response_resend, 'ss' : self.response_stream_sync, 'fe' : self.response_fatal_error} + switch[token](data) + + def send_ascii(self, data, send_and_forget = False): + self.packet_transit = bytearray(data, "utf8") + b'\n' + self.packet_status = 0 + self.transmit_attempt = 0 + + timeout = TimeOut(self.response_timeout * 20) + while self.packet_status == 0: + try: + if timeout.timedout(): + return + self.port.write(self.packet_transit) + if send_and_forget: + self.packet_status = 1 + else: + self.await_response_ascii() + except ReadTimeout: + self.errors += 1 + #print("Packetloss detected..") + except serial.serialutil.SerialException: + return + self.packet_transit = None + + def await_response_ascii(self): + timeout = TimeOut(self.response_timeout) + while not len(self.responses): + time.sleep(0.00001) + if timeout.timedout(): + raise ReadTimeout() + token, data = self.responses.popleft() + self.packet_status = 1 + + def corrupt_array(self, data): + rid = random.randint(0, len(data) - 1) + data[rid] ^= 0xAA + return data + + def transmit_packet(self, packet): + packet = bytearray(packet) + if(self.simulate_errors > 0 and random.random() > (1.0 - self.simulate_errors)): + if random.random() > 0.9: + #random data drop + start = random.randint(0, len(packet)) + end = start + random.randint(1, 10) + packet = packet[:start] + packet[end:] + #print("Dropping {0} bytes".format(end - start)) + else: + #random corruption + packet = self.corrupt_array(packet) + #print("Single byte corruption") + self.port.write(packet) + self.transmit_attempt += 1 + + def build_packet(self, protocol, packet_type, data = bytearray()): + PACKET_TOKEN = 0xB5AD + + if len(data) > self.max_block_size: + raise PayloadOverflow() + + packet_buffer = bytearray() + + packet_buffer += self.pack_int8(self.sync) # 8bit sync id + packet_buffer += self.pack_int4_2(protocol, packet_type) # 4 bit protocol id, 4 bit packet type + packet_buffer += self.pack_int16(len(data)) # 16bit packet length + packet_buffer += self.pack_int16(self.build_checksum(packet_buffer)) # 16bit header checksum + + if len(data): + packet_buffer += data + packet_buffer += self.pack_int16(self.build_checksum(packet_buffer)) + + packet_buffer = self.pack_int16(PACKET_TOKEN) + packet_buffer # 16bit start token, not included in checksum + return packet_buffer + + # checksum 16 fletchers + def checksum(self, cs, value): + cs_low = (((cs & 0xFF) + value) % 255); + return ((((cs >> 8) + cs_low) % 255) << 8) | cs_low; + + def build_checksum(self, buffer): + cs = 0 + for b in buffer: + cs = self.checksum(cs, b) + return cs + + def pack_int32(self, value): + return value.to_bytes(4, byteorder='little') + + def pack_int16(self, value): + return value.to_bytes(2, byteorder='little') + + def pack_int8(self, value): + return value.to_bytes(1, byteorder='little') + + def pack_int4_2(self, vh, vl): + value = ((vh & 0xF) << 4) | (vl & 0xF) + return value.to_bytes(1, byteorder='little') + + def connect(self): + print("Connecting: Switching Marlin to Binary Protocol...") + self.send_ascii("M28B1") + self.send(0, 1) + + def disconnect(self): + self.send(0, 2) + self.syncronised = False + + def response_ok(self, data): + try: + packet_id = int(data); + except ValueError: + return + if packet_id != self.sync: + raise SycronisationError() + self.sync = (self.sync + 1) % 256 + self.packet_status = 1 + + def response_resend(self, data): + packet_id = int(data); + self.errors += 1 + if not self.syncronised: + print("Retrying syncronisation") + elif packet_id != self.sync: + raise SycronisationError() + + def response_stream_sync(self, data): + sync, max_block_size, protocol_version = data.split(',') + self.sync = int(sync) + self.max_block_size = int(max_block_size) + self.block_size = self.max_block_size if self.max_block_size < self.block_size else self.block_size + self.protocol_version = protocol_version + self.packet_status = 1 + self.syncronised = True + print("Connection synced [{0}], binary protocol version {1}, {2} byte payload buffer".format(self.sync, self.protocol_version, self.max_block_size)) + + def response_fatal_error(self, data): + raise FatalError() + + +class FileTransferProtocol(object): + protocol_id = 1 + + class Packet(object): + QUERY = 0 + OPEN = 1 + CLOSE = 2 + WRITE = 3 + ABORT = 4 + + responses = deque() + def __init__(self, protocol, timeout = None): + protocol.register(['PFT:success', 'PFT:version:', 'PFT:fail', 'PFT:busy', 'PFT:ioerror', 'PTF:invalid'], self.process_input) + self.protocol = protocol + self.response_timeout = timeout or protocol.response_timeout + + def process_input(self, data): + #print(data) + self.responses.append(data) + + def await_response(self, timeout = None): + timeout = TimeOut(timeout or self.response_timeout) + while not len(self.responses): + time.sleep(0.0001) + if timeout.timedout(): + raise ReadTimeout() + + return self.responses.popleft() + + def connect(self): + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.QUERY); + + token, data = self.await_response() + if token != 'PFT:version:': + return False + + self.version, _, compression = data.split(':') + if compression != 'none': + algorithm, window, lookahead = compression.split(',') + self.compression = {'algorithm': algorithm, 'window': int(window), 'lookahead': int(lookahead)} + else: + self.compression = {'algorithm': 'none'} + + print("File Transfer version: {0}, compression: {1}".format(self.version, self.compression['algorithm'])) + + def open(self, filename, compression, dummy): + payload = b'\1' if dummy else b'\0' # dummy transfer + payload += b'\1' if compression else b'\0' # payload compression + payload += bytearray(filename, 'utf8') + b'\0'# target filename + null terminator + + timeout = TimeOut(5000) + token = None + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload); + while token != 'PFT:success' and not timeout.timedout(): + try: + token, data = self.await_response(1000) + if token == 'PFT:success': + print(filename,"opened") + return + elif token == 'PFT:busy': + print("Broken transfer detected, purging") + self.abort() + time.sleep(0.1) + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload); + timeout.reset() + elif token == 'PFT:fail': + raise Exception("Can not open file on client") + except ReadTimeout: + pass + raise ReadTimeout() + + def write(self, data): + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.WRITE, data); + + def close(self): + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.CLOSE); + token, data = self.await_response(1000) + if token == 'PFT:success': + print("File closed") + return + elif token == 'PFT:ioerror': + print("Client storage device IO error") + elif token == 'PFT:invalid': + print("No open file") + + def abort(self): + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.ABORT); + token, data = self.await_response() + if token == 'PFT:success': + print("Transfer Aborted") + + def copy(self, filename, dest_filename, compression, dummy): + self.connect() + + compression_support = heatshrink_exists and self.compression['algorithm'] == 'heatshrink' and compression + if compression and (not heatshrink_exists or not self.compression['algorithm'] == 'heatshrink'): + print("Compression not supported by client") + #compression_support = False + + data = open(filename, "rb").read() + filesize = len(data) + + self.open(dest_filename, compression_support, dummy) + + block_size = self.protocol.block_size + if compression_support: + data = heatshrink.encode(data, window_sz2=self.compression['window'], lookahead_sz2=self.compression['lookahead']) + + cratio = filesize / len(data) + + blocks = math.floor((len(data) + block_size - 1) / block_size) + kibs = 0 + dump_pctg = 0 + start_time = millis() + for i in range(blocks): + start = block_size * i + end = start + block_size + self.write(data[start:end]) + kibs = (( (i+1) * block_size) / 1024) / (millis() + 1 - start_time) * 1000 + if (i / blocks) >= dump_pctg: + print("\r{0:2.2f}% {1:4.2f}KiB/s {2} Errors: {3}".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') + dump_pctg += 0.1 + print("\r{0:2.2f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% + + self.close() + print("Transfer complete") + + +class EchoProtocol(object): + def __init__(self, protocol): + protocol.register(['echo:'], self.process_input) + self.protocol = protocol + + def process_input(self, data): + print(data) diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py new file mode 100644 index 000000000000..c7730d8f299d --- /dev/null +++ b/buildroot/share/scripts/upload.py @@ -0,0 +1,288 @@ +import argparse +import sys +import os +import time +import random +import serial + +Import("env") + +# Needed (only) for compression, but there are problems with pip install heatshrink +#try: +# import heatshrink +#except ImportError: +# # Install heatshrink +# print("Installing 'heatshrink' python module...") +# env.Execute(env.subst("$PYTHONEXE -m pip install heatshrink")) +# +# Not tested: If it's safe to install python libraries in PIO python try: +# env.Execute(env.subst("$PYTHONEXE -m pip install https://github.com/p3p/pyheatshrink/releases/download/0.3.3/pyheatshrink-pip.zip")) + +import MarlinBinaryProtocol + +# Internal debug flag +Debug = False + +#-----------------# +# Upload Callback # +#-----------------# +def Upload(source, target, env): + + #------------------# + # Marlin functions # + #------------------# + def _GetMarlinEnv(marlinEnv, feature): + if not marlinEnv: return None + return marlinEnv[feature] if feature in marlinEnv else None + + #----------------# + # Port functions # + #----------------# + def _GetUploadPort(env): + if Debug: print('Autodetecting upload port...') + env.AutodetectUploadPort(env) + port = env.subst('$UPLOAD_PORT') + if not port: + raise Exception('Error detecting the upload port.') + if Debug: print('OK') + return port + + #-------------------------# + # Simple serial functions # + #-------------------------# + def _Send(data): + if Debug: print(f'>> {data}') + strdata = bytearray(data, 'utf8') + b'\n' + port.write(strdata) + time.sleep(0.010) + + def _Recv(): + clean_responses = [] + responses = port.readlines() + for Resp in responses: + # Test: suppress invaid chars (coming from debug info) + try: + clean_response = Resp.decode('utf8').rstrip().lstrip() + clean_responses.append(clean_response) + except: + pass + if Debug: print(f'<< {clean_response}') + return clean_responses + + #------------------# + # SDCard functions # + #------------------# + def _CheckSDCard(): + if Debug: print('Checking SD card...') + _Send('M21') + Responses = _Recv() + if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): + raise Exception('Error accessing SD card') + if Debug: print('SD Card OK') + return True + + #----------------# + # File functions # + #----------------# + def _GetFirmwareFiles(UseLongFilenames): + if Debug: print('Get firmware files...') + _Send(f"M20 F{'L' if UseLongFilenames else ''}") + Responses = _Recv() + if len(Responses) < 3 or not any('file list' in r for r in Responses): + raise Exception('Error getting firmware files') + if Debug: print('OK') + return Responses + + def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): + Firmwares = [] + for FWFile in FirmwareList: + # For long filenames take the 3rd column of the firmwares list + if UseLongFilenames: + Space = 0 + Space = FWFile.find(' ') + if Space >= 0: Space = FWFile.find(' ', Space + 1) + if Space >= 0: FWFile = FWFile[Space + 1:] + if not '/' in FWFile and '.BIN' in FWFile.upper(): + Firmwares.append(FWFile[:FWFile.upper().index('.BIN') + 4]) + return Firmwares + + def _RemoveFirmwareFile(FirmwareFile): + _Send(f'M30 /{FirmwareFile}') + Responses = _Recv() + Removed = len(Responses) >= 1 and any('File deleted' in r for r in Responses) + if not Removed: + raise Exception(f"Firmware file '{FirmwareFile}' not removed") + return Removed + + + #---------------------# + # Callback Entrypoint # + #---------------------# + port = None + protocol = None + filetransfer = None + + # Get Marlin evironment vars + MarlinEnv = env['MARLIN_FEATURES'] + marlin_pioenv = _GetMarlinEnv(MarlinEnv, 'PIOENV') + marlin_motherboard = _GetMarlinEnv(MarlinEnv, 'MOTHERBOARD') + marlin_board_info_name = _GetMarlinEnv(MarlinEnv, 'BOARD_INFO_NAME') + marlin_board_custom_build_flags = _GetMarlinEnv(MarlinEnv, 'BOARD_CUSTOM_BUILD_FLAGS') + marlin_firmware_bin = _GetMarlinEnv(MarlinEnv, 'FIRMWARE_BIN') + marlin_long_filename_host_support = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_HOST_SUPPORT') is not None + marlin_longname_write = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_WRITE_SUPPORT') is not None + marlin_custom_firmware_upload = _GetMarlinEnv(MarlinEnv, 'CUSTOM_FIRMWARE_UPLOAD') is not None + marlin_short_build_version = _GetMarlinEnv(MarlinEnv, 'SHORT_BUILD_VERSION') + marlin_string_config_h_author = _GetMarlinEnv(MarlinEnv, 'STRING_CONFIG_H_AUTHOR') + + # Get firmware upload params + upload_firmware_source_name = str(source[0]) # Source firmware filename + upload_speed = env['UPLOAD_SPEED'] if 'UPLOAD_SPEED' in env else 115200 + # baud rate of serial connection + upload_port = _GetUploadPort(env) # Serial port to use + + # Set local upload params + upload_firmware_target_name = os.path.basename(upload_firmware_source_name) + # Target firmware filename + upload_timeout = 1000 # Communication timout, lossy/slow connections need higher values + upload_blocksize = 512 # Transfer block size. 512 = Autodetect + upload_compression = True # Enable compression + upload_error_ratio = 0 # Simulated corruption ratio + upload_test = False # Benchmark the serial link without storing the file + upload_reset = True # Trigger a soft reset for firmware update after the upload + + # Set local upload params based on board type to change script behavior + # "upload_delete_old_bins": delete all *.bin files in the root of SD Card + upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V24S1'] + # "upload_random_name": generate a random 8.3 firmware filename to upload + upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support + + try: + + # Start upload job + print(f"Uploading firmware '{os.path.basename(upload_firmware_target_name)}' to '{marlin_motherboard}' via '{upload_port}'") + + # Dump some debug info + if Debug: + print('Upload using:') + print('---- Marlin -----------------------------------') + print(f' PIOENV : {marlin_pioenv}') + print(f' SHORT_BUILD_VERSION : {marlin_short_build_version}') + print(f' STRING_CONFIG_H_AUTHOR : {marlin_string_config_h_author}') + print(f' MOTHERBOARD : {marlin_motherboard}') + print(f' BOARD_INFO_NAME : {marlin_board_info_name}') + print(f' CUSTOM_BUILD_FLAGS : {marlin_board_custom_build_flags}') + print(f' FIRMWARE_BIN : {marlin_firmware_bin}') + print(f' LONG_FILENAME_HOST_SUPPORT : {marlin_long_filename_host_support}') + print(f' LONG_FILENAME_WRITE_SUPPORT : {marlin_longname_write}') + print(f' CUSTOM_FIRMWARE_UPLOAD : {marlin_custom_firmware_upload}') + print('---- Upload parameters ------------------------') + print(f' Source : {upload_firmware_source_name}') + print(f' Target : {upload_firmware_target_name}') + print(f' Port : {upload_port} @ {upload_speed} baudrate') + print(f' Timeout : {upload_timeout}') + print(f' Block size : {upload_blocksize}') + print(f' Compression : {upload_compression}') + print(f' Error ratio : {upload_error_ratio}') + print(f' Test : {upload_test}') + print(f' Reset : {upload_reset}') + print('-----------------------------------------------') + + # Custom implementations based on board parameters + # Generate a new 8.3 random filename + if upload_random_filename: + upload_firmware_target_name = f"fw-{''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=5))}.BIN" + print(f"Board {marlin_motherboard}: Overriding firmware filename to '{upload_firmware_target_name}'") + + # Delete all *.bin files on the root of SD Card (if flagged) + if upload_delete_old_bins: + # CUSTOM_FIRMWARE_UPLOAD is needed for this feature + if not marlin_custom_firmware_upload: + raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") + + # Init serial port + port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) + port.reset_input_buffer() + + # Check SD card status + _CheckSDCard() + + # Get firmware files + FirmwareFiles = _GetFirmwareFiles(marlin_long_filename_host_support) + if Debug: + for FirmwareFile in FirmwareFiles: + print(f'Found: {FirmwareFile}') + + # Get all 1st level firmware files (to remove) + OldFirmwareFiles = _FilterFirmwareFiles(FirmwareFiles[1:len(FirmwareFiles)-2], marlin_long_filename_host_support) # Skip header and footers of list + if len(OldFirmwareFiles) == 0: + print('No old firmware files to delete') + else: + print(f"Remove {len(OldFirmwareFiles)} old firmware file{'s' if len(OldFirmwareFiles) != 1 else ''}:") + for OldFirmwareFile in OldFirmwareFiles: + print(f" -Removing- '{OldFirmwareFile}'...") + print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') + + # Close serial + port.close() + + # Cleanup completed + if Debug: print('Cleanup completed') + + # WARNING! The serial port must be closed here because the serial transfer that follow needs it! + + # Upload firmware file + if Debug: print(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") + protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) + #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) + protocol.connect() + filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) + filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) + protocol.disconnect() + + # Notify upload completed + protocol.send_ascii('M117 Firmware uploaded') + + # Remount SD card + print('Wait for SD card release...') + time.sleep(1) + print('Remount SD card') + protocol.send_ascii('M21') + + # Trigger firmware update + if upload_reset: + print('Trigger firmware update...') + protocol.send_ascii('M997', True) + + protocol.shutdown() + print('Firmware update completed') + + except KeyboardInterrupt: + if port: port.close() + if filetransfer: filetransfer.abort() + if protocol: protocol.shutdown() + raise + + except serial.SerialException as se: + if port: port.close() + print(f'Serial excepion: {se}') + raise Exception(se) + + except MarlinBinaryProtocol.FatalError: + if port: port.close() + if protocol: protocol.shutdown() + print('Too many retries, Abort') + raise + + except: + if port: port.close() + if protocol: protocol.shutdown() + print('Firmware not updated') + raise + +# Attach custom upload callback +env.Replace(UPLOADCMD=Upload) diff --git a/buildroot/share/vscode/MarlinFirmware.code-workspace b/buildroot/share/vscode/MarlinFirmware.code-workspace new file mode 100644 index 000000000000..bd433b07f0e2 --- /dev/null +++ b/buildroot/share/vscode/MarlinFirmware.code-workspace @@ -0,0 +1,4 @@ +{ + "folders": [ { "path": "../../.." } ], + "extensions": { "recommendations": [ "marlinfirmware.auto-build" ] } +} diff --git a/buildroot/share/vscode/auto_build.py b/buildroot/share/vscode/auto_build.py index ac8432729f0a..5bd769478e0e 100644 --- a/buildroot/share/vscode/auto_build.py +++ b/buildroot/share/vscode/auto_build.py @@ -72,7 +72,7 @@ from __future__ import print_function from __future__ import division -import sys,os +import sys,os,re pwd = os.getcwd() # make sure we're executing from the correct directory level pwd = pwd.replace('\\', '/') @@ -123,7 +123,7 @@ # ########################################################################################## -def get_answer(board_name, cpu_label_txt, cpu_a_txt, cpu_b_txt): +def get_answer(board_name, question_txt, options, default_value=1): if python_ver == 2: import Tkinter as tk @@ -151,10 +151,10 @@ def disable_event(): root_get_answer.protocol("WM_DELETE_WINDOW", disable_event) root_get_answer.resizable(False, False) - root_get_answer.radio_state = 1 # declare variables used by TK and enable + root_get_answer.radio_state = default_value # declare variables used by TK and enable global get_answer_val - get_answer_val = 2 # return get_answer_val, set default to match radio_state default + get_answer_val = default_value # return get_answer_val, set default to match radio_state default radio_state = tk.IntVar() radio_state.set(get_answer_val) @@ -162,35 +162,27 @@ def disable_event(): l1 = tk.Label(text=board_name, fg="light green", bg="dark green", font="default 14 bold").grid(row=0, columnspan=2, sticky='EW', ipadx=2, ipady=2) - l2 = tk.Label(text=cpu_label_txt).grid(row=1, pady=4, columnspan=2, sticky='EW') - - b4 = tk.Radiobutton( - text=cpu_a_txt, - fg="black", - bg="lightgray", - relief=tk.SUNKEN, - selectcolor="green", - variable=radio_state, - value=1, - indicatoron=0, - command=CPU_exit_3 - ).grid(row=2, pady=1, ipady=2, ipadx=10, columnspan=2) - - b5 = tk.Radiobutton( - text=cpu_b_txt, - fg="black", - bg="lightgray", - relief=tk.SUNKEN, - selectcolor="green", - variable=radio_state, - value=2, - indicatoron=0, - command=CPU_exit_3 - ).grid(row=3, pady=1, ipady=2, ipadx=10, columnspan=2) # use same variable but inverted so they will track - - b6 = tk.Button(text="Cancel", fg="red", command=kill_session).grid(row=4, column=0, padx=4, pady=4, ipadx=2, ipady=2) - - b7 = tk.Button(text="Continue", fg="green", command=got_answer).grid(row=4, column=1, padx=4, pady=4, ipadx=2, ipady=2) + l2 = tk.Label(text=question_txt).grid(row=1, pady=4, columnspan=2, sticky='EW') + + buttons = [] + + for index, val in enumerate(options): + buttons.append( + tk.Radiobutton( + text=val, + fg="black", + bg="lightgray", + relief=tk.SUNKEN, + selectcolor="green", + variable=radio_state, + value=index + 1, + indicatoron=0, + command=CPU_exit_3 + ).grid(row=index + 2, pady=1, ipady=2, ipadx=10, columnspan=2)) + + b6 = tk.Button(text="Cancel", fg="red", command=kill_session).grid(row=(2 + len(options)), column=0, padx=4, pady=4, ipadx=2, ipady=2) + + b7 = tk.Button(text="Continue", fg="green", command=got_answer).grid(row=(2 + len(options)), column=1, padx=4, pady=4, ipadx=2, ipady=2) def got_answer_(): root_get_answer.destroy() @@ -485,6 +477,11 @@ def get_env_from_line(line, start_position): return env, next_position +def invalid_board(): + print('ERROR - invalid board') + print(board_name) + raise SystemExit(0) # quit if unable to find board + # scan pins.h for board name and return the environment(s) found def get_starting_env(board_name_full, version): # get environment starting point @@ -496,48 +493,26 @@ def get_starting_env(board_name_full, version): with open(path, 'r') as myfile: pins_h = myfile.read() - env_A = '' - env_B = '' - env_C = '' - board_name = board_name_full[6:] # only use the part after "BOARD_" since we're searching the pins.h file pins_h = pins_h.split('\n') - environment = '' - board_line = '' - cpu_A = '' - cpu_B = '' - i = 0 list_start_found = False - for lines in pins_h: - i = i + 1 # i is always one ahead of the index into pins_h - if 0 < lines.find("Unknown MOTHERBOARD value set in Configuration.h"): - break # no more - if 0 < lines.find('1280'): + possible_envs = None + for i, line in enumerate(pins_h): + if 0 < line.find("Unknown MOTHERBOARD value set in Configuration.h"): + invalid_board(); + if list_start_found == False and 0 < line.find('1280'): list_start_found = True - if list_start_found == False: # skip lines until find start of CPU list + elif list_start_found == False: # skip lines until find start of CPU list continue - board = lines.find(board_name) - comment_start = lines.find('// ') - cpu_A_loc = comment_start - cpu_B_loc = 0 - if board > 0: # need to look at the next line for environment info - cpu_line = pins_h[i] - comment_start = cpu_line.find('// ') - env_A, next_position = get_env_from_line(cpu_line, comment_start) # get name of environment & start of search for next - env_B, next_position = get_env_from_line(cpu_line, next_position) # get next environment, if it exists - env_C, next_position = get_env_from_line(cpu_line, next_position) # get next environment, if it exists - break - return env_A, env_B, env_C - -# Scan input string for CPUs that users may need to select from -# return: CPU name -def get_CPU_name(environment): - CPU_list = ('1280', '2560', '644', '1284', 'LPC1768', 'DUE') - CPU_name = '' - for CPU in CPU_list: - if 0 < environment.find(CPU): - return CPU + # Use a regex to find the board. Make sure it is surrounded by separators so the full boardname + # will be matched, even if multiple exist in a single MB macro. This avoids problems with boards + # such as MALYAN_M200 and MALYAN_M200_V2 where one board is a substring of the other. + if re.search(r'MB.*[\(, ]' + board_name + r'[, \)]', line): + # need to look at the next line for environment info + possible_envs = re.findall(r'env:([^ ]+)', pins_h[i + 1]) + break + return possible_envs # get environment to be used for the build @@ -549,71 +524,81 @@ def no_environment(): print(board_name) raise SystemExit(0) # no environment so quit - def invalid_board(): - print('ERROR - invalid board') - print(board_name) - raise SystemExit(0) # quit if unable to find board + possible_envs = get_starting_env(board_name, ver_Marlin) - CPU_question = (('1280', '2560', '1280 or 2560 CPU?'), ('644', '1284', '644 or 1284 CPU?')) + if not possible_envs: + no_environment() - if 0 < board_name.find('MELZI'): - get_answer( - board_name, " Which flavor of Melzi? ", "Melzi (Optiboot bootloader)", "Melzi " - ) + # Proceed to ask questions based on the available environments to filter down to a smaller list. + # If more then one remains after this filtering the user will be prompted to choose between + # all remaining options. + + # Filter selection based on CPU choice + CPU_questions = [ + {'options':['1280', '2560'], 'text':'1280 or 2560 CPU?', 'default':2}, + {'options':['644', '1284'], 'text':'644 or 1284 CPU?', 'default':2}, + {'options':['STM32F103RC', 'STM32F103RE'], 'text':'MCU Type?', 'default':1}] + + for question in CPU_questions: + if any(question['options'][0] in env for env in possible_envs) and any(question['options'][1] in env for env in possible_envs): + get_answer(board_name, question['text'], [question['options'][0], question['options'][1]], question['default']) + possible_envs = [env for env in possible_envs if question['options'][get_answer_val - 1] in env] + + # Choose which STM32 framework to use, if both are available + if [env for env in possible_envs if '_maple' in env] and [env for env in possible_envs if '_maple' not in env]: + get_answer(board_name, 'Which STM32 Framework should be used?', ['ST STM32 (Preferred)', 'Maple (Deprecated)']) if 1 == get_answer_val: - target_env = 'melzi_optiboot' + possible_envs = [env for env in possible_envs if '_maple' not in env] else: - target_env = 'melzi' - else: - env_A, env_B, env_C = get_starting_env(board_name, ver_Marlin) + possible_envs = [env for env in possible_envs if '_maple' in env] - if env_A == '': - no_environment() - if env_B == '': - return env_A # only one environment so finished + # Both USB and non-USB STM32 options exist, filter based on these + if any('STM32F103R' in env for env in possible_envs) and any('_USB' in env for env in possible_envs) and any('_USB' not in env for env in possible_envs): + get_answer(board_name, 'USB Support?', ['USB', 'No USB']) + if 1 == get_answer_val: + possible_envs = [env for env in possible_envs if '_USB' in env] + else: + possible_envs = [env for env in possible_envs if '_USB' not in env] - CPU_A = get_CPU_name(env_A) - CPU_B = get_CPU_name(env_B) + if not possible_envs: + no_environment() + if len(possible_envs) == 1: + return possible_envs[0] # only one environment so finished - for item in CPU_question: - if CPU_A == item[0]: - get_answer(board_name, item[2], item[0], item[1]) - if 2 == get_answer_val: - target_env = env_B - else: - target_env = env_A - return target_env + target_env = None - if env_A == 'LPC1768': - if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'LPC1768_debug_and_upload'): - target_env = 'LPC1768_debug_and_upload' - else: - target_env = 'LPC1768' - elif env_A == 'DUE': - target_env = 'DUE' - if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'DUE_debug'): - target_env = 'DUE_debug' - elif env_B == 'DUE_USB': - get_answer(board_name, 'DUE Download Port?', '(Native) USB port', 'Programming port') - if 1 == get_answer_val: - target_env = 'DUE_USB' - else: - target_env = 'DUE' - elif env_A == 'STM32F103RC_btt' or env_A == 'STM32F103RE_btt': - if env_A == 'STM32F103RE_btt': - get_answer(board_name, 'MCU Type?', 'STM32F103RC', 'STM32F103RE') - if 1 == get_answer_val: - env_A = 'STM32F103RC_btt' - target_env = env_A - if env_A == 'STM32F103RC_btt': - get_answer(board_name, 'RCT6 Flash Size?', '512K', '256K') - if 1 == get_answer_val: - target_env += '_512K' - get_answer(board_name, 'USB Support?', 'USB', 'No USB') - if 1 == get_answer_val: - target_env += '_USB' + # A few environments require special behavior + if 'LPC1768' in possible_envs: + if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'LPC1768_debug_and_upload'): + target_env = 'LPC1768_debug_and_upload' else: - invalid_board() + target_env = 'LPC1768' + elif 'DUE' in possible_envs: + target_env = 'DUE' + if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'DUE_debug'): + target_env = 'DUE_debug' + elif 'DUE_USB' in possible_envs: + get_answer(board_name, 'DUE Download Port?', ['(Native) USB port', 'Programming port']) + if 1 == get_answer_val: + target_env = 'DUE_USB' + else: + target_env = 'DUE' + else: + options = possible_envs + # Perform some substitutions for environment names which follow a consistent + # naming pattern and are very commonly used. This is fragile code, and replacements + # should only be made here for stable environments unlikely to change often. + for i, option in enumerate(options): + if 'melzi' in option: + options[i] = 'Melzi' + elif 'sanguino1284p' in option: + options[i] = 'sanguino1284p' + if 'optiboot' in option: + options[i] = options[i] + ' (Optiboot Bootloader)' + if 'optimized' in option: + options[i] = options[i] + ' (Optimized for Size)' + get_answer(board_name, 'Which environment?', options) + target_env = possible_envs[get_answer_val - 1] if build_type == 'traceback' and target_env != 'LPC1768_debug_and_upload' and target_env != 'DUE_debug' and Marlin_ver == 2: print("ERROR - this board isn't setup for traceback") diff --git a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive index 197ece5dfd66..34bf77be27a4 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive +++ b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive @@ -10,8 +10,8 @@ restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT 3 \ EXTRUDERS 8 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 TEMP_SENSOR_5 1 TEMP_SENSOR_6 1 TEMP_SENSOR_7 1 opt_enable SDSUPPORT USB_FLASH_DRIVE_SUPPORT USE_OTG_USB_HOST \ - REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH NEOPIXEL_LED Z_SAFE_HOMING \ - FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE + REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH LEVEL_BED_CORNERS LEVEL_CORNERS_USE_PROBE \ + NEOPIXEL_LED Z_SAFE_HOMING FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE # Not necessary to enable auto-fan for all extruders to hit problematic code paths opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ diff --git a/buildroot/tests/DUE b/buildroot/tests/DUE index 37678501e431..9b968cbd8d4d 100755 --- a/buildroot/tests/DUE +++ b/buildroot/tests/DUE @@ -17,7 +17,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \ ASSISTED_TRAMMING REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \ EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \ - BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ + BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN \ NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \ NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ @@ -37,7 +37,7 @@ exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), ExtUI, S-Curve, many options restore_configs opt_set MOTHERBOARD BOARD_RADDS NUM_Z_STEPPER_DRIVERS 3 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \ - Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS Z_SAFE_HOMING + Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_STEPPER_XY Z_SAFE_HOMING pins_set ramps/RAMPS X_MAX_PIN -1 pins_set ramps/RAMPS Y_MAX_PIN -1 exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3" diff --git a/buildroot/tests/FYSETC_S6 b/buildroot/tests/FYSETC_S6 index 4794e11354d4..6d67800d77ec 100755 --- a/buildroot/tests/FYSETC_S6 +++ b/buildroot/tests/FYSETC_S6 @@ -13,5 +13,13 @@ opt_enable MEATPACK_ON_SERIAL_PORT_1 opt_set Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2130 exec_test $1 $2 "FYSETC S6 Example" "$3" +# +# Build with the default configurations with FYSETC TFT81050 +# +restore_configs +opt_set MOTHERBOARD BOARD_FYSETC_S6_V2_0 SERIAL_PORT 1 +opt_enable TOUCH_UI_FTDI_EVE LCD_FYSETC_TFT81050 S6_TFT_PINMAP +exec_test $1 $2 "FYSETC S6 2 with LCD FYSETC TFT81050" "$3" + # cleanup restore_configs diff --git a/buildroot/tests/LPC1768 b/buildroot/tests/LPC1768 index 92ba286693e8..9fb7479d9921 100755 --- a/buildroot/tests/LPC1768 +++ b/buildroot/tests/LPC1768 @@ -14,8 +14,8 @@ set -e #exec_test $1 $2 "Default Configuration" "$3" restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \ - NEOPIXEL_TYPE NEO_GRB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24 +opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \ + NEOPIXEL_TYPE NEO_RGB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24 opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED E_DUAL_STEPPER_DRIVERS \ NEOPIXEL_LED NEOPIXEL_IS_SEQUENTIAL NEOPIXEL_STARTUP_TEST NEOPIXEL_BKGD_INDEX_FIRST NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_COLOR NEOPIXEL_BKGD_ALWAYS_ON exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3" diff --git a/buildroot/tests/STM32F103RE_btt_USB b/buildroot/tests/STM32F103RE_btt_USB index c63a90e43681..7b264ea28312 100755 --- a/buildroot/tests/STM32F103RE_btt_USB +++ b/buildroot/tests/STM32F103RE_btt_USB @@ -15,7 +15,7 @@ exec_test $1 $2 "BigTreeTech SKR E3 DIP v1.0 - Basic Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_CR6 SERIAL_PORT -1 SERIAL_PORT_2 2 TEMP_SENSOR_BED 1 -opt_enable CR10_STOCKDISPLAY \ +opt_enable CR10_STOCKDISPLAY FAN_SOFT_PWM \ NOZZLE_AS_PROBE Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN Z_SAFE_HOMING \ PROBE_ACTIVATION_SWITCH PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE \ PROBING_HEATERS_OFF PREHEAT_BEFORE_PROBING diff --git a/buildroot/tests/STM32F103RET6_creality b/buildroot/tests/STM32F103RE_creality similarity index 78% rename from buildroot/tests/STM32F103RET6_creality rename to buildroot/tests/STM32F103RE_creality index ca7573cf16c3..6440c5679224 100755 --- a/buildroot/tests/STM32F103RET6_creality +++ b/buildroot/tests/STM32F103RE_creality @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Build tests for STM32F103RET6_creality +# Build tests for STM32F103RE_creality # # exit on first failure @@ -15,8 +15,9 @@ exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3" 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" +opt_enable BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING BAUD_RATE_GCODE \ + DWIN_LCD_PROUI SOUND_MENU_ITEM PRINTCOUNTER +exec_test $1 $2 "Ender 3 v2 with ProUI" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD @@ -30,7 +31,7 @@ exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3" restore_configs opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1 opt_disable NOZZLE_TO_PROBE_OFFSET -opt_enable NOZZLE_AS_PROBE Z_SAFE_HOMING Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN \ +opt_enable NOZZLE_AS_PROBE Z_SAFE_HOMING Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN FAN_SOFT_PWM \ PROBE_ACTIVATION_SWITCH PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE exec_test $1 $2 "Creality V4.5.2 PROBE_ACTIVATION_SWITCH, Probe Tare" "$3" diff --git a/buildroot/tests/mega1280 b/buildroot/tests/mega1280 index cae747017f1c..a7f25953acd0 100755 --- a/buildroot/tests/mega1280 +++ b/buildroot/tests/mega1280 @@ -27,6 +27,12 @@ opt_enable SPINDLE_FEATURE ULTIMAKERCONTROLLER LCD_BED_LEVELING \ EXTERNAL_CLOSED_LOOP_CONTROLLER POWER_MONITOR_CURRENT POWER_MONITOR_VOLTAGE exec_test $1 $2 "Spindle, MESH_BED_LEVELING, closed loop, Power Monitor, and LCD" "$3" +# +# ...and without PWM +# +opt_disable SPINDLE_LASER_USE_PWM +exec_test $1 $2 "(No PWM)" "$3" + # # Test DUAL_X_CARRIAGE # diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index bf3290b9d02c..5ae9a2dbcf0b 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -35,7 +35,7 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE jp_kana DEFAULT_EJERK 10 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 5 TEMP_SENSOR_3 20 TEMP_SENSOR_4 1000 TEMP_SENSOR_BED 1 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \ - SDSUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \ + SDSUPPORT LONG_FILENAME_WRITE_SUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \ Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \ diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index b7136e445ed6..e696dce96ec3 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -14,7 +14,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ EXTRUDERS 2 TEMP_SENSOR_0 -2 TEMP_SENSOR_1 1 TEMP_SENSOR_BED 2 \ TEMP_SENSOR_PROBE 1 TEMP_PROBE_PIN 12 \ TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 3 HEATER_CHAMBER_PIN 45 \ - GRID_MAX_POINTS_X 16 \ + GRID_MAX_POINTS_X 16 AUTO_POWER_E_TEMP 80 \ 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 \ @@ -32,7 +32,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ - PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND AUTO_POWER_CONTROL \ + PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND POWER_OFF_WAIT_FOR_COOLDOWN \ POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \ SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL @@ -91,7 +91,7 @@ opt_set MOTHERBOARD BOARD_MINIRAMBO \ I2C_SLAVE_ADDRESS 63 opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER \ SDSUPPORT PCA9632 SOUND_MENU_ITEM GCODE_REPEAT_MARKERS \ - AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY LCD_BED_LEVELING G26_MESH_VALIDATION MESH_EDIT_MENU \ + AUTO_BED_LEVELING_LINEAR PROBE_MANUALLY LCD_BED_LEVELING \ LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT EXPERIMENTAL_I2CBUS M100_FREE_MEMORY_WATCHER \ NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE \ @@ -99,7 +99,7 @@ opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CO PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 M114_DETAIL opt_add M100_FREE_MEMORY_DUMPER opt_add M100_FREE_MEMORY_CORRUPTOR -exec_test $1 $2 "MINIRAMBO | RRDGFSC | ABL Bilinear Manual | M100 | PWM_MOTOR_CURRENT | M600..." "$3" +exec_test $1 $2 "MINIRAMBO | RRDGFSC | ABL Linear Manual | M100 | PWM_MOTOR_CURRENT | M600..." "$3" # # Test many less common options @@ -115,10 +115,11 @@ opt_set MOTHERBOARD BOARD_RAMBO \ FAN_MIN_PWM 50 FAN_KICKSTART_TIME 100 \ XY_FREQUENCY_LIMIT 15 opt_enable COREYX USE_XMAX_PLUG MIXING_EXTRUDER GRADIENT_MIX \ - BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY FILAMENT_WIDTH_SENSOR \ + BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER MENU_ADDAUTOSTART SDSUPPORT SDCARD_SORT_ALPHA \ ENDSTOP_NOISE_THRESHOLD FAN_SOFT_PWM \ - FIX_MOUNTED_PROBE PROBING_ESTEPPERS_OFF AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE PROBE_OFFSET_WIZARD \ + FIX_MOUNTED_PROBE PROBING_ESTEPPERS_OFF PROBE_OFFSET_WIZARD \ + AUTO_BED_LEVELING_BILINEAR X_AXIS_TWIST_COMPENSATION MESH_EDIT_MENU DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION \ Z_SAFE_HOMING SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER \ SD_ABORT_ON_ENDSTOP_HIT HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT HOST_PAUSE_M76 ADVANCED_OK M114_DETAIL \ VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS EXTRA_FAN_SPEED FWRETRACT \ diff --git a/buildroot/tests/rumba32 b/buildroot/tests/rumba32 index f26af33610c6..833769d0b9ba 100755 --- a/buildroot/tests/rumba32 +++ b/buildroot/tests/rumba32 @@ -11,7 +11,7 @@ restore_configs opt_set MOTHERBOARD BOARD_RUMBA32_V1_0 SERIAL_PORT -1 \ TEMP_SENSOR_BED 1 X_DRIVER_TYPE TMC2130 opt_disable PIDTEMP -opt_enable PIDTEMPBED +opt_enable PIDTEMPBED FAN_SOFT_PWM opt_disable THERMAL_PROTECTION_BED exec_test $1 $2 "RUMBA32 V1.0 with TMC2130, PID Bed, and bed thermal protection disabled" "$3" @@ -19,12 +19,13 @@ exec_test $1 $2 "RUMBA32 V1.0 with TMC2130, PID Bed, and bed thermal protection restore_configs opt_set MOTHERBOARD BOARD_RUMBA32_V1_1 SERIAL_PORT -1 \ TEMP_SENSOR_BED 1 X_DRIVER_TYPE TMC2130 Y_DRIVER_TYPE TMC2208 -opt_enable PIDTEMPBED EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +opt_enable PIDTEMPBED FAN_SOFT_PWM EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER exec_test $1 $2 "RUMBA32 V1.1 with TMC2130, TMC2208, PID Bed, EEPROM settings, and graphic LCD controller" "$3" # Build examples restore_configs opt_set MOTHERBOARD BOARD_RUMBA32_MKS SERIAL_PORT -1 X_DRIVER_TYPE TMC2130 Y_DRIVER_TYPE TMC2208 +opt_enable FAN_SOFT_PWM exec_test $1 $2 "RUMBA32 MKS Default Config with Mixed TMC Drivers" "$3" # cleanup diff --git a/buildroot/tests/teensy31 b/buildroot/tests/teensy31 index 10dde2be99ad..7465a67fdde1 100755 --- a/buildroot/tests/teensy31 +++ b/buildroot/tests/teensy31 @@ -14,7 +14,7 @@ exec_test $1 $2 "Teensy3.1 with default config" "$3" # Zero endstops, as with a CNC # restore_configs -opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_set MOTHERBOARD BOARD_TEENSY31_32 X_HOME_DIR 0 Y_HOME_DIR 0 Z_HOME_DIR 0 opt_disable USE_XMIN_PLUG USE_YMIN_PLUG USE_ZMIN_PLUG exec_test $1 $2 "Teensy3.1 with Zero Endstops" "$3" diff --git a/buildroot/web-ui/data/www/webmarlin-class.js b/buildroot/web-ui/data/www/webmarlin-class.js index 393fd88eef26..2cfc4cbfba6f 100644 --- a/buildroot/web-ui/data/www/webmarlin-class.js +++ b/buildroot/web-ui/data/www/webmarlin-class.js @@ -349,18 +349,18 @@ class jsLog { var wmGCommands = { CustomCmd : new wmGCommandItem('',null,null,'Custom command'), - MoveFw : new wmGCommandItem('G1','Y{0}',10,'Move forward on Y axis'), - MoveBw : new wmGCommandItem('G1','Y-{0}',10,'Move backward on Y axis'), - MoveSx : new wmGCommandItem('G1','X{0}',10,'Move left on X axis'), - MoveDx : new wmGCommandItem('G1','X-{0}',10,'Move right on X axis'), - MoveUp : new wmGCommandItem('G1','Z{0}',10,'Move up on Z axis'), - MoveDw : new wmGCommandItem('G1','Z-{0}',10,'Move down on Z axis'), + MoveFw : new wmGCommandItem('G1','Y{0}',10,'Move Y forward'), + MoveBw : new wmGCommandItem('G1','Y-{0}',10,'Move Y backward'), + MoveSx : new wmGCommandItem('G1','X{0}',10,'Move X left'), + MoveDx : new wmGCommandItem('G1','X-{0}',10,'Move X right'), + MoveUp : new wmGCommandItem('G1','Z{0}',10,'Move Z up'), + MoveDw : new wmGCommandItem('G1','Z-{0}',10,'Move Z down'), FillRetrive : new wmGCommandItem('G10',null,null,'Retract filament'), FillExtrude : new wmGCommandItem('GYYYY',null,null,'Extrude filament'), - MoveHome : new wmGCommandItem('G28',null,null,'Go home on all axis'), - MoveHomeX : new wmGCommandItem('G28','X',null,'Go home on X axis'), - MoveHomeY : new wmGCommandItem('G28','Y',null,'Go home on Y axis'), - MoveHomeZ : new wmGCommandItem('G28','Z',null,'Go home on Z axis'), + MoveHome : new wmGCommandItem('G28',null,null,'Home all axes'), + MoveHomeX : new wmGCommandItem('G28','X',null,'Home X axis'), + MoveHomeY : new wmGCommandItem('G28','Y',null,'Home Y axis'), + MoveHomeZ : new wmGCommandItem('G28','Z',null,'Home Z axis'), StepEnable : new wmGCommandItem('M17','{0}','E X Y Z','Enable stepper'), StepEnableAll : new wmGCommandItem('M17',null,null,'Enable all steppers'), StepDisable : new wmGCommandItem('M18','{0}','E X Y Z','Disable stepper'), diff --git a/docs/ConfigEmbedding.md b/docs/ConfigEmbedding.md new file mode 100644 index 000000000000..ed4ea39eda09 --- /dev/null +++ b/docs/ConfigEmbedding.md @@ -0,0 +1,19 @@ +# Configuration Embedding + +Starting with version 2.0.9.3, Marlin automatically extracts the configuration used to generate the firmware and stores it in the firmware binary. This is enabled by defining `CONFIGURATION_EMBEDDING` in `Configuration_adv.h`. + +## How it's done +To create the embedded configuration, we do a compiler pass to process the Configuration files and extract all active options. The active options are parsed into key/value pairs, serialized to JSON format, and stored in a file called `marlin_config.json`, which also includes specific build information (like the git revision, the build date, and some version information. The JSON file is then compressed in a ZIP archive called `.pio/build/mc.zip` which is converted into a C array and stored in a C++ file called `mc.h` which is included in the build. + +## Extracting configurations from a Marlin binary +To get the configuration out of a binary firmware, you'll need a non-write-protected SD card inserted into the printer while running the firmware. +Send the command `M503 C` to write the file `mc.zip` to the SD card. Copy the file to your computer, ideally in the same folder as the Marlin repository. + +Run the following commands to extract and apply the configuration: +``` +$ git checkout -f +$ unzip mc.zip +$ python buildroot/share/PlatformIO/scripts/mc-apply.py +``` + +This will attempt to update the configuration files to match the settings used for the original build. It will also dump the git reference used to build the code (which may be accessible if the firmware was built from the main repository. As a fallback it also includes the `STRING_DISTRIBUTION_DATE` which is unlikely to be modified in a fork). diff --git a/ini/avr.ini b/ini/avr.ini index e4d64de712a1..b13596afe119 100644 --- a/ini/avr.ini +++ b/ini/avr.ini @@ -13,6 +13,7 @@ # AVR (8-bit) Common Environment values # [common_avr8] +platform = atmelavr@~3.4 build_flags = ${common.build_flags} -Wl,--relax board_build.f_cpu = 16000000L src_filter = ${common.default_src_filter} + @@ -21,7 +22,6 @@ src_filter = ${common.default_src_filter} + # ATmega2560 # [env:mega2560] -platform = atmelavr extends = common_avr8 board = megaatmega2560 @@ -33,7 +33,6 @@ board = megaatmega2560 # BOARD_EINSTART_S # [env:mega2560ext] -platform = atmelavr extends = env:mega2560 board_build.variant = MARLIN_MEGA_EXTENDED extra_scripts = ${common.extra_scripts} @@ -43,7 +42,6 @@ extra_scripts = ${common.extra_scripts} # ATmega1280 # [env:mega1280] -platform = atmelavr extends = common_avr8 board = megaatmega1280 @@ -61,7 +59,6 @@ build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide # MightyBoard ATmega1280 # [env:MightyBoard1280] -platform = atmelavr extends = mega_extended_optimized board = megaatmega1280 @@ -69,7 +66,6 @@ board = megaatmega1280 # MightyBoard ATmega2560 # [env:MightyBoard2560] -platform = atmelavr extends = mega_extended_optimized board = megaatmega2560 @@ -77,7 +73,6 @@ board = megaatmega2560 # RAMBo # [env:rambo] -platform = atmelavr extends = common_avr8 board = reprap_rambo @@ -85,7 +80,6 @@ board = reprap_rambo # FYSETC F6 V1.3 / V1.4 # [env:FYSETC_F6] -platform = atmelavr extends = common_avr8 board = fysetc_f6_13 @@ -93,7 +87,6 @@ board = fysetc_f6_13 # Sanguinololu (ATmega644p) # [env:sanguino644p] -platform = atmelavr extends = common_avr8 board = sanguino_atmega644p @@ -101,19 +94,10 @@ board = sanguino_atmega644p # Sanguinololu (ATmega1284p) # [env:sanguino1284p] -platform = atmelavr extends = common_avr8 board = sanguino_atmega1284p board_upload.maximum_size = 126976 -# -# Melzi and clones (ATmega1284p) -# -[env:melzi] -platform = atmelavr -extends = env:sanguino1284p -upload_speed = 57600 - # # Sanguinololu (ATmega1284p stock bootloader with tuned flags) # @@ -122,22 +106,24 @@ upload_speed = 57600 build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues [env:sanguino1284p_optimized] -platform = atmelavr -extends = env:melzi +extends = env:sanguino1284p build_flags = ${tuned_1284p.build_flags} # -# Melzi and clones (alias for sanguino1284p_optimized) +# Melzi and clones (ATmega1284p) # +[env:melzi] +extends = env:sanguino1284p +upload_speed = 57600 + [env:melzi_optimized] -platform = atmelavr -extends = env:sanguino1284p_optimized +extends = env:sanguino1284p_optimized +upload_speed = 57600 # # Melzi and clones (Optiboot bootloader) # [env:melzi_optiboot] -platform = atmelavr extends = common_avr8 board = sanguino_atmega1284p upload_speed = 115200 @@ -147,29 +133,5 @@ board_upload.maximum_size = 130048 # Melzi and clones (Zonestar Melzi2 with tuned flags) # [env:melzi_optiboot_optimized] -platform = atmelavr extends = env:melzi_optiboot build_flags = ${tuned_1284p.build_flags} - -# -# AT90USB1286 boards using CDC bootloader -# - BRAINWAVE -# - BRAINWAVE_PRO -# - SAV_MKI -# - TEENSYLU -# -[env:at90usb1286_cdc] -platform = teensy -extends = common_avr8 -board = marlin_at90usb1286 -lib_ignore = ${env:common_avr8.lib_ignore}, Teensy_ADC, NativeEthernet - -# -# AT90USB1286 boards using DFU bootloader -# - Printrboard -# - Printrboard Rev.F -# - ? 5DPRINT ? -# -[env:at90usb1286_dfu] -platform = teensy -extends = env:at90usb1286_cdc diff --git a/ini/due.ini b/ini/due.ini index 9123af8cdc88..28b68383074d 100644 --- a/ini/due.ini +++ b/ini/due.ini @@ -21,7 +21,6 @@ board = due src_filter = ${common.default_src_filter} + + [env:DUE_USB] -platform = atmelsam extends = env:DUE board = dueUSB @@ -29,7 +28,6 @@ board = dueUSB # Archim SAM # [common_DUE_archim] -platform = atmelsam extends = env:DUE board = marlin_archim build_flags = ${common.build_flags} @@ -39,5 +37,4 @@ extra_scripts = ${common.extra_scripts} Marlin/src/HAL/DUE/upload_extra_script.py [env:DUE_archim] -platform = ${common_DUE_archim.platform} extends = common_DUE_archim diff --git a/ini/esp32.ini b/ini/esp32.ini index 9c0c44db67b9..4ac6b96f5c3d 100644 --- a/ini/esp32.ini +++ b/ini/esp32.ini @@ -24,12 +24,10 @@ monitor_speed = 250000 #board_build.flash_mode = qio [env:FYSETC_E4] -platform = espressif32@2.1.0 extends = env:esp32 board_build.partitions = default_16MB.csv [env:PANDA] -platform = espressif32@2.1.0 extends = env:esp32 build_flags = ${env:esp32.build_flags} -DUSE_ESP32_EXIO -DUSE_ESP32_TASK_WDT lib_deps = ${common.lib_deps} @@ -37,3 +35,7 @@ lib_deps = ${common.lib_deps} board_build.partitions = Marlin/src/HAL/ESP32/esp32.csv upload_speed = 115200 monitor_speed = 115200 + +[env:mks_tinybee] +extends = env:esp32 +board_build.partitions = default_8MB.csv diff --git a/ini/features.ini b/ini/features.ini index 4c146512989f..9150ff54516b 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -18,13 +18,14 @@ POSTMORTEM_DEBUGGING = src_filter=+ + + + + + src_filter=+ + + + + +HAS_T(RINAMIC_CONFIG|MC_SPI) = src_filter=+ HAS_STEALTHCHOP = src_filter=+ SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster src_filter=+ HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip - src_filter=+ + src_filter=+ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + + LIB_INTERNAL_MAX31865 = src_filter=+ @@ -34,7 +35,7 @@ I2C_AMMETER = peterus/INA226Lib@1.1.2 USES_LIQUIDCRYSTAL = LiquidCrystal=https://github.com/MarlinFirmware/New-LiquidCrystal/archive/1.5.1.zip USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 -HAS_WIRED_LCD = src_filter=+ +HAS_LCDPRINT = src_filter=+ HAS_MARLINUI_HD44780 = src_filter=+ HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.5.0 src_filter=+ @@ -46,13 +47,13 @@ SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https:/ SPI_EEPROM = src_filter=+ HAS_DWIN_E3V2|IS_DWIN_MARLINUI = src_filter=+ DWIN_CREALITY_LCD = src_filter=+ -DWIN_CREALITY_LCD_ENHANCED = src_filter=+ +DWIN_LCD_PROUI = src_filter=+ DWIN_CREALITY_LCD_JYERSUI = src_filter=+ IS_DWIN_MARLINUI = src_filter=+ HAS_GRAPHICAL_TFT = src_filter=+ IS_TFTGLCD_PANEL = src_filter=+ HAS_TOUCH_BUTTONS = src_filter=+ -HAS_LCD_MENU = src_filter=+ +HAS_MARLINUI_MENU = src_filter=+ HAS_GAMES = src_filter=+ MARLIN_BRICKOUT = src_filter=+ MARLIN_INVADERS = src_filter=+ @@ -94,8 +95,10 @@ NEXTION_TFT = src_filter=+ USE_UHS2_USB = src_filter=+ USE_UHS3_USB = src_filter=+ USB_FLASH_DRIVE_SUPPORT = src_filter=+ +HAS_MCP3426_ADC = src_filter=+ + AUTO_BED_LEVELING_BILINEAR = src_filter=+ AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ +X_AXIS_TWIST_COMPENSATION = src_filter=+ + + MESH_BED_LEVELING = src_filter=+ + AUTO_BED_LEVELING_UBL = src_filter=+ + UBL_HILBERT_CURVE = src_filter=+ @@ -107,13 +110,16 @@ CANCEL_OBJECTS = src_filter=+ + EXTERNAL_CLOSED_LOOP_CONTROLLER = src_filter=+ + USE_CONTROLLER_FAN = src_filter=+ +HAS_COOLER|LASER_COOLANT_FLOW_METER = src_filter=+ HAS_MOTOR_CURRENT_DAC = src_filter=+ DIRECT_STEPPING = src_filter=+ + EMERGENCY_PARSER = src_filter=+ - +EASYTHREED_UI = src_filter=+ I2C_POSITION_ENCODERS = src_filter=+ IIC_BL24CXX_EEPROM = src_filter=+ HAS_SPI_FLASH = src_filter=+ HAS_ETHERNET = src_filter=+ + +HAS_FANCHECK = src_filter=+ + HAS_FANMUX = src_filter=+ FILAMENT_WIDTH_SENSOR = src_filter=+ + FWRETRACT = src_filter=+ + @@ -211,7 +217,6 @@ 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=+ INCH_MODE_SUPPORT = src_filter=+ TEMPERATURE_UNITS_SUPPORT = src_filter=+ @@ -229,7 +234,7 @@ HAS_SERVOS = src_filter=+ + HAS_MICROSTEPS = src_filter=+ (ESP3D_)?WIFISUPPORT = AsyncTCP, ESP Async WebServer - ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master.zip + ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master-2.0.7.zip arduinoWebSockets=links2004/WebSockets@2.3.4 luc-github/ESP32SSDP@^1.1.1 lib_ignore=ESPAsyncTCP diff --git a/ini/lpc176x.ini b/ini/lpc176x.ini index 3c5f43764ba6..95f5637a5dec 100644 --- a/ini/lpc176x.ini +++ b/ini/lpc176x.ini @@ -34,11 +34,9 @@ build_flags = ${common.build_flags} -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC17 # NXP LPC176x ARM Cortex-M3 # [env:LPC1768] -platform = ${common_LPC.platform} extends = common_LPC board = nxp_lpc1768 [env:LPC1769] -platform = ${common_LPC.platform} extends = common_LPC board = nxp_lpc1769 diff --git a/ini/native.ini b/ini/native.ini index fe5fe3a5d05a..3d196f343649 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -34,14 +34,14 @@ src_filter = ${common.default_src_filter} + [simulator_common] platform = native framework = -build_flags = ${common.build_flags} -std=gnu++17 -D__PLAT_NATIVE_SIM__ -DU8G_HAL_LINKS -I/usr/include/SDL2 -IMarlin -IMarlin/src/HAL/NATIVE_SIM/include -IMarlin/src/HAL/NATIVE_SIM/u8g +build_flags = ${common.build_flags} -std=gnu++17 -D__PLAT_NATIVE_SIM__ -DU8G_HAL_LINKS -I/usr/include/SDL2 -IMarlin -IMarlin/src/HAL/NATIVE_SIM/u8g src_build_flags = -Wall -Wno-expansion-to-defined -Wcast-align 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 + MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/0.0.2.zip Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/marlin_sim_native.zip LiquidCrystal=https://github.com/p3p/LiquidCrystal/archive/master.zip extra_scripts = ${common.extra_scripts} @@ -52,12 +52,10 @@ extends = simulator_common build_flags = ${simulator_common.build_flags} -ldl -lpthread -lSDL2 -lSDL2_net -lGL [env:simulator_linux_debug] -platform = ${simulator_linux.platform} extends = simulator_linux build_type = debug [env:simulator_linux_release] -platform = ${simulator_linux.platform} extends = simulator_linux build_type = release build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} @@ -92,13 +90,11 @@ build_flags = -lSDL2 [env:simulator_macos_debug] -platform = ${env:simulator_linux_release.platform} extends = env:simulator_linux_debug build_flags = ${env:simulator_linux_debug.build_flags} ${simulator_macos.build_flags} -ggdb -Og -D_THREAD_SAFE build_unflags = ${simulator_macos.build_unflags} [env:simulator_macos_release] -platform = ${env:simulator_linux_release.platform} extends = env:simulator_linux_release build_flags = ${env:simulator_linux_release.build_flags} ${simulator_macos.build_flags} build_unflags = ${simulator_macos.build_unflags} @@ -110,7 +106,6 @@ build_unflags = ${simulator_macos.build_unflags} # pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-glm mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_net mingw-w64-x86_64-dlfcn # [env:simulator_windows] -platform = ${simulator_common.platform} extends = simulator_common src_build_flags = ${simulator_common.src_build_flags} -fpermissive build_flags = ${simulator_common.build_flags} ${simulator_common.debug_build_flags} -IC:\\msys64\\mingw64\\include\\SDL2 -fno-stack-protector -Wl,-subsystem,windows -ldl -lmingw32 -lSDL2main -lSDL2 -lSDL2_net -lopengl32 -lssp diff --git a/ini/renamed.ini b/ini/renamed.ini new file mode 100644 index 000000000000..b325476d2f9e --- /dev/null +++ b/ini/renamed.ini @@ -0,0 +1,50 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# Renamed Environments # +# # +################################# + +# +# A platform that doesn't match anything in pins.h +# + +[renamed] +platform = ststm32 +board = genericSTM32F103RE + +# +# List of environment names that are no longer used +# + +[env:STM32F103RET6_creality_maple] +# Renamed to STM32F103RE_creality_maple +extends = renamed + +[env:STM32F103RET6_creality] +# Renamed to STM32F103RE_creality +extends = renamed + +[env:STM32F103RET6_creality_xfer] +# Renamed to STM32F103RE_creality_xfer +extends = renamed + +[env:STM32F103RC_btt_512K] +# Renamed to STM32F103RE_btt +extends = renamed + +[env:STM32F103RC_btt_512K_USB] +# Renamed to STM32F103RE_btt_USB +extends = renamed + +[env:STM32F103RC_btt_512K_maple] +# Renamed to STM32F103RE_btt_maple +extends = renamed + +[env:STM32F103RC_btt_512K_USB_maple] +# Renamed to STM32F103RE_btt_USB_maple +extends = renamed diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini index 54bc746ff4ff..1d3f858bf8e9 100644 --- a/ini/stm32-common.ini +++ b/ini/stm32-common.ini @@ -16,6 +16,7 @@ build_flags = ${common.build_flags} -std=gnu++14 -DHAL_STM32 -DUSBCON -DUSBD_USE_CDC -DTIM_IRQ_PRIO=13 + -DADC_RESOLUTION=12 build_unflags = -std=gnu++11 src_filter = ${common.default_src_filter} + + extra_scripts = ${common.extra_scripts} diff --git a/ini/stm32f0.ini b/ini/stm32f0.ini index 4559f115bd8e..d6251344c365 100644 --- a/ini/stm32f0.ini +++ b/ini/stm32f0.ini @@ -23,7 +23,6 @@ # Malyan M200 v2 (STM32F070RB) # [env:STM32F070RB_malyan] -platform = ${common_stm32.platform} extends = common_stm32 board = marlin_malyanM200v2 build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED @@ -34,7 +33,6 @@ build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED # Malyan M200 v2 (STM32F070CB) # [env:STM32F070CB_malyan] -platform = ${common_stm32.platform} extends = common_stm32 board = malyanm200_f070cb build_flags = ${common_stm32.build_flags} @@ -45,7 +43,6 @@ build_flags = ${common_stm32.build_flags} # Malyan M300 (STM32F070CB) # [env:malyan_M300] -platform = ${common_stm32.platform} extends = common_stm32 board = malyanm300_f070cb build_flags = ${common_stm32.build_flags} diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 969bb815dacd..9ea848f1b6b1 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -42,7 +42,6 @@ extra_scripts = ${common.extra_scripts} # STM32F103RC # [common_STM32F103RC_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC monitor_speed = 115200 @@ -51,7 +50,6 @@ monitor_speed = 115200 # MEEB_3DP (STM32F103RCT6 with 512K) # [env:STM32F103RC_meeb] -platform = ${common_stm32f1.platform} extends = common_STM32F103RC_maple board = marlin_MEEB_3DP build_flags = ${common_stm32f1.build_flags} @@ -75,7 +73,6 @@ upload_protocol = dfu # FYSETC STM32F103RC # [env:STM32F103RC_fysetc_maple] -platform = ${common_stm32f1.platform} extends = common_STM32F103RC_maple extra_scripts = ${common_stm32f1.extra_scripts} buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -91,7 +88,6 @@ upload_protocol = serial # STM32F103RC_btt_USB_maple ......... RCT6 with 256K (USB mass storage) # [env:STM32F103RC_btt_maple] -platform = ${common_stm32f1.platform} extends = common_STM32F103RC_maple board_build.address = 0x08007000 board_build.ldscript = STM32F103RC_SKR_MINI_256K.ld @@ -102,7 +98,6 @@ build_flags = ${common_stm32f1.build_flags} monitor_speed = 115200 [env:STM32F103RC_btt_USB_maple] -platform = ${common_stm32f1.platform} extends = env:STM32F103RC_btt_maple build_flags = ${env:STM32F103RC_btt_maple.build_flags} -DUSE_USB_COMPOSITE lib_deps = ${env:STM32F103RC_btt_maple.lib_deps} @@ -112,16 +107,22 @@ lib_deps = ${env:STM32F103RC_btt_maple.lib_deps} # Generic STM32F103RE environment # [env:STM32F103RE_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RE monitor_speed = 115200 +# +# Generic STM32F103RC environment +# +[env:STM32F103RC_maple] +extends = common_stm32f1 +board = genericSTM32F103RC +monitor_speed = 115200 + # # Creality (STM32F103RET6) # -[env:STM32F103RET6_creality_maple] -platform = ${common_stm32f1.platform} +[env:STM32F103RE_creality_maple] extends = env:STM32F103RE_maple build_flags = ${common_stm32f1.build_flags} -DTEMP_TIMER_CHAN=4 board_build.address = 0x08007000 @@ -132,6 +133,20 @@ extra_scripts = ${common_stm32f1.extra_scripts} debug_tool = jlink upload_protocol = jlink +# +# Creality (STM32F103RCT6) +# +[env:STM32F103RC_creality_maple] +extends = env:STM32F103RC_maple +build_flags = ${common_stm32f1.build_flags} -DTEMP_TIMER_CHAN=4 +board_build.address = 0x08007000 +board_build.ldscript = creality.ld +extra_scripts = ${common_stm32f1.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/random-bin.py + buildroot/share/PlatformIO/scripts/custom_board.py +debug_tool = jlink +upload_protocol = jlink + # # BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # @@ -139,7 +154,6 @@ upload_protocol = jlink # STM32F103RE_btt_USB_maple ......... RET6 (USB mass storage) # [env:STM32F103RE_btt_maple] -platform = ${common_stm32f1.platform} extends = env:STM32F103RE_maple board_build.address = 0x08007000 board_build.ldscript = STM32F103RE_SKR_MINI_512K.ld @@ -150,7 +164,6 @@ debug_tool = stlink upload_protocol = stlink [env:STM32F103RE_btt_USB_maple] -platform = ${common_stm32f1.platform} extends = env:STM32F103RE_btt_maple build_flags = ${env:STM32F103RE_btt_maple.build_flags} -DUSE_USB_COMPOSITE lib_deps = ${common_stm32f1.lib_deps} @@ -160,7 +173,6 @@ lib_deps = ${common_stm32f1.lib_deps} # Geeetech GTM32 (STM32F103VET6) # [env:STM32F103VE_GTM32] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE build_flags = ${common_stm32f1.build_flags} @@ -174,7 +186,6 @@ upload_protocol = serial # Longer 3D board in Alfawise U20 (STM32F103VET6) # [env:STM32F103VE_longer_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE board_build.address = 0x08010000 @@ -191,7 +202,6 @@ build_unflags = ${common_stm32f1.build_unflags} # MKS Robin Mini (STM32F103VET6) # [env:mks_robin_mini_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE extra_scripts = ${common_stm32f1.extra_scripts} @@ -203,7 +213,6 @@ build_flags = ${common_stm32f1.build_flags} # MKS Robin Nano (STM32F103VET6) # [env:mks_robin_nano35_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE extra_scripts = ${common_stm32f1.extra_scripts} @@ -217,7 +226,6 @@ upload_protocol = jlink # MKS Robin (STM32F103ZET6) # [env:mks_robin_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103ZE extra_scripts = ${common_stm32f1.extra_scripts} @@ -229,7 +237,6 @@ build_flags = ${common_stm32f1.build_flags} # MKS Robin Pro (STM32F103ZET6) # [env:mks_robin_pro_maple] -platform = ${common_stm32f1.platform} extends = env:mks_robin_maple extra_scripts = ${common_stm32f1.extra_scripts} buildroot/share/PlatformIO/scripts/mks_robin_pro.py @@ -238,7 +245,6 @@ extra_scripts = ${common_stm32f1.extra_scripts} # TRIGORILLA PRO (STM32F103ZET6) # [env:trigorilla_pro_maple] -platform = ${common_stm32f1.platform} extends = env:mks_robin_maple extra_scripts = ${common_stm32f1.extra_scripts} @@ -247,7 +253,6 @@ extra_scripts = ${common_stm32f1.extra_scripts} # MKS Robin E3 with TMC2209 # [env:mks_robin_e3_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC extra_scripts = ${common_stm32f1.extra_scripts} @@ -260,7 +265,6 @@ build_flags = ${common_stm32f1.build_flags} # - LVGL UI # [env:mks_robin_e3p_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE extra_scripts = ${common_stm32f1.extra_scripts} @@ -274,7 +278,6 @@ upload_protocol = jlink # MKS Robin Lite/Lite2 (STM32F103RCT6) # [env:mks_robin_lite_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC extra_scripts = ${common_stm32f1.extra_scripts} @@ -284,7 +287,6 @@ extra_scripts = ${common_stm32f1.extra_scripts} # MKS ROBIN LITE3 (STM32F103RCT6) # [env:mks_robin_lite3_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC extra_scripts = ${common_stm32f1.extra_scripts} @@ -294,7 +296,6 @@ extra_scripts = ${common_stm32f1.extra_scripts} # JGAurora A5S A1 (STM32F103ZET6) # [env:jgaurora_a5s_a1_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103ZE board_build.address = 0x0800A000 @@ -309,7 +310,6 @@ build_flags = ${common_stm32f1.build_flags} # Malyan M200 (STM32F103CB) # [env:STM32F103CB_malyan_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = marlin_malyanM200 build_flags = ${common_stm32f1.build_flags} @@ -322,7 +322,6 @@ lib_ignore = ${common_stm32f1.lib_ignore} # Chitu boards like Tronxy X5s (STM32F103ZET6) # [env:chitu_f103_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = marlin_CHITU_F103 extra_scripts = ${common_stm32f1.extra_scripts} @@ -338,7 +337,6 @@ build_unflags = ${common_stm32f1.build_unflags} # Use this target if G28 or G29 are always failing. # [env:chitu_v5_gpio_init_maple] -platform = ${common_stm32f1.platform} extends = env:chitu_f103_maple build_flags = ${env:chitu_f103_maple.build_flags} -DCHITU_V5_Z_MIN_BUGFIX @@ -346,7 +344,6 @@ build_flags = ${env:chitu_f103_maple.build_flags} -DCHITU_V5_Z_MIN_BUGFIX # FLYmaker FLY Mini (STM32F103RCT6) # [env:FLY_MINI_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC board_build.address = 0x08005000 @@ -364,7 +361,6 @@ build_flags = ${common_stm32f1.build_flags} # STM32F103VE_ZM3E4V2_USB_maple ......... VET6 with 512K # [ZONESTAR_ZM3E_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 platform_packages = tool-stm32duino board_build.address = 0x08005000 @@ -380,20 +376,17 @@ lib_deps = ${common_stm32f1.lib_deps} lib_ignore = Adafruit NeoPixel, SPI, SailfishLCD, SailfishRGB_LED, SlowSoftI2CMaster, TMCStepper [env:STM32F103RC_ZM3E2_USB_maple] -platform = ${ZONESTAR_ZM3E_maple.platform} extends = ZONESTAR_ZM3E_maple board = genericSTM32F103RC board_build.ldscript = ZONESTAR_ZM3E_256K.ld [env:STM32F103VC_ZM3E4_USB_maple] -platform = ${ZONESTAR_ZM3E_maple.platform} extends = ZONESTAR_ZM3E_maple board = genericSTM32F103VC board_build.ldscript = ZONESTAR_ZM3E_256K.ld build_flags = ${ZONESTAR_ZM3E_maple.build_flags} -DTONE_TIMER=1 -DTONE_CHANNEL=2 [env:STM32F103VE_ZM3E4V2_USB_maple] -platform = ${ZONESTAR_ZM3E_maple.platform} extends = ZONESTAR_ZM3E_maple board = genericSTM32F103VE board_build.ldscript = ZONESTAR_ZM3E_512K.ld @@ -404,7 +397,6 @@ board_upload.maximum_size = 499712 # ERYONE ERY32 Mini (STM32F103VET6) # [env:ERYONE_ERY32_MINI_maple] -platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE build_flags = ${common_stm32f1.build_flags} diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index da7cedd3a3db..9002f81a8143 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -30,7 +30,6 @@ monitor_speed = 115200 # STM32F103RE # [env:STM32F103RE] -platform = ${common_stm32.platform} extends = common_stm32 board = genericSTM32F103RE monitor_speed = 115200 @@ -39,7 +38,6 @@ monitor_speed = 115200 # STM32F103VE # [env:STM32F103VE] -platform = ${common_stm32.platform} extends = common_stm32 board = genericSTM32F103VE monitor_speed = 115200 @@ -48,7 +46,6 @@ monitor_speed = 115200 # STM32F103ZE # [env:STM32F103ZE] -platform = ${common_stm32.platform} extends = common_stm32 board = genericSTM32F103ZE monitor_speed = 115200 @@ -60,7 +57,6 @@ monitor_speed = 115200 # STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) # [env:STM32F103RC_btt] -platform = ${common_stm32.platform} extends = common_STM32F103RC_variant build_flags = ${common_STM32F103RC_variant.build_flags} -DTIMER_SERVO=TIM5 @@ -68,7 +64,6 @@ board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 [env:STM32F103RC_btt_USB] -platform = ${common_stm32.platform} extends = env:STM32F103RC_btt platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${env:STM32F103RC_btt.build_flags} @@ -78,12 +73,22 @@ build_flags = ${env:STM32F103RC_btt.build_flags} -DUSBD_USE_CDC_MSC build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC +# +# Panda Pi V2.9 - Standalone (STM32F103RC) +# Headless, without direct Pi control, but potentially hosting OctoPrint, stepdaemon, etc. +# +[env:PANDA_PI_V29] +extends = common_STM32F103RC_variant +build_flags = ${common_STM32F103RC_variant.build_flags} + -DTIMER_SERVO=TIM1 +board_build.offset = 0x5000 +board_upload.offset_address = 0x08005000 + # # MKS Robin (STM32F103ZET6) # Uses HAL STM32 to support Marlin UI for TFT screen with optional touch panel # [env:mks_robin] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx @@ -98,7 +103,6 @@ build_unflags = ${stm32_variant.build_unflags} # MKS Robin E3/E3D (STM32F103RCT6) with TMC2209 # [env:mks_robin_e3] -platform = ${common_stm32.platform} extends = common_STM32F103RC_variant board_build.encrypt = Robin_e3.bin board_build.offset = 0x5000 @@ -107,16 +111,13 @@ build_flags = ${common_STM32F103RC_variant.build_flags} -DTIMER_SERVO=TIM5 -DDEFAULT_SPI=3 build_unflags = ${common_STM32F103RC_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -monitor_speed = 115200 debug_tool = stlink # -# Creality (STM32F103RET6) +# Creality (STM32F103Rx) # -[env:STM32F103RET6_creality] -platform = ${common_stm32.platform} +[STM32F103Rx_creality] extends = stm32_variant -board = genericSTM32F103RE board_build.variant = MARLIN_F103Rx board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 @@ -132,6 +133,37 @@ monitor_speed = 115200 debug_tool = jlink upload_protocol = jlink +# +# Custom upload to SD via Marlin with Binary Protocol +# +[STM32F103Rx_creality_xfer] +extends = STM32F103Rx_creality +extra_scripts = ${STM32F103Rx_creality.extra_scripts} + pre:buildroot/share/scripts/upload.py +upload_protocol = custom + +# +# Creality 512K (STM32F103RE) +# +[env:STM32F103RE_creality] +extends = STM32F103Rx_creality +board = genericSTM32F103RE + +[env:STM32F103RE_creality_xfer] +extends = STM32F103Rx_creality_xfer +board = genericSTM32F103RE + +# +# Creality 256K (STM32F103RC) +# +[env:STM32F103RC_creality] +extends = STM32F103Rx_creality +board = genericSTM32F103RC + +[env:STM32F103RC_creality_xfer] +extends = STM32F103Rx_creality_xfer +board = genericSTM32F103RC + # # BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # @@ -139,7 +171,6 @@ upload_protocol = jlink # STM32F103RE_btt_USB ......... RET6 (USB mass storage) # [env:STM32F103RE_btt] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103RE board_build.variant = MARLIN_F103Rx @@ -154,7 +185,6 @@ debug_tool = jlink upload_protocol = jlink [env:STM32F103RE_btt_USB] -platform = ${common_stm32.platform} extends = env:STM32F103RE_btt platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${env:STM32F103RE_btt.build_flags} @@ -167,7 +197,6 @@ build_unflags = ${stm32_variant.build_unflags} -DUSBD_USE_CDC # board Hispeedv1 # [env:flsun_hispeedv1] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx @@ -184,7 +213,6 @@ build_unflags = ${stm32_variant.build_unflags} # MKS Robin Nano V1.2 and V2 # [env:mks_robin_nano35] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx @@ -203,7 +231,6 @@ upload_protocol = jlink # Mingda MPX_ARM_MINI # [env:mingda_mpx_arm_mini] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx @@ -217,7 +244,6 @@ build_unflags = ${stm32_variant.build_unflags} # Malyan M200 (STM32F103CB) # [env:STM32F103CB_malyan] -platform = ${common_stm32.platform} extends = common_stm32 board = malyanm200_f103cb build_flags = ${common_stm32.build_flags} @@ -229,7 +255,6 @@ src_filter = ${common.default_src_filter} + # FLYmaker FLY Mini (STM32F103RCT6) # [env:FLY_MINI] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103RC board_build.variant = MARLIN_F103Rx @@ -241,7 +266,6 @@ build_flags = ${stm32_variant.build_flags} -DSS_TIMER=4 # MKS Robin Mini (STM32F103VET6) # [env:mks_robin_mini] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx @@ -255,7 +279,6 @@ build_flags = ${stm32_variant.build_flags} # MKS Robin Lite/Lite2 (STM32F103RCT6) # [env:mks_robin_lite] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103RC board_build.variant = MARLIN_F103Rx @@ -267,7 +290,6 @@ board_upload.offset_address = 0x08005000 # MKS ROBIN LITE3 (STM32F103RCT6) # [env:mks_robin_lite3] -platform = ${common_stm32.platform} extends = env:mks_robin_lite board_build.encrypt = mksLite3.bin @@ -275,7 +297,6 @@ board_build.encrypt = mksLite3.bin # MKS Robin Pro (STM32F103ZET6) # [env:mks_robin_pro] -platform = ${common_stm32.platform} extends = env:mks_robin board_build.encrypt = Robin_pro.bin @@ -284,7 +305,6 @@ board_build.encrypt = Robin_pro.bin # - LVGL UI # [env:mks_robin_e3p] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx @@ -301,7 +321,6 @@ upload_protocol = jlink # JGAurora A5S A1 (STM32F103ZET6) # [env:jgaurora_a5s_a1] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx @@ -317,7 +336,6 @@ extra_scripts = ${stm32_variant.extra_scripts} # FYSETC STM32F103RC # [env:STM32F103RC_fysetc] -platform = ${common_stm32.platform} extends = common_STM32F103RC_variant extra_scripts = ${common_STM32F103RC_variant.extra_scripts} buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -329,10 +347,9 @@ upload_protocol = serial # Longer 3D board in Alfawise U20 (STM32F103VET6) # [env:STM32F103VE_longer] -platform = ${common_stm32.platform} +extends = stm32_variant lib_deps = ${common.lib_deps} https://github.com/tpruvot/STM32_Servo_OpenDrain/archive/2.0.zip -extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103VE_LONGER board_build.rename = project.bin @@ -348,7 +365,6 @@ debug_tool = stlink # TRIGORILLA PRO (STM32F103ZET6) # [env:trigorilla_pro] -platform = ${stm32_variant.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx @@ -361,12 +377,12 @@ build_unflags = ${stm32_variant.build_unflags} # Chitu boards like Tronxy X5s (STM32F103ZET6) # [env:chitu_f103] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx +board_build.offset = 0x8800 build_flags = ${stm32_variant.build_flags} - -DSTM32F1xx -DSTM32_XL_DENSITY + -DSTM32F1xx build_unflags = ${stm32_variant.build_unflags} extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -376,7 +392,6 @@ extra_scripts = ${stm32_variant.extra_scripts} # Use this target if G28 or G29 are always failing. # [env:chitu_v5_gpio_init] -platform = ${common_stm32.platform} extends = env:chitu_f103 build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX @@ -388,7 +403,6 @@ build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX # STM32F103VE_ZM3E4V2_USB ......... VET6 with 512K # [ZONESTAR_ZM3E] -platform = ${common_stm32.platform} extends = stm32_variant platform_packages = ${stm_flash_drive.platform_packages} board_upload.offset_address = 0x08005000 @@ -400,22 +414,19 @@ build_flags = ${common_stm32.build_flags} build_unflags = ${stm32_variant.build_unflags} -DUSBD_USE_CDC [env:STM32F103RC_ZM3E2_USB] -platform = ${ZONESTAR_ZM3E.platform} extends = ZONESTAR_ZM3E board = genericSTM32F103RC board_build.variant = MARLIN_F103Rx [env:STM32F103VC_ZM3E4_USB] -platform = ${ZONESTAR_ZM3E.platform} extends = ZONESTAR_ZM3E board = genericSTM32F103VC board_build.variant = MARLIN_F103Vx -build_flags = ${ZONESTAR_ZM3E.build_flags} -DTIMER_TONE=1 +build_flags = ${ZONESTAR_ZM3E.build_flags} -DTIMER_TONE=TIM1 [env:STM32F103VE_ZM3E4V2_USB] -platform = ${ZONESTAR_ZM3E.platform} extends = ZONESTAR_ZM3E board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx -build_flags = ${ZONESTAR_ZM3E.build_flags} -DTIMER_TONE=1 +build_flags = ${ZONESTAR_ZM3E.build_flags} -DTIMER_TONE=TIM1 board_upload.maximum_size = 499712 diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 6fec1d46fce7..d7c160d63942 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -23,7 +23,6 @@ # ARMED (STM32) # [env:ARMED] -platform = ${common_stm32.platform} extends = common_stm32 board = armed_v1 build_flags = ${common_stm32.build_flags} @@ -34,7 +33,6 @@ build_flags = ${common_stm32.build_flags} # 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html # [env:STM32F401VE_STEVAL] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STEVAL_STM32F401VE build_flags = ${stm32_variant.build_flags} @@ -45,17 +43,16 @@ build_flags = ${stm32_variant.build_flags} # STM32F401RC # [env:FYSETC_CHEETAH_V20] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_FYSETC_CHEETAH_V20 board_build.offset = 0x8000 build_flags = ${stm32_variant.build_flags} -DSTM32F401xC +upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE" # # FLYF407ZG # [env:FLYF407ZG] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_FLY_F407ZG @@ -66,7 +63,6 @@ upload_protocol = dfu # FYSETC S6 (STM32F446RET6 ARM Cortex-M4) # [env:FYSETC_S6] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_fysetc_s6 board_build.offset = 0x10000 @@ -80,7 +76,6 @@ upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" # FYSETC S6 new bootloader # [env:FYSETC_S6_8000] -platform = ${common_stm32.platform} extends = env:FYSETC_S6 board = marlin_fysetc_s6 board_build.offset = 0x8000 @@ -93,7 +88,6 @@ upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE" # Shield - https://github.com/jmz52/Hardware # [env:STM32F407VE_black] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_blackSTM32F407VET6 build_flags = ${stm32_variant.build_flags} @@ -103,7 +97,6 @@ build_flags = ${stm32_variant.build_flags} # STM32F407VET6 Index Mobo Rev 03 # [env:Index_Mobo_Rev03] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_index_mobo_rev03 build_flags = ${stm32_variant.build_flags} @@ -117,7 +110,6 @@ extra_scripts = ${stm32_variant.extra_scripts} # Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000. # [env:Anet_ET4_OpenBLT] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -137,7 +129,6 @@ upload_protocol = jlink # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) # [env:BIGTREE_SKR_PRO] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_BigTree_SKR_Pro board_build.offset = 0x8000 @@ -149,7 +140,6 @@ upload_protocol = stlink # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_SKR_PRO_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:BIGTREE_SKR_PRO platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} -DSTM32F407_5ZX @@ -159,7 +149,6 @@ build_unflags = ${env:BIGTREE_SKR_PRO.build_unflags} -DUSBCON -DUSBD_USE_CDC # BigTreeTech E3 RRF (STM32F407VGT6 ARM Cortex-M4) # [env:BIGTREE_E3_RRF] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_BIGTREE_E3_RRF @@ -173,7 +162,6 @@ build_flags = ${stm32_variant.build_flags} # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) # [env:BIGTREE_GTR_V1_0] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_BigTree_GTR_v1 board_build.offset = 0x8000 @@ -183,7 +171,6 @@ build_flags = ${stm32_variant.build_flags} -DSTM32F407IX # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_GTR_V1_0_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:BIGTREE_GTR_V1_0 platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} -DSTM32F407IX @@ -193,7 +180,6 @@ build_unflags = ${env:BIGTREE_GTR_V1_0.build_unflags} -DUSBCON -DUSBD_USE_CD # BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4) # [env:BIGTREE_BTT002] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_BigTree_BTT002 board_build.offset = 0x8000 @@ -208,7 +194,6 @@ build_flags = ${stm32_variant.build_flags} # BigTreeTech BTT002 V1.x with 512k of flash (STM32F407VET6 ARM Cortex-M4) # [env:BIGTREE_BTT002_VET6] -platform = ${env:BIGTREE_BTT002.platform} extends = env:BIGTREE_BTT002 board = marlin_BigTree_BTT002_VET6 @@ -216,7 +201,6 @@ board = marlin_BigTree_BTT002_VET6 # BigTreeTech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_SKR_2] -platform = ${common_stm32.platform} extends = stm32_variant platform_packages = ${stm_flash_drive.platform_packages} board = marlin_STM32F407VGT6_CCM @@ -234,22 +218,49 @@ upload_protocol = stlink # BigTreeTech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Media Share Support # [env:BIGTREE_SKR_2_USB] -platform = ${common_stm32.platform} 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 SKR V2.0 F429 (STM32F429VGT6 ARM Cortex-M4) with USB Flash Drive Support +# +[env:BIGTREE_SKR_2_F429] +extends = stm32_variant +platform_packages = ${stm_flash_drive.platform_packages} +board = marlin_STM32F429VGT6 +board_build.variant = MARLIN_F4x7Vx +board_build.offset = 0x8000 +board_upload.offset_address = 0x08008000 +build_flags = ${stm_flash_drive.build_flags} + -DUSE_USBHOST_HS -DUSE_USB_HS_IN_FS + -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 F429 (STM32F429VGT6 ARM Cortex-M4) with USB Media Share Support +# +[env:BIGTREE_SKR_2_F429_USB] +extends = env:BIGTREE_SKR_2_F429 +build_flags = ${env:BIGTREE_SKR_2_F429.build_flags} -DUSBD_USE_CDC_MSC +build_unflags = ${env:BIGTREE_SKR_2_F429.build_unflags} -DUSBD_USE_CDC + +[env:BIGTREE_SKR_2_F429_USB_debug] +extends = env:BIGTREE_SKR_2_F429_USB +build_flags = ${env:BIGTREE_SKR_2_F429_USB.build_flags} -O0 +build_unflags = ${env:BIGTREE_SKR_2_F429_USB.build_unflags} -Os -NDEBUG + # # BigTreeTech Octopus V1.0/1.1 / Octopus Pro V1.0 (STM32F446ZET6 ARM Cortex-M4) # [env:BIGTREE_OCTOPUS_V1] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_BigTree_Octopus_v1 board_build.offset = 0x8000 @@ -260,7 +271,6 @@ build_flags = ${stm32_variant.build_flags} # BigTreeTech Octopus V1.0/1.1 / Octopus Pro V1.0 (STM32F446ZET6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_OCTOPUS_V1_USB] -platform = ${common_stm32.platform} extends = env:BIGTREE_OCTOPUS_V1 platform_packages = ${stm_flash_drive.platform_packages} build_unflags = -DUSBD_USE_CDC @@ -274,7 +284,6 @@ build_flags = ${stm_flash_drive.build_flags} # BigTreeTech Octopus Pro V1.0 (STM32F429ZGT6 ARM Cortex-M4) # [env:BIGTREE_OCTOPUS_PRO_V1_F429] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_BigTree_Octopus_Pro_v1_F429 board_build.offset = 0x8000 @@ -285,21 +294,18 @@ build_flags = ${stm32_variant.build_flags} # BigTreeTech Octopus Pro V1.0 (STM32F429ZGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_OCTOPUS_PRO_V1_F429_USB] -platform = ${common_stm32.platform} extends = env:BIGTREE_OCTOPUS_PRO_V1_F429 platform_packages = ${stm_flash_drive.platform_packages} build_unflags = -DUSBD_USE_CDC build_flags = ${stm_flash_drive.build_flags} - -DSTM32F446_5VX -DUSE_USB_HS_IN_FS - -DUSE_USBHOST_HS -DUSBD_IRQ_PRIO=5 - -DUSBD_IRQ_SUBPRIO=6 + -DUSE_USB_HS_IN_FS -DUSE_USBHOST_HS + -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 -DUSBD_USE_CDC_MSC # # Lerdge base # [lerdge_common] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_LERDGE @@ -316,7 +322,6 @@ extra_scripts = ${common_stm32.extra_scripts} # Lerdge X (STM32F407VE) # [env:LERDGEX] -platform = ${lerdge_common.platform} extends = lerdge_common board_build.encrypt = Lerdge_X_firmware_force.bin @@ -324,7 +329,6 @@ board_build.encrypt = Lerdge_X_firmware_force.bin # Lerdge X with USB Flash Drive Support # [env:LERDGEX_usb_flash_drive] -platform = ${env:LERDGEX.platform} extends = env:LERDGEX platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} @@ -333,7 +337,6 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # Lerdge S (STM32F407ZG) # [env:LERDGES] -platform = ${lerdge_common.platform} extends = lerdge_common board_build.encrypt = Lerdge_firmware_force.bin @@ -341,7 +344,6 @@ board_build.encrypt = Lerdge_firmware_force.bin # Lerdge S with USB Flash Drive Support # [env:LERDGES_usb_flash_drive] -platform = ${env:LERDGES.platform} extends = env:LERDGES platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} @@ -350,7 +352,6 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # Lerdge K (STM32F407ZG) # [env:LERDGEK] -platform = ${lerdge_common.platform} extends = lerdge_common board_build.encrypt = Lerdge_K_firmware_force.bin build_flags = ${lerdge_common.build_flags} -DLERDGEK @@ -359,7 +360,6 @@ build_flags = ${lerdge_common.build_flags} -DLERDGEK # Lerdge K with USB Flash Drive Support # [env:LERDGEK_usb_flash_drive] -platform = ${env:LERDGEK.platform} extends = env:LERDGEK platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} @@ -368,7 +368,6 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # RUMBA32 # [env:rumba32] -platform = ${common_stm32.platform} extends = stm32_variant board = rumba32_f446ve board_build.variant = MARLIN_F446VE @@ -385,7 +384,6 @@ upload_protocol = dfu # MKS Robin Pro V2 # [env:mks_robin_pro2] -platform = ${common_stm32.platform} extends = stm32_variant platform_packages = ${stm_flash_drive.platform_packages} board = genericSTM32F407VET6 @@ -407,7 +405,6 @@ build_flags = -DPIN_WIRE_SCL=PB6 -DPIN_WIRE_SDA=PB7 # MKS Robin Nano V3 # [env:mks_robin_nano_v3] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -424,7 +421,6 @@ upload_protocol = jlink # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_robin_nano_v3_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:mks_robin_nano_v3 platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} @@ -438,18 +434,39 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} # Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged # [env:mks_robin_nano_v3_usb_flash_drive_msc] -platform = ${common_stm32.platform} extends = env:mks_robin_nano_v3_usb_flash_drive build_flags = ${env:mks_robin_nano_v3_usb_flash_drive.build_flags} -DUSBD_USE_CDC_MSC build_unflags = -DUSBD_USE_CDC +# +# MKS Robin Nano V3_1 +# +[env:mks_robin_nano_v3_1] +extends = env:mks_robin_nano_v3 +board = marlin_STM32F407VET6_CCM + +# +# MKS Robin Nano V3.1 with USB Flash Drive Support +# Currently, using a STM32duino fork, until USB Host get merged +# +[env:mks_robin_nano_v3_1_usb_flash_drive] +extends = env:mks_robin_nano_v3_usb_flash_drive +board = marlin_STM32F407VET6_CCM + +# +# MKS Robin Nano V3.1 with USB Flash Drive Support and Shared Media +# Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged +# +[env:mks_robin_nano_v3_1_usb_flash_drive_msc] +extends = env:mks_robin_nano_v3_usb_flash_drive_msc +board = marlin_STM32F407VET6_CCM + # # MKS Eagle # 5 TMC2209 uart mode on board # [env:mks_eagle] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -467,7 +484,6 @@ upload_protocol = jlink # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_eagle_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:mks_eagle platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} @@ -481,7 +497,6 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} # Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged # [env:mks_eagle_usb_flash_drive_msc] -platform = ${common_stm32.platform} extends = env:mks_eagle_usb_flash_drive build_flags = ${env:mks_eagle_usb_flash_drive.build_flags} -DUSBD_USE_CDC_MSC @@ -497,7 +512,6 @@ build_flags = -DPIN_WIRE_SCL=PB8 -DPIN_WIRE_SDA=PB9 # MKS Monster8 # [env:mks_monster8] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -515,7 +529,6 @@ upload_protocol = jlink # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_monster8_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:mks_monster8 platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1_CAN.build_flags} @@ -529,7 +542,6 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1_CAN.build_flag # Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged # [env:mks_monster8_usb_flash_drive_msc] -platform = ${common_stm32.platform} extends = env:mks_monster8_usb_flash_drive build_flags = ${env:mks_monster8_usb_flash_drive.build_flags} -DUSBD_USE_CDC_MSC @@ -539,15 +551,17 @@ build_unflags = -DUSBD_USE_CDC # TH3D EZBoard v2.0 (STM32F405RGT6 ARM Cortex-M4) # [env:TH3D_EZBoard_V2] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F405RG board_build.variant = MARLIN_TH3D_EZBOARD_V2 +board_build.encrypt = firmware.bin board_build.offset = 0xC000 board_upload.offset_address = 0x0800C000 build_flags = ${stm32_variant.build_flags} -DHSE_VALUE=12000000U -O0 debug_tool = stlink upload_protocol = stlink +extra_scripts = ${stm32_variant.extra_scripts} + buildroot/share/PlatformIO/scripts/openblt.py # # BOARD_MKS_ROBIN_NANO_V1_3_F4 @@ -555,7 +569,6 @@ upload_protocol = stlink # - MKS Robin Nano-S V1.3 (STM32F407VET6) 4 TMC2225 + 1 Pololu Plug # [env:mks_robin_nano_v1_3_f4] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -577,12 +590,12 @@ 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\" + -DFLASH_DATA_SECTOR=1U -DFLASH_BASE_ADDRESS=0x08004000 extra_scripts = ${common_stm32.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py diff --git a/ini/stm32f7.ini b/ini/stm32f7.ini index 200740589b1a..62755c846d47 100644 --- a/ini/stm32f7.ini +++ b/ini/stm32f7.ini @@ -25,7 +25,6 @@ # being readily available based on STM32F7 MCUs # [env:NUCLEO_F767ZI] -platform = ${common_stm32.platform} extends = common_stm32 board = nucleo_f767zi build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 @@ -34,6 +33,5 @@ build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 # REMRAM_V1 # [env:REMRAM_V1] -platform = ${common_stm32.platform} extends = common_stm32 board = remram_v1 diff --git a/ini/stm32g0.ini b/ini/stm32g0.ini new file mode 100644 index 000000000000..e6094c1e312d --- /dev/null +++ b/ini/stm32g0.ini @@ -0,0 +1,38 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# +# STM32G0 Architecture +# +# Naming Example: STM32G0B1RET6 +# +# G : Foundation +# 0 : Cortex M0+ core (0:M0, 1-2:M3, 3-4:M4, 7:M7) +# B1 : Line/Features +# R : 64 pins (R:64 or 66, F:20) +# E : 512KB Flash-memory (C:256KB, D:384KB, E:512KB, G:1024KB) +# T : LQFP package +# 6 : -40...85°C (7: ...105°C) +# +################################# + +# +# BigTree SKR mini E3 V3.0 (STM32G0B1RET6 ARM Cortex-M0+) +# +[env:STM32G0B1RE_btt] +extends = stm32_variant +platform = ststm32@~14.1.0 +platform_packages = framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/main.zip +board = marlin_STM32G0B1RE +board_build.offset = 0x2000 +board_upload.offset_address = 0x08002000 +build_flags = ${stm32_variant.build_flags} + -DPIN_SERIAL4_RX=PC_11 -DPIN_SERIAL4_TX=PC_10 + -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024 + -DTIMER_SERVO=TIM3 -DTIMER_TONE=TIM4 + -DSTEP_TIMER_IRQ_PRIO=0 +upload_protocol = stlink +debug_tool = stlink diff --git a/ini/stm32h7.ini b/ini/stm32h7.ini index fb39d4cc6b73..b0cb10866c55 100644 --- a/ini/stm32h7.ini +++ b/ini/stm32h7.ini @@ -23,9 +23,8 @@ # BigTreeTech SKR SE BX (STM32H743IIT6 ARM Cortex-M7) # [env:BTT_SKR_SE_BX] -platform = ${common_stm32.platform} extends = stm32_variant -platform_packages = ${stm_flash_drive.platform_packages} +platform_packages = framework-arduinoststm32@https://github.com/thisiskeithb/Arduino_Core_STM32/archive/biqu-bx-workaround.zip board = marlin_BTT_SKR_SE_BX board_build.offset = 0x20000 build_flags = ${stm32_variant.build_flags} ${stm_flash_drive.build_flags} diff --git a/ini/teensy.ini b/ini/teensy.ini index ef1ad766bcbb..ab0617b5b7b5 100644 --- a/ini/teensy.ini +++ b/ini/teensy.ini @@ -9,43 +9,72 @@ # # ################################# +# +# Teensy AVR +# +[teensy_avr] +platform = teensy +platform_packages = toolchain-atmelavr@~1.70300.0 +extends = common_avr8 +lib_ignore = ${env:common_avr8.lib_ignore}, NativeEthernet + +# +# AT90USB1286 boards using CDC bootloader +# e.g., BRAINWAVE, BRAINWAVE_PRO, SAV_MKI, TEENSYLU +# +[env:at90usb1286_cdc] +extends = teensy_avr +board = marlin_at90usb1286 +lib_ignore = ${teensy_avr.lib_ignore}, Teensy_ADC + +# +# AT90USB1286 boards using DFU bootloader +# e.g., Printrboard, Printrboard Rev.F, 5DPRINT +# +[env:at90usb1286_dfu] +extends = env:at90usb1286_cdc + # # Teensy++ 2.0 # [env:teensy20] -platform = teensy -extends = common_avr8 -board = teensy2pp -lib_ignore = ${env:common_avr8.lib_ignore}, NativeEthernet +extends = teensy_avr +board = teensy2pp + +# +# Teensy 3.x - 4.x +# +[teensy_arm] +platform = teensy@~4.12.0 +src_filter = ${common.default_src_filter} +lib_ignore = NativeEthernet # # Teensy 3.1 / 3.2 (ARM Cortex-M4) # [env:teensy31] -platform = teensy@~4.12.0 -board = teensy31 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet +extends = teensy_arm +board = teensy31 +src_filter = ${teensy_arm.src_filter} + # # Teensy 3.5 / 3.6 (ARM Cortex-M4) # [env:teensy35] -platform = teensy@~4.12.0 -board = teensy35 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet +extends = teensy_arm +board = teensy35 +src_filter = ${teensy_arm.src_filter} + [env:teensy36] -platform = teensy@~4.12.0 -board = teensy36 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet +extends = teensy_arm +board = teensy36 +src_filter = ${teensy_arm.src_filter} + # # Teensy 4.0 / 4.1 (ARM Cortex-M7) # [env:teensy41] -platform = teensy@~4.12.0 -board = teensy41 -src_filter = ${common.default_src_filter} + +extends = teensy_arm +board = teensy41 +src_filter = ${teensy_arm.src_filter} + +lib_ignore = diff --git a/platformio.ini b/platformio.ini index a364e8920f75..0e50da2b7392 100644 --- a/platformio.ini +++ b/platformio.ini @@ -30,7 +30,9 @@ extra_configs = ini/stm32f4.ini ini/stm32f7.ini ini/stm32h7.ini + ini/stm32g0.ini ini/teensy.ini + ini/renamed.ini # # The 'common' section applies to most Marlin builds. @@ -50,7 +52,7 @@ lib_deps = default_src_filter = + - - + - - - - - - - - - - - - - + - - - - - - - - - - - @@ -74,6 +76,7 @@ default_src_filter = + - - + - - - + - - - - - - - - @@ -92,6 +95,7 @@ default_src_filter = + - - + - - - + - - - - - - @@ -109,8 +113,10 @@ default_src_filter = + - - + - - - - - + - - - - + - - - - - - @@ -144,6 +150,7 @@ default_src_filter = + - - + - - - - + - - - - - @@ -198,6 +205,7 @@ default_src_filter = + - - + - - - + - - - - @@ -228,6 +236,7 @@ default_src_filter = + - - + - - - + - - - -