diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9acdc107ca8f..6e4afa16c6a5 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1231,11 +1231,16 @@ /** * Default Axis Steps Per Unit (linear=steps/mm, rotational=steps/°) - * Override with M92 + * Override with M92 (when enabled below) * X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]] */ #define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 500 } +/** + * Enable support for M92. Disable to save at least ~530 bytes of flash. + */ +#define EDITABLE_STEPS_PER_UNIT + /** * Default Max Feed Rate (linear=mm/s, rotational=°/s) * Override with M203 @@ -2032,7 +2037,7 @@ * Commands to execute at the end of G29 probing. * Useful to retract or move the Z probe out of the way. */ -//#define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" +//#define EVENT_GCODE_AFTER_G29 "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" /** * Normally G28 leaves leveling disabled on completion. Enable one of diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 3208364c3c2e..1d7c1a7277f3 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1743,19 +1743,20 @@ */ //#define POWER_LOSS_RECOVERY #if ENABLED(POWER_LOSS_RECOVERY) - #define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500) - //#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss - //#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS) - //#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module. - //#define POWER_LOSS_STATE HIGH // State of pin indicating power loss - //#define POWER_LOSS_PULLUP // Set pullup / pulldown as appropriate for your sensor + #define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500) + //#define PLR_BED_THRESHOLD BED_MAXTEMP // (°C) Skip user confirmation at or above this bed temperature (0 to disable) + //#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss + //#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS) + //#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module. + //#define POWER_LOSS_STATE HIGH // State of pin indicating power loss + //#define POWER_LOSS_PULLUP // Set pullup / pulldown as appropriate for your sensor //#define POWER_LOSS_PULLDOWN - //#define POWER_LOSS_PURGE_LEN 20 // (mm) Length of filament to purge on resume - //#define POWER_LOSS_RETRACT_LEN 10 // (mm) Length of filament to retract on fail. Requires backup power. + //#define POWER_LOSS_PURGE_LEN 20 // (mm) Length of filament to purge on resume + //#define POWER_LOSS_RETRACT_LEN 10 // (mm) Length of filament to retract on fail. Requires backup power. // Without a POWER_LOSS_PIN the following option helps reduce wear on the SD card, // especially with "vase mode" printing. Set too high and vases cannot be continued. - #define POWER_LOSS_MIN_Z_CHANGE 0.05 // (mm) Minimum Z change before saving power-loss data + #define POWER_LOSS_MIN_Z_CHANGE 0.05 // (mm) Minimum Z change before saving power-loss data // Enable if Z homing is needed for proper recovery. 99.9% of the time this should be disabled! //#define POWER_LOSS_RECOVER_ZHOME diff --git a/Marlin/Version.h b/Marlin/Version.h index baa1539a5b09..2ca028ebc562 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 "2024-01-06" +//#define STRING_DISTRIBUTION_DATE "2024-01-10" /** * 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 407a570cde97..97173c63f9c1 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -81,6 +81,12 @@ void MarlinHAL::init() { #if HAS_SERVO_3 OUT_WRITE(SERVO3_PIN, LOW); #endif + #if HAS_SERVO_4 + OUT_WRITE(SERVO4_PIN, LOW); + #endif + #if HAS_SERVO_5 + OUT_WRITE(SERVO5_PIN, LOW); + #endif init_pwm_timers(); // Init user timers to default frequency - 1000HZ diff --git a/Marlin/src/HAL/ESP32/i2s.cpp b/Marlin/src/HAL/ESP32/i2s.cpp index 69f8ca98458a..5404c3e9e2de 100644 --- a/Marlin/src/HAL/ESP32/i2s.cpp +++ b/Marlin/src/HAL/ESP32/i2s.cpp @@ -34,6 +34,10 @@ #include #include "../../module/stepper.h" +#if ENABLED(FT_MOTION) + #include "../../module/ft_motion.h" +#endif + #define DMA_BUF_COUNT 8 // number of DMA buffers to store data #define DMA_BUF_LEN 4092 // maximum size in bytes #define I2S_SAMPLE_SIZE 4 // 4 bytes, 32 bits per sample @@ -134,8 +138,8 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) { if (high_priority_task_awoken == pdTRUE) portYIELD_FROM_ISR(); - // clear interrupt - I2S0.int_clr.val = I2S0.int_st.val; //clear pending interrupt + // Clear pending interrupt + I2S0.int_clr.val = I2S0.int_st.val; } void stepperTask(void *parameter) { @@ -148,29 +152,43 @@ void stepperTask(void *parameter) { xQueueReceive(dma.queue, &dma.current, portMAX_DELAY); dma.rw_pos = 0; + const bool using_ftMotion = TERN0(FT_MOTION, ftMotion.cfg.mode); + while (dma.rw_pos < DMA_SAMPLE_COUNT) { - if (!nextMainISR) { - Stepper::pulse_phase_isr(); - nextMainISR = Stepper::block_phase_isr(); - } - #if ENABLED(LIN_ADVANCE) - else if (!nextAdvanceISR) { - Stepper::advance_isr(); - nextAdvanceISR = Stepper::la_interval; - } - #endif - else - i2s_push_sample(); - nextMainISR--; + #if ENABLED(FT_MOTION) - #if ENABLED(LIN_ADVANCE) - if (nextAdvanceISR == Stepper::LA_ADV_NEVER) - nextAdvanceISR = Stepper::la_interval; + if (using_ftMotion) { + if (!nextMainISR) stepper.ftMotion_stepper(); + nextMainISR = 0; + } - if (nextAdvanceISR && nextAdvanceISR != Stepper::LA_ADV_NEVER) - nextAdvanceISR--; #endif + + if (!using_ftMotion) { + if (!nextMainISR) { + Stepper::pulse_phase_isr(); + nextMainISR = Stepper::block_phase_isr(); + } + #if ENABLED(LIN_ADVANCE) + else if (!nextAdvanceISR) { + Stepper::advance_isr(); + nextAdvanceISR = Stepper::la_interval; + } + #endif + else + i2s_push_sample(); + + nextMainISR--; + + #if ENABLED(LIN_ADVANCE) + if (nextAdvanceISR == Stepper::LA_ADV_NEVER) + nextAdvanceISR = Stepper::la_interval; + + if (nextAdvanceISR && nextAdvanceISR != Stepper::LA_ADV_NEVER) + nextAdvanceISR--; + #endif + } } } } diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index 6fada12486a9..db9881cdd4ac 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -111,6 +111,12 @@ void MarlinHAL::init() { #if HAS_SERVO_3 INIT_SERVO(3); #endif + #if HAS_SERVO_4 + INIT_SERVO(4); + #endif + #if HAS_SERVO_5 + INIT_SERVO(5); + #endif //debug_frmwrk_init(); //_DBG("\n\nDebug running\n"); diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index cca247e20d6b..cda2eb28e304 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -31,6 +31,10 @@ #include "tft_spi.h" #include "pinconfig.h" +//#define DEBUG_TFT_IO +#define DEBUG_OUT ENABLED(DEBUG_TFT_IO) +#include "../../../core/debug_out.h" + SPI_HandleTypeDef TFT_SPI::SPIx; DMA_HandleTypeDef TFT_SPI::DMAtx; @@ -43,8 +47,9 @@ void TFT_SPI::init() { if ((spiInstance = (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TFT_SCK_PIN), PinMap_SPI_SCLK)) == NP) return; if (spiInstance != (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TFT_MOSI_PIN), PinMap_SPI_MOSI)) return; - #if PIN_EXISTS(TFT_MISO) && TFT_MISO_PIN != TFT_MOSI_PIN - if (spiInstance != (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TFT_MISO_PIN), PinMap_SPI_MISO)) return; + #if PIN_EXISTS(TFT_MISO) + // Check these pins in code because they are sometimes defined as analog pin references + if ((TFT_MISO_PIN != TFT_MOSI_PIN) && (spiInstance != (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TFT_MISO_PIN), PinMap_SPI_MISO))) return; #endif SPIx.Instance = spiInstance; @@ -76,10 +81,13 @@ void TFT_SPI::init() { pinmap_pinout(digitalPinToPinName(TFT_SCK_PIN), PinMap_SPI_SCLK); pinmap_pinout(digitalPinToPinName(TFT_MOSI_PIN), PinMap_SPI_MOSI); - #if PIN_EXISTS(TFT_MISO) && TFT_MISO_PIN != TFT_MOSI_PIN - pinmap_pinout(digitalPinToPinName(TFT_MISO_PIN), PinMap_SPI_MISO); + #if PIN_EXISTS(TFT_MISO) + // Check these pins in code because they are sometimes defined as analog pin references + if (TFT_MISO_PIN != TFT_MOSI_PIN) pinmap_pinout(digitalPinToPinName(TFT_MISO_PIN), PinMap_SPI_MISO); #endif + //pin_PullConfig(get_GPIO_Port(STM_PORT(digitalPinToPinName(TFT_SCK_PIN))), STM_LL_GPIO_PIN(digitalPinToPinName(TFT_SCK_PIN)), GPIO_PULLDOWN); + #ifdef SPI1_BASE if (SPIx.Instance == SPI1) { __HAL_RCC_SPI1_CLK_ENABLE(); @@ -151,29 +159,47 @@ void TFT_SPI::dataTransferBegin(uint16_t dataSize) { WRITE(TFT_CS_PIN, LOW); } -#ifdef TFT_DEFAULT_DRIVER - #include "../../../lcd/tft_io/tft_ids.h" -#endif +#include "../../../lcd/tft_io/tft_ids.h" uint32_t TFT_SPI::getID() { - uint32_t id; - id = readID(LCD_READ_ID); + DEBUG_ECHOLNPGM("TFT_SPI::getID()"); + + uint32_t id = readID(LCD_READ_ID); + #if ENABLED(DEBUG_TFT_IO) + char debug_register[3], debug_value[5]; + sprintf_P(debug_register, PSTR("%02X"), LCD_READ_ID); + sprintf_P(debug_value, PSTR("%04X"), uint16_t(id)); + DEBUG_ECHOLNPGM(" readID(0x", debug_register, ") : 0x", debug_value); + #endif + if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) { id = readID(LCD_READ_ID4); - #ifdef TFT_DEFAULT_DRIVER - if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) - id = TFT_DEFAULT_DRIVER; + #if ENABLED(DEBUG_TFT_IO) + sprintf_P(debug_register, PSTR("%02X"), LCD_READ_ID4); + sprintf_P(debug_value, PSTR("%04X"), uint16_t(id)); + DEBUG_ECHOLNPGM(" readID(0x", debug_register, ") : 0x", debug_value); #endif - } + } + + #ifdef TFT_DEFAULT_DRIVER + if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) { + id = TFT_DEFAULT_DRIVER; + #if ENABLED(DEBUG_TFT_IO) + sprintf_P(debug_value, PSTR("%04X"), uint16_t(id)); + DEBUG_ECHOLNPGM(" Fallback to TFT_DEFAULT_DRIVER : 0x", debug_value); + #endif + } + #endif + return id; } uint32_t TFT_SPI::readID(const uint16_t inReg) { uint32_t data = 0; #if PIN_EXISTS(TFT_MISO) - const uint32_t oldPrescaler = SPIx.Init.BaudRatePrescaler; - + uint32_t BaudRatePrescaler = SPIx.Init.BaudRatePrescaler; SPIx.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + dataTransferBegin(DATASIZE_8BIT); writeReg(inReg); @@ -185,10 +211,8 @@ uint32_t TFT_SPI::readID(const uint16_t inReg) { __HAL_SPI_ENABLE(&SPIx); SET_BIT(SPIx.Instance->CR1, SPI_CR1_CSTART); - #if TFT_MISO_PIN != TFT_MOSI_PIN - SPIx.Instance->TXDR = 0; - #endif - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_EOT)) {} + if (SPIx.Init.Direction == SPI_DIRECTION_2LINES) SPIx.Instance->TXDR = 0; + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_EOT)) { /* nada */ } data = (data << 8) | SPIx.Instance->RXDR; __HAL_SPI_DISABLE(&SPIx); __HAL_SPI_CLEAR_EOTFLAG(&SPIx); @@ -197,19 +221,22 @@ uint32_t TFT_SPI::readID(const uint16_t inReg) { #else __HAL_SPI_ENABLE(&SPIx); for (uint32_t i = 0; i < 4; i++) { - #if TFT_MISO_PIN != TFT_MOSI_PIN - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} + if (SPIx.Init.Direction == SPI_DIRECTION_2LINES) { + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) { /* nada */ } SPIx.Instance->DR = 0; - #endif - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_RXNE)) {} + } + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_RXNE)) { /* nada */ } data = (data << 8) | SPIx.Instance->DR; } #endif dataTransferEnd(); - SPIx.Init.BaudRatePrescaler = oldPrescaler; + #if DISABLED(DEBUG_TFT_IO) + SPIx.Init.BaudRatePrescaler = BaudRatePrescaler; + #endif #endif + DEBUG_ECHOLNPGM(" raw data : ", data); return data >> 7; } @@ -238,13 +265,13 @@ bool TFT_SPI::isBusy() { // Check if SPI data transfer is completed if (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_EOT)) return true; #else - // Check if SPI is idle - if (__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) return true; + // Check if SPI transmit butter is empty and SPI is idle + if ((!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) || (__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY))) return true; #endif } abort(); - return false; + return true; } void TFT_SPI::abort() { @@ -263,9 +290,7 @@ void TFT_SPI::abort() { } void TFT_SPI::transmit(uint16_t data) { - #if TFT_MISO_PIN == TFT_MOSI_PIN - SPI_1LINE_TX(&SPIx); - #endif + if (SPIx.Init.Direction == SPI_DIRECTION_1LINE) SPI_1LINE_TX(&SPIx); #ifdef STM32H7xx MODIFY_REG(SPIx.Instance->CR2, SPI_CR2_TSIZE, 1); @@ -274,30 +299,26 @@ void TFT_SPI::transmit(uint16_t data) { SPIx.Instance->TXDR = data; - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_SR_EOT)) {} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_SR_EOT)) { /* nada */ } __HAL_SPI_CLEAR_EOTFLAG(&SPIx); __HAL_SPI_CLEAR_TXTFFLAG(&SPIx); + __HAL_SPI_DISABLE(&SPIx); #else __HAL_SPI_ENABLE(&SPIx); SPIx.Instance->DR = data; - while (__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) { /* nada */ } // Wait for data transfer to actually start + while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) { /* nada */ } // Wait until SPI is idle #endif - __HAL_SPI_DISABLE(&SPIx); - - #if TFT_MISO_PIN != TFT_MOSI_PIN - __HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received data is not read - #endif + if (SPIx.Init.Direction == SPI_DIRECTION_2LINES) __HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received data is not read } void TFT_SPI::transmitDMA(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); - #endif + if (SPIx.Init.Direction == SPI_DIRECTION_1LINE) SPI_1LINE_TX(&SPIx); dataTransferBegin(); @@ -316,7 +337,7 @@ void TFT_SPI::transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t coun SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request #endif - TERN_(TFT_SHARED_IO, while (isBusy())); + TERN_(TFT_SHARED_IO, while (isBusy()) { /* nada */ }); } void TFT_SPI::transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count) { @@ -324,9 +345,10 @@ void TFT_SPI::transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count) HAL_DMA_PollForTransfer(&DMAtx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY); #ifdef STM32H7xx - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_SR_EOT)) {} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_SR_EOT)) { /* nada */ } #else - while (__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) { /* nada */ } + while (__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) { /* nada */ } #endif abort(); } @@ -337,8 +359,7 @@ void TFT_SPI::transmit(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); + if (SPIx.Init.Direction == SPI_DIRECTION_1LINE) SPI_1LINE_TX(&SPIx); dataTransferBegin(); diff --git a/Marlin/src/HAL/shared/servo.cpp b/Marlin/src/HAL/shared/servo.cpp index bb9d61801841..543bc8e873ae 100644 --- a/Marlin/src/HAL/shared/servo.cpp +++ b/Marlin/src/HAL/shared/servo.cpp @@ -60,8 +60,8 @@ ServoInfo_t servo_info[MAX_SERVOS]; // static array of servo info structures uint8_t ServoCount = 0; // the total number of attached servos -#define SERVO_MIN(v) (MIN_PULSE_WIDTH - (v) * 4) // minimum value in uS for this servo -#define SERVO_MAX(v) (MAX_PULSE_WIDTH - (v) * 4) // maximum value in uS for this servo +#define SERVO_MIN_US(v) (MIN_PULSE_WIDTH - (v) * 4) // minimum value in uS for this servo +#define SERVO_MAX_US(v) (MAX_PULSE_WIDTH - (v) * 4) // maximum value in uS for this servo /************ static functions common to all instances ***********************/ @@ -117,7 +117,7 @@ void Servo::detach() { void Servo::write(int value) { if (value < MIN_PULSE_WIDTH) // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) - value = map(constrain(value, 0, 180), 0, 180, SERVO_MIN(min), SERVO_MAX(max)); + value = map(constrain(value, 0, 180), 0, 180, SERVO_MIN_US(min), SERVO_MAX_US(max)); writeMicroseconds(value); } @@ -126,8 +126,8 @@ void Servo::writeMicroseconds(int value) { byte channel = servoIndex; if (channel < MAX_SERVOS) { // ensure channel is valid // ensure pulse width is valid - value = constrain(value, SERVO_MIN(min), SERVO_MAX(max)) - (TRIM_DURATION); - value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009 + LIMIT(value, SERVO_MIN_US(min), SERVO_MAX_US(max)); + value = usToTicks(value - (TRIM_DURATION)); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009 CRITICAL_SECTION_START(); servo_info[channel].ticks = value; @@ -136,7 +136,7 @@ void Servo::writeMicroseconds(int value) { } // return the value as degrees -int Servo::read() { return map(readMicroseconds() + 1, SERVO_MIN(min), SERVO_MAX(max), 0, 180); } +int Servo::read() { return map(readMicroseconds() + 1, SERVO_MIN_US(min), SERVO_MAX_US(max), 0, 180); } int Servo::readMicroseconds() { return (servoIndex == INVALID_SERVO) ? 0 : ticksToUs(servo_info[servoIndex].ticks) + (TRIM_DURATION); diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index f0bd97ac1cf7..91496b1c5c50 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -819,7 +819,7 @@ void idle(const bool no_stepper_sleep/*=false*/) { TERN_(HAS_BEEPER, buzzer.tick()); // Handle UI input / draw events - TERN(DWIN_CREALITY_LCD, dwinUpdate(), ui.update()); + ui.update(); // Run i2c Position Encoders #if ENABLED(I2C_POSITION_ENCODERS) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 720c86769da4..560ff71e8493 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -681,11 +681,11 @@ void unified_bed_leveling::G29() { ui.release(); #endif - #ifdef Z_PROBE_END_SCRIPT - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", Z_PROBE_END_SCRIPT); + #ifdef EVENT_GCODE_AFTER_G29 + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", EVENT_GCODE_AFTER_G29); if (probe_deployed) { planner.synchronize(); - gcode.process_subcommands_now(F(Z_PROBE_END_SCRIPT)); + gcode.process_subcommands_now(F(EVENT_GCODE_AFTER_G29)); } #else UNUSED(probe_deployed); diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 816ffb23b7ea..acbae459e716 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -55,17 +55,19 @@ void ControllerFan::set_fan_speed(const uint8_t s) { } void ControllerFan::update() { - static millis_t lastMotorOn = 0, // Last time a motor was turned on - nextMotorCheck = 0; // Last time the state was checked + static millis_t lastComponentOn = 0, // Last time a stepper, heater, etc. was turned on + nextFanCheck = 0; // Last time the state was checked const millis_t ms = millis(); - if (ELAPSED(ms, nextMotorCheck)) { - nextMotorCheck = ms + 2500UL; // Not a time critical function, so only check every 2.5s - - // If any triggers for the controller fan are true... - // - At least one stepper driver is enabled - // - The heated bed is enabled - // - TEMP_SENSOR_BOARD is reporting >= CONTROLLER_FAN_MIN_BOARD_TEMP - // - TEMP_SENSOR_SOC is reporting >= CONTROLLER_FAN_MIN_SOC_TEMP + if (ELAPSED(ms, nextFanCheck)) { + nextFanCheck = ms + 2500UL; // Not a time critical function, so only check every 2.5s + + /** + * If any triggers for the controller fan are true... + * - At least one stepper driver is enabled + * - The heated bed (MOSFET) is enabled + * - TEMP_SENSOR_BOARD is reporting >= CONTROLLER_FAN_MIN_BOARD_TEMP + * - TEMP_SENSOR_SOC is reporting >= CONTROLLER_FAN_MIN_SOC_TEMP + */ const ena_mask_t axis_mask = TERN(CONTROLLER_FAN_USE_Z_ONLY, _BV(Z_AXIS), (ena_mask_t)~TERN0(CONTROLLER_FAN_IGNORE_Z, _BV(Z_AXIS))); if ( (stepper.axis_enabled.bits & axis_mask) || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0) @@ -75,13 +77,15 @@ void ControllerFan::update() { #ifdef CONTROLLER_FAN_MIN_SOC_TEMP || thermalManager.wholeDegSoc() >= CONTROLLER_FAN_MIN_SOC_TEMP #endif - ) lastMotorOn = ms; //... set time to NOW so the fan will turn on + ) lastComponentOn = ms; //... set time to NOW so the fan will turn on - // Fan Settings. Set fan > 0: - // - If AutoMode is on and steppers have been enabled for CONTROLLERFAN_IDLE_TIME seconds. - // - If System is on idle and idle fan speed settings is activated. + /** + * Fan Settings. Set fan > 0: + * - If AutoMode is on and hot components have been powered for CONTROLLERFAN_IDLE_TIME seconds. + * - If System is on idle and idle fan speed settings is activated. + */ set_fan_speed( - settings.auto_mode && lastMotorOn && PENDING(ms, lastMotorOn + SEC_TO_MS(settings.duration)) + settings.auto_mode && lastComponentOn && PENDING(ms, lastComponentOn + SEC_TO_MS(settings.duration)) ? settings.active_speed : settings.idle_speed ); diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index 5a0564ee71d1..9a8e369c6a39 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -422,22 +422,22 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) { travelledDistance = mm_from_count(ABS(stopCount - startCount)); SERIAL_ECHOLNPGM("Attempted travel: ", travelDistance, "mm"); - SERIAL_ECHOLNPGM(" Actual travel: ", travelledDistance, "mm"); + SERIAL_ECHOLNPGM(" Actual travel: ", travelledDistance, "mm"); - //Calculate new axis steps per unit + // Calculate new axis steps per unit old_steps_mm = planner.settings.axis_steps_per_mm[encoderAxis]; new_steps_mm = (old_steps_mm * travelDistance) / travelledDistance; SERIAL_ECHOLNPGM("Old steps/mm: ", old_steps_mm); SERIAL_ECHOLNPGM("New steps/mm: ", new_steps_mm); - //Save new value + // Save new value planner.settings.axis_steps_per_mm[encoderAxis] = new_steps_mm; if (iter > 1) { total += new_steps_mm; - // swap start and end points so next loop runs from current position + // Swap start and end points so next loop runs from current position const float tempCoord = startCoord[encoderAxis]; startCoord[encoderAxis] = endCoord[encoderAxis]; endCoord[encoderAxis] = tempCoord; diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 5a25710084b2..ce34b3a95cec 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -37,6 +37,10 @@ bool PrintJobRecovery::enabled; // Initialized by settings.load() +#if HAS_PLR_BED_THRESHOLD + celsius_t PrintJobRecovery::bed_temp_threshold; // Initialized by settings.load() +#endif + MediaFile PrintJobRecovery::file; job_recovery_info_t PrintJobRecovery::info; const char PrintJobRecovery::filename[5] = "/PLR"; diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index a69862b25957..1fdc42db26ad 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -175,6 +175,10 @@ class PrintJobRecovery { static void enable(const bool onoff); static void changed(); + #if HAS_PLR_BED_THRESHOLD + static celsius_t bed_temp_threshold; + #endif + static bool exists() { return card.jobRecoverFileExists(); } static void open(const bool read) { card.openJobRecoveryFile(read); } static void close() { file.close(); } diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 5c7f9e1f6d97..7fae11783e9d 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -615,7 +615,7 @@ void GcodeSuite::G26() { // If any preset or temperature was specified if (noztemp) { - if (!WITHIN(noztemp, 165, (HEATER_0_MAXTEMP) - (HOTEND_OVERSHOOT))) { + if (!WITHIN(noztemp, 165, thermalManager.hotend_max_target(active_extruder))) { SERIAL_ECHOLNPGM("?Specified nozzle temperature not plausible."); return; } diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 700562df8168..1ca3826c816f 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -987,10 +987,10 @@ G29_TYPE GcodeSuite::G29() { TERN_(HAS_BED_PROBE, probe.move_z_after_probing()); - #ifdef Z_PROBE_END_SCRIPT - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", Z_PROBE_END_SCRIPT); + #ifdef EVENT_GCODE_AFTER_G29 + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", EVENT_GCODE_AFTER_G29); planner.synchronize(); - process_subcommands_now(F(Z_PROBE_END_SCRIPT)); + process_subcommands_now(F(EVENT_GCODE_AFTER_G29)); #endif probe.use_probing_tool(false); diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 98d0a401481c..55698c942bd4 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -639,8 +639,8 @@ void GcodeSuite::G28() { #endif #ifdef XY_AFTER_HOMING - constexpr xy_pos_t xy_after XY_AFTER_HOMING; - do_blocking_move_to(xy_after); + if (!axes_should_home(_BV(X_AXIS) | _BV(Y_AXIS))) + do_blocking_move_to(xy_pos_t(XY_AFTER_HOMING)); #endif restore_feedrate_and_scaling(); diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 5ea89b713638..467a31cf44fc 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -118,7 +118,7 @@ inline void toggle_pins() { inline void servo_probe_test() { - #if !(NUM_SERVOS > 0 && HAS_SERVO_0) + #if !HAS_SERVO_0 SERIAL_ERROR_MSG("SERVO not set up."); diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index 09153c51fd49..347de3bdea2d 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -20,6 +20,10 @@ * */ +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(EDITABLE_STEPS_PER_UNIT) + #include "../gcode.h" #include "../../module/planner.h" @@ -37,6 +41,7 @@ * H - Specify micro-steps to use. Best guess if not supplied. * L - Desired layer height in current units. Nearest good heights are shown. */ + void GcodeSuite::M92() { const int8_t target_extruder = get_target_extruder_from_command(); @@ -127,3 +132,5 @@ void GcodeSuite::M92_report(const bool forReplay/*=true*/, const int8_t e/*=-1*/ UNUSED(e); #endif } + +#endif // EDITABLE_STEPS_PER_UNIT diff --git a/Marlin/src/gcode/feature/ft_motion/M493.cpp b/Marlin/src/gcode/feature/ft_motion/M493.cpp index a72a35d5bf36..64d57118a0f3 100644 --- a/Marlin/src/gcode/feature/ft_motion/M493.cpp +++ b/Marlin/src/gcode/feature/ft_motion/M493.cpp @@ -79,7 +79,7 @@ void say_shaping() { SERIAL_ECHO_TERNARY(dynamic, "X/A ", "base dynamic", "static", " compensator frequency: "); SERIAL_ECHO(p_float_t(ftMotion.cfg.baseFreq[X_AXIS], 2), F("Hz")); #if HAS_DYNAMIC_FREQ - if (dynamic) SERIAL_ECHO(" scaling: ", p_float_t(ftMotion.cfg.dynFreqK[X_AXIS], 8), F("Hz/"), z_based ? F("mm") : F("g")); + if (dynamic) SERIAL_ECHO(F(" scaling: "), p_float_t(ftMotion.cfg.dynFreqK[X_AXIS], 2), F("Hz/"), z_based ? F("mm") : F("g")); #endif SERIAL_EOL(); #endif @@ -88,7 +88,7 @@ void say_shaping() { SERIAL_ECHO_TERNARY(dynamic, "Y/B ", "base dynamic", "static", " compensator frequency: "); SERIAL_ECHO(p_float_t(ftMotion.cfg.baseFreq[Y_AXIS], 2), F(" Hz")); #if HAS_DYNAMIC_FREQ - if (dynamic) SERIAL_ECHO(F(" scaling: "), p_float_t(ftMotion.cfg.dynFreqK[Y_AXIS], 8), F("Hz/"), z_based ? F("mm") : F("g")); + if (dynamic) SERIAL_ECHO(F(" scaling: "), p_float_t(ftMotion.cfg.dynFreqK[Y_AXIS], 2), F("Hz/"), z_based ? F("mm") : F("g")); #endif SERIAL_EOL(); #endif @@ -96,7 +96,10 @@ void say_shaping() { #if HAS_EXTRUDERS SERIAL_ECHO_TERNARY(ftMotion.cfg.linearAdvEna, "Linear Advance ", "en", "dis", "abled"); - SERIAL_ECHOLN(F(". Gain: "), p_float_t(ftMotion.cfg.linearAdvK, 5)); + if (ftMotion.cfg.linearAdvEna) + SERIAL_ECHOLNPGM(". Gain: ", ftMotion.cfg.linearAdvK); + else + SERIAL_EOL(); #endif } diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index 1a1ebd517b3b..033bcf4ebbdc 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -28,6 +28,10 @@ #include "../../../feature/powerloss.h" #include "../../../module/motion.h" +#if HAS_PLR_BED_THRESHOLD + #include "../../../module/temperature.h" // for degBed +#endif + #include "../../../lcd/marlinui.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" @@ -60,12 +64,15 @@ inline void plr_error(FSTR_P const prefix) { /** * M1000: Resume from power-loss (undocumented) * - With 'S' go to the Resume/Cancel menu + * ...unless the bed temperature is already above a configured minimum temperature. * - With no parameters, run recovery commands */ void GcodeSuite::M1000() { if (recovery.valid()) { - if (parser.seen_test('S')) { + const bool force_resume = TERN0(HAS_PLR_BED_THRESHOLD, recovery.bed_temp_threshold && (thermalManager.degBed() >= recovery.bed_temp_threshold)); + + if (!force_resume && parser.seen_test('S')) { #if HAS_MARLINUI_MENU ui.goto_screen(menu_job_recovery); #elif HAS_DWIN_E3V2_BASIC diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 5e508d4f28ae..8cbe468476b3 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -35,6 +35,9 @@ * Parameters * S[bool] - Flag to enable / disable. * If omitted, report current state. + * + * With PLR_BED_THRESHOLD: + * B Bed Temperature above which recovery will proceed without asking permission. */ void GcodeSuite::M413() { @@ -43,6 +46,11 @@ void GcodeSuite::M413() { else M413_report(); + #if HAS_PLR_BED_THRESHOLD + if (parser.seenval('B')) + recovery.bed_temp_threshold = parser.value_celsius(); + #endif + #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) if (parser.seen("RL")) recovery.load(); if (parser.seen_test('W')) recovery.save(true); @@ -57,7 +65,11 @@ void GcodeSuite::M413() { void GcodeSuite::M413_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_POWER_LOSS_RECOVERY)); - SERIAL_ECHOPGM(" M413 S", AS_DIGIT(recovery.enabled), " ; "); + SERIAL_ECHOPGM(" M413 S", AS_DIGIT(recovery.enabled) + #if HAS_PLR_BED_THRESHOLD + , " B", recovery.bed_temp_threshold + #endif + ); serialprintln_onoff(recovery.enabled); } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 86d73dd56fb4..1ff643dc2174 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -669,7 +669,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 87: M87(); break; // M87: Cancel Hotend Idle Timeout #endif - case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes + #endif + case 114: M114(); break; // M114: Report current position #if ENABLED(CAPABILITIES_REPORT) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 6be5dc642c81..7a72097141b7 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -128,7 +128,7 @@ * M84 - Disable steppers until next move, or use S to specify an idle * duration after which steppers should turn off. S0 disables the timeout. * M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) - * M92 - Set planner.settings.axis_steps_per_mm for one or more axes. + * M92 - Set planner.settings.axis_steps_per_mm for one or more axes. (Requires EDITABLE_STEPS_PER_UNIT) * * M100 - Watch Free Memory (for debugging) (Requires M100_FREE_MEMORY_WATCHER) * @@ -719,8 +719,10 @@ class GcodeSuite { static void M87(); #endif - static void M92(); - static void M92_report(const bool forReplay=true, const int8_t e=-1); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + static void M92(); + static void M92_report(const bool forReplay=true, const int8_t e=-1); + #endif #if ENABLED(M100_FREE_MEMORY_WATCHER) static void M100(); diff --git a/Marlin/src/inc/Changes.h b/Marlin/src/inc/Changes.h index 5a03e87b1d8e..0fd91ee9ca13 100644 --- a/Marlin/src/inc/Changes.h +++ b/Marlin/src/inc/Changes.h @@ -685,6 +685,8 @@ #error "SDIO_SUPPORT is now ONBOARD_SDIO." #elif defined(ANET_FULL_GRAPHICS_LCD_ALT_WIRING) #error "ANET_FULL_GRAPHICS_LCD_ALT_WIRING is now CTC_A10S_A13." +#elif defined(Z_PROBE_END_SCRIPT) + #error "Z_PROBE_END_SCRIPT is now EVENT_GCODE_AFTER_G29." #endif // Changes to Probe Temp Compensation (#17392) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e07d026cb961..58842209afe2 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -263,10 +263,13 @@ #endif #if NUM_AXES >= 1 #define HAS_X_AXIS 1 + #define HAS_A_AXIS 1 #if NUM_AXES >= XY #define HAS_Y_AXIS 1 + #define HAS_B_AXIS 1 #if NUM_AXES >= XYZ #define HAS_Z_AXIS 1 + #define HAS_C_AXIS 1 #if NUM_AXES >= 4 #define HAS_I_AXIS 1 #if NUM_AXES >= 5 @@ -1087,6 +1090,10 @@ #define HAS_DISPLAY 1 #endif +#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD) + #define HAS_UI_UPDATE 1 +#endif + #if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI #define HAS_LCDPRINT 1 #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 191da44af759..20b357c9e31e 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1309,6 +1309,12 @@ #define HAS_ZV_SHAPING 1 #endif +// FT Motion unified window and batch size +#if ALL(FT_MOTION, FTM_UNIFIED_BWS) + #define FTM_WINDOW_SIZE FTM_BW_SIZE + #define FTM_BATCH_SIZE FTM_BW_SIZE +#endif + // Toolchange Event G-code #if !HAS_MULTI_EXTRUDER || !(defined(EVENT_GCODE_TOOLCHANGE_T0) || defined(EVENT_GCODE_TOOLCHANGE_T1) || defined(EVENT_GCODE_TOOLCHANGE_T2) || defined(EVENT_GCODE_TOOLCHANGE_T3) || defined(EVENT_GCODE_TOOLCHANGE_T4) || defined(EVENT_GCODE_TOOLCHANGE_T5) || defined(EVENT_GCODE_TOOLCHANGE_T6) || defined(EVENT_GCODE_TOOLCHANGE_T7)) #undef TC_GCODE_USE_GLOBAL_X @@ -1349,3 +1355,8 @@ #if DISABLED(INCH_MODE_SUPPORT) #undef MANUAL_MOVE_DISTANCE_IN #endif + +// Power-Loss Recovery +#if ENABLED(POWER_LOSS_RECOVERY) && defined(PLR_BED_THRESHOLD) + #define HAS_PLR_BED_THRESHOLD 1 +#endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index cea7f85fd872..28a2e1f4e2b4 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2458,7 +2458,7 @@ #ifndef BED_OVERSHOOT #define BED_OVERSHOOT 10 #endif - #define BED_MAX_TARGET (BED_MAXTEMP - (BED_OVERSHOOT)) + #define BED_MAX_TARGET ((BED_MAXTEMP) - (BED_OVERSHOOT)) #else #undef PIDTEMPBED #undef PREHEAT_BEFORE_LEVELING @@ -2469,8 +2469,8 @@ #ifndef COOLER_OVERSHOOT #define COOLER_OVERSHOOT 2 #endif - #define COOLER_MIN_TARGET (COOLER_MINTEMP + (COOLER_OVERSHOOT)) - #define COOLER_MAX_TARGET (COOLER_MAXTEMP - (COOLER_OVERSHOOT)) + #define COOLER_MIN_TARGET ((COOLER_MINTEMP) + (COOLER_OVERSHOOT)) + #define COOLER_MAX_TARGET ((COOLER_MAXTEMP) - (COOLER_OVERSHOOT)) #endif #if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_TEMP_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER || HAS_TEMP_BOARD || HAS_TEMP_SOC @@ -2482,7 +2482,7 @@ #ifndef CHAMBER_OVERSHOOT #define CHAMBER_OVERSHOOT 10 #endif - #define CHAMBER_MAX_TARGET (CHAMBER_MAXTEMP - (CHAMBER_OVERSHOOT)) + #define CHAMBER_MAX_TARGET ((CHAMBER_MAXTEMP) - (CHAMBER_OVERSHOOT)) #else #undef PIDTEMPCHAMBER #endif @@ -2767,20 +2767,26 @@ #endif // Servos -#if PIN_EXISTS(SERVO0) && NUM_SERVOS > 0 - #define HAS_SERVO_0 1 -#endif -#if PIN_EXISTS(SERVO1) && NUM_SERVOS > 1 - #define HAS_SERVO_1 1 -#endif -#if PIN_EXISTS(SERVO2) && NUM_SERVOS > 2 - #define HAS_SERVO_2 1 -#endif -#if PIN_EXISTS(SERVO3) && NUM_SERVOS > 3 - #define HAS_SERVO_3 1 -#endif #if NUM_SERVOS > 0 #define HAS_SERVOS 1 + #if PIN_EXISTS(SERVO0) + #define HAS_SERVO_0 1 + #endif + #if PIN_EXISTS(SERVO1) && NUM_SERVOS > 1 + #define HAS_SERVO_1 1 + #endif + #if PIN_EXISTS(SERVO2) && NUM_SERVOS > 2 + #define HAS_SERVO_2 1 + #endif + #if PIN_EXISTS(SERVO3) && NUM_SERVOS > 3 + #define HAS_SERVO_3 1 + #endif + #if PIN_EXISTS(SERVO4) && NUM_SERVOS > 4 + #define HAS_SERVO_4 1 + #endif + #if PIN_EXISTS(SERVO5) && NUM_SERVOS > 5 + #define HAS_SERVO_5 1 + #endif #if defined(PAUSE_SERVO_OUTPUT) && defined(RESUME_SERVO_OUTPUT) #define HAS_PAUSE_SERVO_OUTPUT 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index c3fed355d322..bab6fa1d0193 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -458,6 +458,8 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #if ENABLED(I2C_POSITION_ENCODERS) #if !ALL(BABYSTEPPING, BABYSTEP_XY) #error "I2C_POSITION_ENCODERS requires BABYSTEPPING and BABYSTEP_XY." + #elif DISABLED(EDITABLE_STEPS_PER_UNIT) + #error "EDITABLE_STEPS_PER_UNIT is required for I2C_POSITION_ENCODERS." #elif !WITHIN(I2CPE_ENCODER_CNT, 1, 5) #error "I2CPE_ENCODER_CNT must be between 1 and 5." #endif @@ -961,9 +963,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L /** * Limited number of servos */ -#if NUM_SERVOS > NUM_SERVO_PLUGS - #error "The selected board doesn't support enough servos for your configuration. Reduce NUM_SERVOS." -#endif +static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) is too large. The selected board only has " STRINGIFY(NUM_SERVO_PLUGS) " servos."); /** * Servo deactivation depends on servo endstops, switching nozzle, or switching extruder @@ -4123,8 +4123,12 @@ static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive." /** * Fixed-Time Motion limitations */ -#if ALL(FT_MOTION, MIXING_EXTRUDER) - #error "FT_MOTION does not currently support MIXING_EXTRUDER." +#if ENABLED(FT_MOTION) + #if ENABLED(MIXING_EXTRUDER) + #error "FT_MOTION does not currently support MIXING_EXTRUDER." + #elif DISABLED(FTM_UNIFIED_BWS) + #error "FT_MOTION requires FTM_UNIFIED_BWS to be enabled because FBS is not yet implemented." + #endif #endif // Multi-Stepping Limit diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 892d02c74514..f134f53e5f6f 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 "2024-01-06" + #define STRING_DISTRIBUTION_DATE "2024-01-10" #endif /** diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 560acf4cd863..519bb7651a67 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -826,3 +826,17 @@ #if PIN_EXISTS(BEEPER) && ALL(SPEAKER, NO_SPEAKER) #warning "The BEEPER cannot produce tones so you can disable SPEAKER." #endif + +/** + * Fixed-Time Motion + */ +#if ALL(FT_MOTION, I2S_STEPPER_STREAM) + #warning "FT_MOTION has not been tested with I2S_STEPPER_STREAM." +#endif + +/** + * User doesn't have or disabled G92? + */ +#if DISABLED(EDITABLE_STEPS_PER_UNIT) + #warning "EDITABLE_STEPS_PER_UNIT is required to enable G92 runtime configuration of steps-per-unit." +#endif diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 8156489f7bc5..ea6265b419a1 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -1619,23 +1619,27 @@ void hmiMaxAccelerationXYZE() { #endif // CLASSIC_JERK -void hmiStepXYZE() { - EncoderState encoder_diffState = encoderReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (applyEncoder(encoder_diffState, hmiValues.maxStepScaled)) { - checkkey = ID_Step; - encoderRate.enabled = false; +#if ENABLED(EDITABLE_STEPS_PER_UNIT) + + void hmiStepXYZE() { + EncoderState encoder_diffState = encoderReceiveAnalyze(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + if (applyEncoder(encoder_diffState, hmiValues.maxStepScaled)) { + checkkey = ID_Step; + encoderRate.enabled = false; + if (WITHIN(hmiFlag.step_axis, X_AXIS, LAST_AXIS)) + planner.settings.axis_steps_per_mm[hmiFlag.step_axis] = hmiValues.maxStepScaled / MINUNITMULT; + drawEditFloat3(select_step.now, hmiValues.maxStepScaled); + return; + } + // Step limit if (WITHIN(hmiFlag.step_axis, X_AXIS, LAST_AXIS)) - planner.settings.axis_steps_per_mm[hmiFlag.step_axis] = hmiValues.maxStepScaled / MINUNITMULT; - drawEditFloat3(select_step.now, hmiValues.maxStepScaled); - return; + LIMIT(hmiValues.maxStepScaled, min_steps_edit_values[hmiFlag.step_axis] * MINUNITMULT, max_steps_edit_values[hmiFlag.step_axis] * MINUNITMULT); + // Step value + drawEditFloat3(select_step.now, hmiValues.maxStepScaled, true); } - // Step limit - if (WITHIN(hmiFlag.step_axis, X_AXIS, LAST_AXIS)) - LIMIT(hmiValues.maxStepScaled, min_steps_edit_values[hmiFlag.step_axis] * MINUNITMULT, max_steps_edit_values[hmiFlag.step_axis] * MINUNITMULT); - // Step value - drawEditFloat3(select_step.now, hmiValues.maxStepScaled, true); -} + +#endif // EDITABLE_STEPS_PER_UNIT // Draw X, Y, Z and blink if in an un-homed or un-trusted state void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool blink, const bool force) { @@ -4077,11 +4081,13 @@ void dwinInitScreen() { } void dwinUpdate() { - eachMomentUpdate(); // Status update - hmiSDCardUpdate(); // SD card update - dwinHandleScreen(); // Rotary encoder update + eachMomentUpdate(); // Status update + hmiSDCardUpdate(); // SD card update + dwinHandleScreen(); // Rotary encoder update } +void MarlinUI::update() { dwinUpdate(); } + void eachMomentUpdate() { static millis_t next_var_update_ms = 0, next_rts_update_ms = 0; @@ -4277,7 +4283,9 @@ void dwinHandleScreen() { #if ENABLED(CLASSIC_JERK) case ID_MaxJerkValue: hmiMaxJerkXYZE(); break; #endif - case ID_StepValue: hmiStepXYZE(); break; + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case ID_StepValue: hmiStepXYZE(); break; + #endif default: break; } } diff --git a/Marlin/src/lcd/e3v2/creality/dwin.h b/Marlin/src/lcd/e3v2/creality/dwin.h index 17a7a965ee39..461c57f11cfb 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.h +++ b/Marlin/src/lcd/e3v2/creality/dwin.h @@ -204,7 +204,10 @@ void hmiPrintSpeed(); void hmiMaxFeedspeedXYZE(); void hmiMaxAccelerationXYZE(); void hmiMaxJerkXYZE(); -void hmiStepXYZE(); +#if ENABLED(EDITABLE_STEPS_PER_UNIT) + void hmiStepXYZE(); +#endif + void hmiSetLanguageCache(); void updateVariable(); diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 296f46f68a32..856229b0d845 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -114,7 +114,7 @@ #define MAX_FLOW_RATE 299 #define MIN_FLOW_RATE 10 - #define MAX_E_TEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT) + #define MAX_E_TEMP thermalManager.hotend_max_target(0) #define MIN_E_TEMP 0 #endif @@ -2364,6 +2364,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra else drawMenu(ID_MaxAcceleration); break; + #if ENABLED(CLASSIC_JERK) case MOTION_JERK: if (draw) @@ -2372,12 +2373,16 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenu(ID_MaxJerk); break; #endif - case MOTION_STEPS: - if (draw) - drawMenuItem(row, ICON_Step, GET_TEXT_F(MSG_STEPS_PER_MM), nullptr, true); - else - drawMenu(ID_Steps); - break; + + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case MOTION_STEPS: + if (draw) + drawMenuItem(row, ICON_Step, GET_TEXT_F(MSG_STEPS_PER_MM), nullptr, true); + else + drawMenu(ID_Steps); + break; + #endif + #if HAS_HOTEND case MOTION_FLOW: if (draw) { @@ -2388,6 +2393,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra modifyValue(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1, []{ planner.refresh_e_factor(0); }); break; #endif + #if ENABLED(LIN_ADVANCE) case MOTION_LA: if (draw) { @@ -2613,64 +2619,69 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra } break; #endif - case ID_Steps: - #define STEPS_BACK 0 - #define STEPS_X (STEPS_BACK + ENABLED(HAS_X_AXIS)) - #define STEPS_Y (STEPS_X + ENABLED(HAS_Y_AXIS)) - #define STEPS_Z (STEPS_Y + ENABLED(HAS_Z_AXIS)) - #define STEPS_E (STEPS_Z + ENABLED(HAS_HOTEND)) - #define STEPS_TOTAL STEPS_E + #if ENABLED(EDITABLE_STEPS_PER_UNIT) - switch (item) { - case STEPS_BACK: - if (draw) - drawMenuItem(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - drawMenu(ID_Motion, MOTION_STEPS); - break; - #if HAS_X_AXIS - case STEPS_X: - if (draw) { - drawMenuItem(row, ICON_StepX, GET_TEXT_F(MSG_A_STEPS)); - drawFloat(planner.settings.axis_steps_per_mm[X_AXIS], row, false, STEPS_UNIT); - } - else - modifyValue(planner.settings.axis_steps_per_mm[X_AXIS], min_steps_edit_values.x, max_steps_edit_values.x, STEPS_UNIT); - break; - #endif - #if HAS_Y_AXIS - case STEPS_Y: - if (draw) { - drawMenuItem(row, ICON_StepY, GET_TEXT_F(MSG_B_STEPS)); - drawFloat(planner.settings.axis_steps_per_mm[Y_AXIS], row, false, STEPS_UNIT); - } - else - modifyValue(planner.settings.axis_steps_per_mm[Y_AXIS], min_steps_edit_values.y, max_steps_edit_values.y, STEPS_UNIT); - break; - #endif - #if HAS_Z_AXIS - case STEPS_Z: - if (draw) { - drawMenuItem(row, ICON_StepZ, GET_TEXT_F(MSG_C_STEPS)); - drawFloat(planner.settings.axis_steps_per_mm[Z_AXIS], row, false, STEPS_UNIT); - } - else - modifyValue(planner.settings.axis_steps_per_mm[Z_AXIS], min_steps_edit_values.z, max_steps_edit_values.z, STEPS_UNIT); - break; - #endif - #if HAS_HOTEND - case STEPS_E: - if (draw) { - drawMenuItem(row, ICON_StepE, GET_TEXT_F(MSG_E_STEPS)); - drawFloat(planner.settings.axis_steps_per_mm[E_AXIS], row, false, STEPS_UNIT); - } + case ID_Steps: + + #define STEPS_BACK 0 + #define STEPS_X (STEPS_BACK + ENABLED(HAS_X_AXIS)) + #define STEPS_Y (STEPS_X + ENABLED(HAS_Y_AXIS)) + #define STEPS_Z (STEPS_Y + ENABLED(HAS_Z_AXIS)) + #define STEPS_E (STEPS_Z + ENABLED(HAS_HOTEND)) + #define STEPS_TOTAL STEPS_E + + switch (item) { + case STEPS_BACK: + if (draw) + drawMenuItem(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else - modifyValue(planner.settings.axis_steps_per_mm[E_AXIS], min_steps_edit_values.e, max_steps_edit_values.e, STEPS_UNIT); + drawMenu(ID_Motion, MOTION_STEPS); break; - #endif - } - break; + #if HAS_X_AXIS + case STEPS_X: + if (draw) { + drawMenuItem(row, ICON_StepX, GET_TEXT_F(MSG_A_STEPS)); + drawFloat(planner.settings.axis_steps_per_mm[X_AXIS], row, false, STEPS_UNIT); + } + else + modifyValue(planner.settings.axis_steps_per_mm[X_AXIS], min_steps_edit_values.x, max_steps_edit_values.x, STEPS_UNIT); + break; + #endif + #if HAS_Y_AXIS + case STEPS_Y: + if (draw) { + drawMenuItem(row, ICON_StepY, GET_TEXT_F(MSG_B_STEPS)); + drawFloat(planner.settings.axis_steps_per_mm[Y_AXIS], row, false, STEPS_UNIT); + } + else + modifyValue(planner.settings.axis_steps_per_mm[Y_AXIS], min_steps_edit_values.y, max_steps_edit_values.y, STEPS_UNIT); + break; + #endif + #if HAS_Z_AXIS + case STEPS_Z: + if (draw) { + drawMenuItem(row, ICON_StepZ, GET_TEXT_F(MSG_C_STEPS)); + drawFloat(planner.settings.axis_steps_per_mm[Z_AXIS], row, false, STEPS_UNIT); + } + else + modifyValue(planner.settings.axis_steps_per_mm[Z_AXIS], min_steps_edit_values.z, max_steps_edit_values.z, STEPS_UNIT); + break; + #endif + #if HAS_HOTEND + case STEPS_E: + if (draw) { + drawMenuItem(row, ICON_StepE, GET_TEXT_F(MSG_E_STEPS)); + drawFloat(planner.settings.axis_steps_per_mm[E_AXIS], row, false, STEPS_UNIT); + } + else + modifyValue(planner.settings.axis_steps_per_mm[E_AXIS], min_steps_edit_values.e, max_steps_edit_values.e, STEPS_UNIT); + break; + #endif + } + break; + + #endif // EDITABLE_STEPS_PER_UNIT case ID_Visual: @@ -4173,7 +4184,9 @@ FSTR_P JyersDWIN::getMenuTitle(const uint8_t menu) { #if ENABLED(CLASSIC_JERK) case ID_MaxJerk: return F("Max Jerk"); #endif - case ID_Steps: return GET_TEXT_F(MSG_STEPS_PER_MM); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case ID_Steps: return GET_TEXT_F(MSG_STEPS_PER_MM); + #endif case ID_Visual: return F("Visual Settings"); case ID_Advanced: return GET_TEXT_F(MSG_ADVANCED_SETTINGS); #if HAS_BED_PROBE @@ -4250,7 +4263,9 @@ uint8_t JyersDWIN::getMenuSize(const uint8_t menu) { #if ENABLED(CLASSIC_JERK) case ID_MaxJerk: return JERK_TOTAL; #endif - case ID_Steps: return STEPS_TOTAL; + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case ID_Steps: return STEPS_TOTAL; + #endif case ID_Visual: return VISUAL_TOTAL; case ID_Advanced: return ADVANCED_TOTAL; #if HAS_BED_PROBE diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.h b/Marlin/src/lcd/e3v2/jyersui/dwin.h index 050a4cb39eae..97c5a85adaa6 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.h @@ -101,7 +101,7 @@ enum menuID : uint8_t { ID_MaxSpeed, ID_MaxAcceleration, ID_MaxJerk, - ID_Steps, + OPTITEM(EDITABLE_STEPS_PER_UNIT, ID_Steps) ID_Visual, ID_ColorSettings, ID_Advanced, diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index a99a8c821913..d343444031b7 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -154,8 +154,8 @@ #endif // Editable temperature limits -#define MIN_ETEMP 0 -#define MAX_ETEMP (thermalManager.hotend_maxtemp[0] - (HOTEND_OVERSHOOT)) +#define MIN_ETEMP 0 +#define MAX_ETEMP thermalManager.hotend_max_target(0) #define MIN_BEDTEMP 0 #define MAX_BEDTEMP BED_MAX_TARGET @@ -3530,7 +3530,9 @@ void drawMotionMenu() { #if ENABLED(ADAPTIVE_STEP_SMOOTHING) EDIT_ITEM(ICON_UBLActive, MSG_STEP_SMOOTHING, onDrawChkbMenu, setAdaptiveStepSmoothing, &hmiData.adaptiveStepSmoothing); #endif - MENU_ITEM(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, drawStepsMenu); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + MENU_ITEM(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, drawStepsMenu); + #endif EDIT_ITEM(ICON_Flow, MSG_FLOW, onDrawPIntMenu, setFlow, &planner.flow_percentage[0]); EDIT_ITEM(ICON_Speed, MSG_SPEED, onDrawPIntMenu, setSpeed, &feedrate_percentage); } @@ -3708,25 +3710,29 @@ void drawMaxAccelMenu() { #endif // CLASSIC_JERK -void drawStepsMenu() { - checkkey = ID_Menu; - if (SET_MENU_R(stepsMenu, selrect({1, 16, 28, 13}), MSG_STEPS_PER_MM, 5)) { - BACK_ITEM(drawMotionMenu); - #if HAS_X_AXIS - EDIT_ITEM(ICON_StepX, MSG_A_STEPS, onDrawStepsX, setStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); - #endif - #if HAS_Y_AXIS - EDIT_ITEM(ICON_StepY, MSG_B_STEPS, onDrawStepsY, setStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); - #endif - #if HAS_Z_AXIS - EDIT_ITEM(ICON_StepZ, MSG_C_STEPS, onDrawStepsZ, setStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); - #endif - #if HAS_HOTEND - EDIT_ITEM(ICON_StepE, MSG_E_STEPS, onDrawStepsE, setStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); - #endif +#if ENABLED(EDITABLE_STEPS_PER_UNIT) + + void drawStepsMenu() { + checkkey = ID_Menu; + if (SET_MENU_R(stepsMenu, selrect({1, 16, 28, 13}), MSG_STEPS_PER_MM, 5)) { + BACK_ITEM(drawMotionMenu); + #if HAS_X_AXIS + EDIT_ITEM(ICON_StepX, MSG_A_STEPS, onDrawStepsX, setStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); + #endif + #if HAS_Y_AXIS + EDIT_ITEM(ICON_StepY, MSG_B_STEPS, onDrawStepsY, setStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); + #endif + #if HAS_Z_AXIS + EDIT_ITEM(ICON_StepZ, MSG_C_STEPS, onDrawStepsZ, setStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); + #endif + #if HAS_HOTEND + EDIT_ITEM(ICON_StepE, MSG_E_STEPS, onDrawStepsE, setStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); + #endif + } + updateMenu(stepsMenu); } - updateMenu(stepsMenu); -} + +#endif //============================================================================= // UI editable custom colors diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 675c087074ac..fe48822e4865 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -345,7 +345,9 @@ void drawMaxAccelMenu(); #if ENABLED(CLASSIC_JERK) void drawMaxJerkMenu(); #endif -void drawStepsMenu(); +#if ENABLED(EDITABLE_STEPS_PER_UNIT) + void drawStepsMenu(); +#endif #if ANY(HAS_BED_PROBE, BABYSTEPPING) void drawZOffsetWizMenu(); #endif 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 8b073652b044..f8cba1567694 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -697,8 +697,7 @@ void AnycubicTFT::getCommandFromTFT() { case 18: { // A18 set fan speed float fanPercent; if (codeSeen('S')) { - fanPercent = codeValue(); - fanPercent = constrain(fanPercent, 0, 100); + fanPercent = constrain(codeValue(), 0, 100); setTargetFan_percent(fanPercent, FAN0); } else diff --git a/Marlin/src/lcd/extui/anycubic_vyper/dgus_tft.cpp b/Marlin/src/lcd/extui/anycubic_vyper/dgus_tft.cpp index 3209aa76f248..ed4f8c73673a 100644 --- a/Marlin/src/lcd/extui/anycubic_vyper/dgus_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_vyper/dgus_tft.cpp @@ -1011,7 +1011,7 @@ namespace Anycubic { #if HAS_HOTEND else if (control_index == TXT_HOTEND_TARGET || control_index == TXT_ADJUST_HOTEND) { // hotend target temp control_value = (uint16_t(data_buf[4]) << 8) | uint16_t(data_buf[5]); - temp = constrain(uint16_t(control_value), 0, HEATER_0_MAXTEMP); + temp = constrain(uint16_t(control_value), 0, thermalManager.hotend_max_target(0)); setTargetTemp_celsius(temp, E0); //sprintf(str_buf,"%u/%u", (uint16_t)thermalManager.degHotend(0), uint16_t(control_value)); //sendTxtToTFT(str_buf, TXT_PRINT_HOTEND); @@ -1021,7 +1021,7 @@ namespace Anycubic { #if HAS_HEATED_BED else if (control_index == TXT_BED_TARGET || control_index == TXT_ADJUST_BED) {// bed target temp control_value = (uint16_t(data_buf[4]) << 8) | uint16_t(data_buf[5]); - temp = constrain(uint16_t(control_value), 0, BED_MAXTEMP); + temp = constrain(uint16_t(control_value), 0, BED_MAX_TARGET); setTargetTemp_celsius(temp, BED); //sprintf(str_buf,"%u/%u", uint16_t(thermalManager.degBed()), uint16_t(control_value)); //sendTxtToTFT(str_buf, TXT_PRINT_BED); diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index d440ea537539..4403716fff65 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -379,21 +379,21 @@ void DGUSScreenHandler::handleTemperatureChanged(DGUS_VP_Variable &var, void *va default: return; #if HAS_HOTEND case VP_T_E0_Set: - NOMORE(newvalue, HEATER_0_MAXTEMP); + NOMORE(newvalue, thermalManager.hotend_max_target(0)); thermalManager.setTargetHotend(newvalue, 0); acceptedvalue = thermalManager.degTargetHotend(0); break; #endif #if HAS_MULTI_HOTEND case VP_T_E1_Set: - NOMORE(newvalue, HEATER_1_MAXTEMP); + NOMORE(newvalue, thermalManager.hotend_max_target(1)); thermalManager.setTargetHotend(newvalue, 1); acceptedvalue = thermalManager.degTargetHotend(1); break; #endif #if HAS_HEATED_BED case VP_T_Bed_Set: - NOMORE(newvalue, BED_MAXTEMP); + NOMORE(newvalue, BED_MAX_TARGET); thermalManager.setTargetBed(newvalue); acceptedvalue = thermalManager.degTargetBed(); break; @@ -469,36 +469,40 @@ void DGUSScreenHandler::handleSettings(DGUS_VP_Variable &var, void *val_ptr) { } } -void DGUSScreenHandler::handleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t value_raw = BE16_P(val_ptr); - const float value = (float)value_raw / 10; - ExtUI::axis_t axis; - switch (var.VP) { - case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; - case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break; - case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; - default: return; +#if ENABLED(EDITABLE_STEPS_PER_UNIT) + + void DGUSScreenHandler::handleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { + const uint16_t value_raw = BE16_P(val_ptr); + const float value = (float)value_raw / 10; + ExtUI::axis_t axis; + switch (var.VP) { + case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; + case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break; + case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; + default: return; + } + ExtUI::setAxisSteps_per_mm(value, axis); + skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } - ExtUI::setAxisSteps_per_mm(value, axis); - skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel -} -void DGUSScreenHandler::handleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t value_raw = BE16_P(val_ptr); - const float value = (float)value_raw / 10; - ExtUI::extruder_t extruder; - switch (var.VP) { - default: return; - #if HAS_EXTRUDERS - case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; - #if HAS_MULTI_EXTRUDER - case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; + void DGUSScreenHandler::handleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { + const uint16_t value_raw = BE16_P(val_ptr); + const float value = (float)value_raw / 10; + ExtUI::extruder_t extruder; + switch (var.VP) { + default: return; + #if HAS_EXTRUDERS + case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; + #if HAS_MULTI_EXTRUDER + case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; + #endif #endif - #endif + } + ExtUI::setAxisSteps_per_mm(value, extruder); + skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } - ExtUI::setAxisSteps_per_mm(value, extruder); - skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel -} + +#endif // EDITABLE_STEPS_PER_UNIT #if HAS_PID_HEATING void DGUSScreenHandler::handlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr) { diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h b/Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h index 163a095d0819..3764920be1d0 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h @@ -80,8 +80,11 @@ class DGUSScreenHandler { #endif // Hook for settings static void handleSettings(DGUS_VP_Variable &var, void *val_ptr); - static void handleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); - static void handleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); + + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + static void handleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); + static void handleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); + #endif #if HAS_PID_HEATING // Hook for "Change this temperature PID para" diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp index 08d5387ceff3..243dbfbab6f2 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp @@ -431,13 +431,15 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, screen.sendPrintsTotalToDisplay), #endif - VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - #if HAS_EXTRUDERS - VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), - #if HAS_MULTI_EXTRUDER - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if HAS_EXTRUDERS + VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if HAS_MULTI_EXTRUDER + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #endif #endif #endif diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp index d99a4fe4f688..56d58a19b07f 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp @@ -424,13 +424,15 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, screen.sendPrintsTotalToDisplay), #endif - VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - #if HAS_HOTEND - VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), - #if HAS_MULTI_HOTEND - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if HAS_HOTEND + VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if HAS_MULTI_HOTEND + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #endif #endif #endif diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index 2b5b6d956e2a..5878d145ea76 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -646,9 +646,11 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, screen.sendPrintsTotalToDisplay), #endif - VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<0>), + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<0>), + #endif VPHELPER(VP_X_MAX_SPEED, &planner.settings.max_feedrate_mm_s[X_AXIS], screen.handleMaxSpeedChange, screen.sendFloatAsIntValueToDisplay<0>), VPHELPER(VP_Y_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Y_AXIS], screen.handleMaxSpeedChange, screen.sendFloatAsIntValueToDisplay<0>), @@ -742,10 +744,12 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_AutoTurnOffSw, nullptr, screen.getTurnOffCtrl, nullptr), - #if HAS_HOTEND - VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<0>), - #if HAS_MULTI_HOTEND - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<0>), + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + #if HAS_HOTEND + VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<0>), + #if HAS_MULTI_HOTEND + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<0>), + #endif #endif #endif diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 4c1995cebc24..4af271951d55 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -872,40 +872,44 @@ void DGUSScreenHandlerMKS::handleChangeLevelPoint(DGUS_VP_Variable &var, void *v skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandlerMKS::handleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t raw = BE16_P(val_ptr); - const float value = (float)raw; +#if ENABLED(EDITABLE_STEPS_PER_UNIT) - ExtUI::axis_t axis; - switch (var.VP) { - default: return; - case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; - case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break; - case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; + void DGUSScreenHandlerMKS::handleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { + const uint16_t raw = BE16_P(val_ptr); + const float value = (float)raw; + + ExtUI::axis_t axis; + switch (var.VP) { + default: return; + case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; + case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break; + case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; + } + ExtUI::setAxisSteps_per_mm(value, axis); + settings.save(); + skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } - ExtUI::setAxisSteps_per_mm(value, axis); - settings.save(); - skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel -} -void DGUSScreenHandlerMKS::handleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t raw = BE16_P(val_ptr); - const float value = (float)raw; + void DGUSScreenHandlerMKS::handleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { + const uint16_t raw = BE16_P(val_ptr); + const float value = (float)raw; - ExtUI::extruder_t extruder; - switch (var.VP) { - default: return; - #if HAS_HOTEND - case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; - #endif - #if HAS_MULTI_HOTEND - case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; - #endif + ExtUI::extruder_t extruder; + switch (var.VP) { + default: return; + #if HAS_HOTEND + case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; + #endif + #if HAS_MULTI_HOTEND + case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; + #endif + } + ExtUI::setAxisSteps_per_mm(value, extruder); + settings.save(); + skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } - ExtUI::setAxisSteps_per_mm(value, extruder); - settings.save(); - skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel -} + +#endif // EDITABLE_STEPS_PER_UNIT void DGUSScreenHandlerMKS::handleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) { const uint16_t raw = BE16_P(val_ptr); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h index 9527badb5a79..0e61080e67a4 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h @@ -63,8 +63,11 @@ class DGUSScreenHandlerMKS : public DGUSScreenHandler { static void lcdBLKAdjust(DGUS_VP_Variable &var, void *val_ptr); static void sdFileBack(DGUS_VP_Variable &var, void *val_ptr); - static void handleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); - static void handleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + static void handleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); + static void handleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); + #endif + static void handleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr); static void handleExtruderMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr); static void handleAccChange(DGUS_VP_Variable &var, void *val_ptr); diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp index d69041ebc5e0..8c82b63f3a41 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp @@ -232,13 +232,15 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, screen.sendPrintsTotalToDisplay), #endif - VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), - #if HAS_HOTEND - VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), - #if HAS_MULTI_HOTEND - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], screen.handleStepPerMMChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if HAS_HOTEND + VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #if HAS_MULTI_HOTEND + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], screen.handleStepPerMMExtruderChanged, screen.sendFloatAsIntValueToDisplay<1>), + #endif #endif #endif diff --git a/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSRxHandler.h b/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSRxHandler.h index 562edf950948..adbc1c628dca 100644 --- a/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSRxHandler.h +++ b/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSRxHandler.h @@ -51,11 +51,14 @@ namespace DGUSRxHandler { float maxJerk = dgus.fromFixedPoint(Endianness::fromBE_P(data)); ExtUI::setAxisMaxJerk_mm_s(maxJerk, axis); } - template - void stepsPerMM(DGUS_VP &vp, void *data) { - float stepsPerMm = dgus.fromFixedPoint(Endianness::fromBE_P(data)); - ExtUI::setAxisSteps_per_mm(stepsPerMm, axis); - } + + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + template + void stepsPerMM(DGUS_VP &vp, void *data) { + float stepsPerMm = dgus.fromFixedPoint(Endianness::fromBE_P(data)); + ExtUI::setAxisSteps_per_mm(stepsPerMm, axis); + } + #endif #if ENABLED(PIDTEMP) template diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index aa58e8569229..c953b417a53a 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -809,15 +809,19 @@ void DGUSRxHandler::pidSetTemp(DGUS_VP &vp, void *data_ptr) { switch (screen.pid_heater) { default: return; - case DGUS_Data::Heater::BED: - temp = constrain(temp, BED_MINTEMP, BED_MAX_TARGET); - break; - case DGUS_Data::Heater::H0: - temp = constrain(temp, HEATER_0_MINTEMP, (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT)); - break; + #if HAS_HEATED_BED + case DGUS_Data::Heater::BED: + LIMIT(temp, BED_MINTEMP, BED_MAX_TARGET); + break; + #endif + #if HAS_HOTEND + case DGUS_Data::Heater::H0: + LIMIT(temp, celsius_t(HEATER_0_MINTEMP), thermalManager.hotend_max_target(0)); + break; + #endif #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: - temp = constrain(temp, HEATER_1_MINTEMP, (HEATER_1_MAXTEMP - HOTEND_OVERSHOOT)); + LIMIT(temp, celsius_t(HEATER_1_MINTEMP), thermalManager.hotend_max_target(0)); break; #endif } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp index 76aa3de8727e..703c56d1e116 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp @@ -51,7 +51,7 @@ uint16_t DGUSScreenHandler::filament_length = DGUS_DEFAULT_FILAMENT_LEN; char DGUSScreenHandler::gcode[] = ""; DGUS_Data::Heater DGUSScreenHandler::pid_heater = DGUS_Data::Heater::H0; -uint16_t DGUSScreenHandler::pid_temp = DGUS_PLA_TEMP_HOTEND; +celsius_t DGUSScreenHandler::pid_temp = DGUS_PLA_TEMP_HOTEND; uint8_t DGUSScreenHandler::pid_cycles = 5; bool DGUSScreenHandler::settings_ready = false; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h index 27f7f92517ca..e5942ad44d5b 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h @@ -106,7 +106,7 @@ class DGUSScreenHandler { static char gcode[DGUS_GCODE_LEN + 1]; static DGUS_Data::Heater pid_heater; - static uint16_t pid_temp; + static celsius_t pid_temp; static uint8_t pid_cycles; static bool wait_continue; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp index 037eafcc9424..1212f715c008 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp @@ -31,7 +31,9 @@ #include "../ui_api.h" #include "../../../module/stepper.h" +#include "../../../module/temperature.h" #include "../../../module/printcounter.h" + #if ENABLED(ADVANCED_PAUSE_FEATURE) #include "../../../feature/pause.h" #endif @@ -266,15 +268,19 @@ void DGUSTxHandler::tempMax(DGUS_VP &vp) { switch (vp.addr) { default: return; - case DGUS_Addr::TEMP_Max_Bed: - temp = BED_MAX_TARGET; - break; - case DGUS_Addr::TEMP_Max_H0: - temp = HEATER_0_MAXTEMP - HOTEND_OVERSHOOT; - break; + #if HAS_HEATED_BED + case DGUS_Addr::TEMP_Max_Bed: + temp = BED_MAX_TARGET; + break; + #endif + #if HAS_HOTEND + case DGUS_Addr::TEMP_Max_H0: + temp = thermalManager.hotend_max_target(0); + break; + #endif #if HAS_MULTI_HOTEND case DGUS_Addr::TEMP_Max_H1: - temp = HEATER_1_MAXTEMP - HOTEND_OVERSHOOT; + temp = thermalManager.hotend_max_target(1); break; #endif } diff --git a/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp b/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp index 68581aeafd9b..8ff9fd9f7144 100644 --- a/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp +++ b/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp @@ -654,12 +654,19 @@ void RTS::handleData() { switch (recdat.addr) { case Flowrate: - case StepMM_X ... StepMM_E: + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case StepMM_X ... StepMM_E: + #endif case ProbeOffset_X ... ProbeOffset_Y: case HotendPID_AutoTmp ... BedPID_AutoTmp: case HotendPID_P ... HotendPID_D: case BedPID_P ... BedPID_D: - case T2Offset_X ... T2StepMM_E: + #if ENABLED(DUAL_X_CARRIAGE) + case T2Offset_X ... T2Offset_Z + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case T2StepMM_E: + #endif + #endif case Accel_X ... Accel_E: case Feed_X ... Feed_E: case Jerk_X ... Jerk_E: @@ -940,25 +947,33 @@ void RTS::handleData() { tmp_float_handling = (float(recdat.data[0]) - 65536) / 100; else tmp_float_handling = float(recdat.data[0]) / 100; - if (recdat.addr == StepMM_X) { - setAxisSteps_per_mm(tmp_float_handling * 10, X); - } - else if (recdat.addr == StepMM_Y) { - setAxisSteps_per_mm(tmp_float_handling * 10, Y); - } - else if (recdat.addr == StepMM_Z) { - setAxisSteps_per_mm(tmp_float_handling * 10, Z); - } - else if (recdat.addr == StepMM_E) { - setAxisSteps_per_mm(tmp_float_handling * 10, E0); - #if DISABLED(DUAL_X_CARRIAGE) - setAxisSteps_per_mm(tmp_float_handling * 10, E1); - #endif - } - #if ENABLED(DUAL_X_CARRIAGE) - else if (recdat.addr == T2StepMM_E) { - setAxisSteps_per_mm(tmp_float_handling * 10, E1); + + if (false) {} + + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + else if (recdat.addr == StepMM_X) { + setAxisSteps_per_mm(tmp_float_handling * 10, X); + } + else if (recdat.addr == StepMM_Y) { + setAxisSteps_per_mm(tmp_float_handling * 10, Y); + } + else if (recdat.addr == StepMM_Z) { + setAxisSteps_per_mm(tmp_float_handling * 10, Z); + } + else if (recdat.addr == StepMM_E) { + setAxisSteps_per_mm(tmp_float_handling * 10, E0); + #if DISABLED(DUAL_X_CARRIAGE) + setAxisSteps_per_mm(tmp_float_handling * 10, E1); + #endif } + #endif // EDITABLE_STEPS_PER_UNIT + + #if ENABLED(DUAL_X_CARRIAGE) + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + else if (recdat.addr == T2StepMM_E) { + setAxisSteps_per_mm(tmp_float_handling * 10, E1); + } + #endif else if (recdat.addr == T2Offset_X) { setNozzleOffset_mm(tmp_float_handling * 10, X, E1); } @@ -1655,9 +1670,9 @@ void RTS::handleData() { case AutolevelVal: { uint8_t meshPoint = (recdat.addr - AutolevelVal) / 2, - yPnt = floor(meshPoint / GRID_MAX_POINTS_X), - xPnt = meshPoint - (yPnt * GRID_MAX_POINTS_X); - if (yPnt % 2 != 0) xPnt = (GRID_MAX_POINTS_X - 1) - xPnt; // zag row + yPnt = meshPoint / (GRID_MAX_POINTS_X), + xPnt = meshPoint - yPnt * (GRID_MAX_POINTS_X); + if (yPnt % 2 != 0) xPnt = (GRID_MAX_POINTS_X) - 1 - xPnt; // zag row float meshVal = float(recdat.data[0] - (recdat.data[0] >= 32768 ? 65536 : 0)) / 1000; diff --git a/Marlin/src/lcd/extui/mks_ui/SPI_TFT.cpp b/Marlin/src/lcd/extui/mks_ui/SPI_TFT.cpp index 6cbe13e9fddb..236ff3f615ed 100644 --- a/Marlin/src/lcd/extui/mks_ui/SPI_TFT.cpp +++ b/Marlin/src/lcd/extui/mks_ui/SPI_TFT.cpp @@ -63,9 +63,7 @@ void TFT::lcdInit() { #if PIN_EXISTS(TFT_BACKLIGHT) OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif - #if HAS_LOGO_IN_FLASH - delay(2000); - #endif + TERN_(HAS_LOGO_IN_FLASH, delay(2000)); } void TFT::lcdClear(uint16_t color) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp index f0609f4ebbf7..1f703f365291 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp @@ -380,6 +380,7 @@ void lv_draw_dialog(uint8_t type) { lv_label_set_text(labelDialog, DIALOG_UPDATE_NO_DEVICE_EN); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); } + #if ENABLED(MKS_WIFI_MODULE) else if (DIALOG_IS(TYPE_UPLOAD_FILE)) { if (upload_result == 1) { @@ -391,28 +392,12 @@ void lv_draw_dialog(uint8_t type) { lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); } else if (upload_result == 3) { - char buf[200]; - int _index = 0; - - strcpy_P(buf, PSTR(DIALOG_UPLOAD_FINISH_EN)); - _index = strlen(buf); - buf[_index++] = '\n'; - strcat_P(buf, PSTR(DIALOG_UPLOAD_SIZE_EN)); - - _index = strlen(buf); - buf[_index++] = ':'; - sprintf_P(&buf[_index], PSTR(" %d KBytes\n"), (int)(upload_size / 1024)); - - strcat_P(buf, PSTR(DIALOG_UPLOAD_TIME_EN)); - _index = strlen(buf); - buf[_index++] = ':'; - sprintf_P(&buf[_index], PSTR(" %d s\n"), (int)upload_time_sec); - - strcat_P(buf, PSTR(DIALOG_UPLOAD_SPEED_EN)); - _index = strlen(buf); - buf[_index++] = ':'; - sprintf_P(&buf[_index], PSTR(" %d KBytes/s\n"), (int)(upload_size / upload_time_sec / 1024)); - + MString<200> buf( + F(DIALOG_UPLOAD_FINISH_EN), '\n', + F(DIALOG_UPLOAD_SIZE_EN), F(": "), int(upload_size / 1024), F(" KBytes\n"), + F(DIALOG_UPLOAD_TIME_EN), F(": "), int(upload_time_sec), F(" s\n"), + F(DIALOG_UPLOAD_SPEED_EN), F(": "), int(upload_size / upload_time_sec / 1024), F(" KBytes/s\n"), + ); lv_label_set_text(labelDialog, buf); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); } @@ -422,6 +407,7 @@ void lv_draw_dialog(uint8_t type) { lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); } #endif // MKS_WIFI_MODULE + else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT)) { lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); @@ -491,7 +477,11 @@ void filament_dialog_handle() { planner.synchronize(); uiCfg.filament_loading_time_flg = true; uiCfg.filament_loading_time_cnt = 0; - sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_load_length, gCfgItems.filamentchange_load_speed); + #if HAS_TOOLCHANGE + sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_load_length, gCfgItems.filamentchange_load_speed); + #else + sprintf_P(public_buf_m, PSTR("G91\nG1 E%d F%d\nG90"), gCfgItems.filamentchange_load_length, gCfgItems.filamentchange_load_speed); + #endif queue.inject(public_buf_m); } if (uiCfg.filament_heat_completed_unload) { @@ -501,7 +491,11 @@ void filament_dialog_handle() { planner.synchronize(); uiCfg.filament_unloading_time_flg = true; uiCfg.filament_unloading_time_cnt = 0; - sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E-%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_unload_length, gCfgItems.filamentchange_unload_speed); + #if HAS_TOOLCHANGE + sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E-%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_unload_length, gCfgItems.filamentchange_unload_speed); + #else + sprintf_P(public_buf_m, PSTR("G91\nG1 E-%d F%d\nG90"), gCfgItems.filamentchange_unload_length, gCfgItems.filamentchange_unload_speed); + #endif queue.inject(public_buf_m); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_motor_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_motor_settings.cpp index df17ac7687b9..08e2dd876331 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_motor_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_motor_settings.cpp @@ -34,7 +34,7 @@ static lv_obj_t *scr; enum { ID_MOTOR_RETURN = 1, - ID_MOTOR_STEPS, + OPTITEM(EDITABLE_STEPS_PER_UNIT, ID_MOTOR_STEPS) ID_MOTOR_TMC_CURRENT, ID_MOTOR_STEP_MODE, ID_HOME_SENSE @@ -44,26 +44,20 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; lv_clear_motor_settings(); switch (obj->mks_obj_id) { - case ID_MOTOR_RETURN: - draw_return_ui(); - break; - case ID_MOTOR_STEPS: - lv_draw_step_settings(); - break; + case ID_MOTOR_RETURN: draw_return_ui(); break; + + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case ID_MOTOR_STEPS: lv_draw_step_settings(); break; + #endif + #if USE_SENSORLESS - case ID_HOME_SENSE: - lv_draw_homing_sensitivity_settings(); - break; + case ID_HOME_SENSE: lv_draw_homing_sensitivity_settings(); break; #endif #if HAS_TRINAMIC_CONFIG - case ID_MOTOR_TMC_CURRENT: - lv_draw_tmc_current_settings(); - break; + case ID_MOTOR_TMC_CURRENT: lv_draw_tmc_current_settings(); break; #if HAS_STEALTHCHOP - case ID_MOTOR_STEP_MODE: - lv_draw_tmc_step_mode_settings(); - break; + case ID_MOTOR_STEP_MODE: lv_draw_tmc_step_mode_settings(); break; #endif #endif } @@ -73,17 +67,19 @@ void lv_draw_motor_settings() { int index = 0; scr = lv_screen_create(MOTOR_SETTINGS_UI, machine_menu.MotorConfTitle); - lv_screen_menu_item(scr, machine_menu.StepsConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MOTOR_STEPS, index++); + + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + lv_screen_menu_item(scr, machine_menu.StepsConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MOTOR_STEPS, index++); + #endif + #if USE_SENSORLESS - lv_screen_menu_item(scr, machine_menu.HomingSensitivityConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_HOME_SENSE, index); - index++; + lv_screen_menu_item(scr, machine_menu.HomingSensitivityConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_HOME_SENSE, index++); #endif + #if HAS_TRINAMIC_CONFIG - lv_screen_menu_item(scr, machine_menu.TMCcurrentConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_TMC_CURRENT, index); - index++; + lv_screen_menu_item(scr, machine_menu.TMCcurrentConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_TMC_CURRENT, index++); #if HAS_STEALTHCHOP - lv_screen_menu_item(scr, machine_menu.TMCStepModeConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_STEP_MODE, index); - index++; + lv_screen_menu_item(scr, machine_menu.TMCStepModeConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_STEP_MODE, index++); #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_MOTOR_RETURN, true); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp index c39678ed0f88..b1444fae11c4 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp @@ -56,15 +56,9 @@ static bool point_flag = true; enum { ID_NUM_KEY1 = 1, - ID_NUM_KEY2, - ID_NUM_KEY3, - ID_NUM_KEY4, - ID_NUM_KEY5, - ID_NUM_KEY6, - ID_NUM_KEY7, - ID_NUM_KEY8, - ID_NUM_KEY9, - ID_NUM_KEY0, + ID_NUM_KEY2, ID_NUM_KEY3, ID_NUM_KEY4, + ID_NUM_KEY5, ID_NUM_KEY6, ID_NUM_KEY7, + ID_NUM_KEY8, ID_NUM_KEY9, ID_NUM_KEY0, ID_NUM_BACK, ID_NUM_RESET, ID_NUM_CONFIRM, @@ -86,201 +80,136 @@ static void disp_key_value() { case TravelAcceleration: dtostrf(planner.settings.travel_acceleration, 1, 1, public_buf_m); break; - case XAcceleration: - itoa(planner.settings.max_acceleration_mm_per_s2[X_AXIS], public_buf_m, 10); - break; - case YAcceleration: - itoa(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], public_buf_m, 10); - break; - case ZAcceleration: - itoa(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], public_buf_m, 10); - break; - case E0Acceleration: - itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS], public_buf_m, 10); - break; - case E1Acceleration: - itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], public_buf_m, 10); - break; - case XMaxFeedRate: - dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_m); - break; - case YMaxFeedRate: - dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_m); - break; - case ZMaxFeedRate: - dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_m); - break; - case E0MaxFeedRate: - dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, public_buf_m); - break; - case E1MaxFeedRate: - dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, public_buf_m); - break; - case XJerk: - #if ENABLED(CLASSIC_JERK) - dtostrf(planner.max_jerk.x, 1, 1, public_buf_m); + #if HAS_X_AXIS + case XAcceleration: itoa(planner.settings.max_acceleration_mm_per_s2[X_AXIS], public_buf_m, 10); break; + #endif + #if HAS_Y_AXIS + case YAcceleration: itoa(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], public_buf_m, 10); break; + #endif + #if HAS_Z_AXIS + case ZAcceleration: itoa(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], public_buf_m, 10); break; + #endif + #if HAS_EXTRUDERS + case E0Acceleration: + itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS], public_buf_m, 10); + break; + #if HAS_MULTI_EXTRUDER + case E1Acceleration: + itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], public_buf_m, 10); + break; #endif - break; - case YJerk: - #if ENABLED(CLASSIC_JERK) - dtostrf(planner.max_jerk.y, 1, 1, public_buf_m); + #endif + + #if HAS_X_AXIS + case XMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_m); break; + #endif + #if HAS_Y_AXIS + case YMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_m); break; + #endif + #if HAS_Z_AXIS + case ZMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_m); break; + #endif + #if HAS_EXTRUDERS + case E0MaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, public_buf_m); break; + #if HAS_MULTI_EXTRUDER + case E1MaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, public_buf_m); break; #endif - break; - case ZJerk: - #if ENABLED(CLASSIC_JERK) - dtostrf(planner.max_jerk.z, 1, 1, public_buf_m); + #endif + + #if ENABLED(CLASSIC_JERK) + #if HAS_X_AXIS + case XJerk: dtostrf(planner.max_jerk.x, 1, 1, public_buf_m); break; #endif - break; - case EJerk: - #if ENABLED(CLASSIC_JERK) - dtostrf(planner.max_jerk.e, 1, 1, public_buf_m); + #if HAS_Y_AXIS + case YJerk: dtostrf(planner.max_jerk.y, 1, 1, public_buf_m); break; #endif - break; - - case Xstep: - dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_m); - break; - case Ystep: - dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_m); - - break; - case Zstep: - dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_m); - - break; - case E0step: - dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, public_buf_m); - - break; - case E1step: - dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, public_buf_m); - break; - - case Xcurrent: - #if AXIS_IS_TMC(X) - milliamps = stepperX.getMilliamps(); - dtostrf(milliamps, 1, 1, public_buf_m); + #if HAS_Z_AXIS + case ZJerk: dtostrf(planner.max_jerk.z, 1, 1, public_buf_m); break; #endif - break; - - case Ycurrent: - #if AXIS_IS_TMC(Y) - milliamps = stepperY.getMilliamps(); - dtostrf(milliamps, 1, 1, public_buf_m); + #if HAS_EXTRUDERS + case EJerk: dtostrf(planner.max_jerk.e, 1, 1, public_buf_m); break; #endif - break; + #endif - case Zcurrent: - #if AXIS_IS_TMC(Z) - milliamps = stepperZ.getMilliamps(); - dtostrf(milliamps, 1, 1, public_buf_m); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + #if HAS_X_AXIS + case Xstep: dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_m); break; #endif - break; - - case E0current: - #if AXIS_IS_TMC(E0) - milliamps = stepperE0.getMilliamps(); - dtostrf(milliamps, 1, 1, public_buf_m); + #if HAS_Y_AXIS + case Ystep: dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_m); break; #endif - break; - - case E1current: - #if AXIS_IS_TMC(E1) - milliamps = stepperE1.getMilliamps(); - dtostrf(milliamps, 1, 1, public_buf_m); + #if HAS_Z_AXIS + case Zstep: dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_m); break; #endif - break; - - case pause_pos_x: - dtostrf(gCfgItems.pausePosX, 1, 1, public_buf_m); - break; - case pause_pos_y: - dtostrf(gCfgItems.pausePosY, 1, 1, public_buf_m); - break; - case pause_pos_z: - dtostrf(gCfgItems.pausePosZ, 1, 1, public_buf_m); - break; - case level_pos_x1: - itoa(gCfgItems.trammingPos[0].x, public_buf_m, 10); - break; - case level_pos_y1: - itoa(gCfgItems.trammingPos[0].y, public_buf_m, 10); - break; - case level_pos_x2: - itoa(gCfgItems.trammingPos[1].x, public_buf_m, 10); - break; - case level_pos_y2: - itoa(gCfgItems.trammingPos[1].y, public_buf_m, 10); - break; - case level_pos_x3: - itoa(gCfgItems.trammingPos[2].x, public_buf_m, 10); - break; - case level_pos_y3: - itoa(gCfgItems.trammingPos[2].y, public_buf_m, 10); - break; - case level_pos_x4: - itoa(gCfgItems.trammingPos[3].x, public_buf_m, 10); - break; - case level_pos_y4: - itoa(gCfgItems.trammingPos[3].y, public_buf_m, 10); - break; - case level_pos_x5: - itoa(gCfgItems.trammingPos[4].x, public_buf_m, 10); - break; - case level_pos_y5: - itoa(gCfgItems.trammingPos[4].y, public_buf_m, 10); - break; - #if HAS_BED_PROBE - case x_offset: - #if HAS_PROBE_XY_OFFSET - dtostrf(probe.offset.x, 1, 3, public_buf_m); - #endif - break; - case y_offset: - #if HAS_PROBE_XY_OFFSET - dtostrf(probe.offset.y, 1, 3, public_buf_m); + #if HAS_EXTRUDERS + case E0step: dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, public_buf_m); break; + #if HAS_MULTI_EXTRUDER + case E1step: dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, public_buf_m); break; #endif - break; - case z_offset: - dtostrf(probe.offset.z, 1, 3, public_buf_m); - break; - #endif - case load_length: - itoa(gCfgItems.filamentchange_load_length, public_buf_m, 10); - break; - case load_speed: - itoa(gCfgItems.filamentchange_load_speed, public_buf_m, 10); - break; - case unload_length: - itoa(gCfgItems.filamentchange_unload_length, public_buf_m, 10); - break; - case unload_speed: - itoa(gCfgItems.filamentchange_unload_speed, public_buf_m, 10); - break; - case filament_temp: - itoa(gCfgItems.filament_limit_temp, public_buf_m, 10); - break; - case x_sensitivity: - #if X_SENSORLESS - itoa(TERN(X_SENSORLESS, stepperX.homing_threshold(), 0), public_buf_m, 10); #endif - break; - case y_sensitivity: - #if Y_SENSORLESS - itoa(TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0), public_buf_m, 10); - #endif - break; - case z_sensitivity: - #if Z_SENSORLESS - itoa(TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0), public_buf_m, 10); + #endif + + #if AXIS_IS_TMC(X) + case Xcurrent: dtostrf(stepperX.getMilliamps(), 1, 1, public_buf_m); break; + #endif + #if AXIS_IS_TMC(Y) + case Ycurrent: dtostrf(stepperY.getMilliamps(), 1, 1, public_buf_m); break; + #endif + #if AXIS_IS_TMC(Z) + case Zcurrent: dtostrf(stepperZ.getMilliamps(), 1, 1, public_buf_m); break; + #endif + #if AXIS_IS_TMC(E0) + case E0current: dtostrf(stepperE0.getMilliamps(), 1, 1, public_buf_m); break; + #endif + #if AXIS_IS_TMC(E1) + case E1current: dtostrf(stepperE1.getMilliamps(), 1, 1, public_buf_m); break; + #endif + + case pause_pos_x: dtostrf(gCfgItems.pausePosX, 1, 1, public_buf_m); break; + case pause_pos_y: dtostrf(gCfgItems.pausePosY, 1, 1, public_buf_m); break; + case pause_pos_z: dtostrf(gCfgItems.pausePosZ, 1, 1, public_buf_m); break; + + case level_pos_x1: itoa(gCfgItems.trammingPos[0].x, public_buf_m, 10); break; + case level_pos_y1: itoa(gCfgItems.trammingPos[0].y, public_buf_m, 10); break; + case level_pos_x2: itoa(gCfgItems.trammingPos[1].x, public_buf_m, 10); break; + case level_pos_y2: itoa(gCfgItems.trammingPos[1].y, public_buf_m, 10); break; + case level_pos_x3: itoa(gCfgItems.trammingPos[2].x, public_buf_m, 10); break; + case level_pos_y3: itoa(gCfgItems.trammingPos[2].y, public_buf_m, 10); break; + case level_pos_x4: itoa(gCfgItems.trammingPos[3].x, public_buf_m, 10); break; + case level_pos_y4: itoa(gCfgItems.trammingPos[3].y, public_buf_m, 10); break; + case level_pos_x5: itoa(gCfgItems.trammingPos[4].x, public_buf_m, 10); break; + case level_pos_y5: itoa(gCfgItems.trammingPos[4].y, public_buf_m, 10); break; + + #if HAS_BED_PROBE + #if HAS_PROBE_XY_OFFSET + case x_offset: dtostrf(probe.offset.x, 1, 3, public_buf_m); break; #endif - break; - case z2_sensitivity: - #if Z2_SENSORLESS - itoa(TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0), public_buf_m, 10); + #if HAS_PROBE_XY_OFFSET + case y_offset: dtostrf(probe.offset.y, 1, 3, public_buf_m); break; #endif - break; + case z_offset: dtostrf(probe.offset.z, 1, 3, public_buf_m); break; + #endif + + // TODO: Use built-in filament change instead of the MKS UI implementation + case load_length: itoa(gCfgItems.filamentchange_load_length, public_buf_m, 10); break; + case load_speed: itoa(gCfgItems.filamentchange_load_speed, public_buf_m, 10); break; + case unload_length: itoa(gCfgItems.filamentchange_unload_length, public_buf_m, 10); break; + case unload_speed: itoa(gCfgItems.filamentchange_unload_speed, public_buf_m, 10); break; + case filament_temp: itoa(gCfgItems.filament_limit_temp, public_buf_m, 10); break; + + #if X_SENSORLESS + case x_sensitivity: itoa(TERN(X_SENSORLESS, stepperX.homing_threshold(), 0), public_buf_m, 10); break; + #endif + #if Y_SENSORLESS + case y_sensitivity: itoa(TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0), public_buf_m, 10); break; + #endif + #if Z_SENSORLESS + case z_sensitivity: itoa(TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0), public_buf_m, 10); break; + #endif + #if Z2_SENSORLESS + case z2_sensitivity: itoa(TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0), public_buf_m, 10); break; + #endif } strcpy(key_value, public_buf_m); @@ -297,53 +226,74 @@ static void set_value_confirm() { case PrintAcceleration: planner.settings.acceleration = atof(key_value); break; case RetractAcceleration: planner.settings.retract_acceleration = atof(key_value); break; case TravelAcceleration: planner.settings.travel_acceleration = atof(key_value); break; - case XAcceleration: planner.settings.max_acceleration_mm_per_s2[X_AXIS] = atof(key_value); break; - case YAcceleration: planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = atof(key_value); break; - case ZAcceleration: planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = atof(key_value); break; - case E0Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS] = atof(key_value); break; - case E1Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)] = atof(key_value); break; - case XMaxFeedRate: planner.settings.max_feedrate_mm_s[X_AXIS] = atof(key_value); break; - case YMaxFeedRate: planner.settings.max_feedrate_mm_s[Y_AXIS] = atof(key_value); break; - case ZMaxFeedRate: planner.settings.max_feedrate_mm_s[Z_AXIS] = atof(key_value); break; - case E0MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS] = atof(key_value); break; - case E1MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); break; - case XJerk: TERN_(CLASSIC_JERK, planner.max_jerk.x = atof(key_value)); break; - case YJerk: TERN_(CLASSIC_JERK, planner.max_jerk.y = atof(key_value)); break; - case ZJerk: TERN_(CLASSIC_JERK, planner.max_jerk.z = atof(key_value)); break; - case EJerk: TERN_(CLASSIC_JERK, planner.max_jerk.e = atof(key_value)); break; - case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); planner.refresh_positioning(); break; - case Ystep: planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); planner.refresh_positioning(); break; - case Zstep: planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); planner.refresh_positioning(); break; - case E0step: planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value); planner.refresh_positioning(); break; - case E1step: planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); planner.refresh_positioning(); break; - case Xcurrent: - #if AXIS_IS_TMC(X) - stepperX.rms_current(atoi(key_value)); - #endif - break; - case Ycurrent: - #if AXIS_IS_TMC(Y) - stepperY.rms_current(atoi(key_value)); - #endif - break; - case Zcurrent: - #if AXIS_IS_TMC(Z) - stepperZ.rms_current(atoi(key_value)); - #endif - break; - case E0current: - #if AXIS_IS_TMC(E0) - stepperE0.rms_current(atoi(key_value)); - #endif - break; - case E1current: - #if AXIS_IS_TMC(E1) - stepperE1.rms_current(atoi(key_value)); + + #if HAS_X_AXIS + case XAcceleration: planner.settings.max_acceleration_mm_per_s2[X_AXIS] = atof(key_value); break; + #endif + #if HAS_Y_AXIS + case YAcceleration: planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = atof(key_value); break; + #endif + #if HAS_Z_AXIS + case ZAcceleration: planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = atof(key_value); break; + #endif + #if HAS_EXTRUDERS + case E0Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS] = atof(key_value); break; + #if HAS_MULTI_EXTRUDER + case E1Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)] = atof(key_value); break; #endif - break; + #endif + + #if HAS_X_AXIS + case XMaxFeedRate: planner.settings.max_feedrate_mm_s[X_AXIS] = atof(key_value); break; + #endif + #if HAS_Y_AXIS + case YMaxFeedRate: planner.settings.max_feedrate_mm_s[Y_AXIS] = atof(key_value); break; + #endif + #if HAS_Z_AXIS + case ZMaxFeedRate: planner.settings.max_feedrate_mm_s[Z_AXIS] = atof(key_value); break; + #endif + #if HAS_E0_AXIS + case E0MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS] = atof(key_value); break; + #endif + #if HAS_E1_AXIS + case E1MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); break; + #endif + + #if ENABLED(CLASSIC_JERK) + case XJerk: planner.max_jerk.x = atof(key_value); break; + case YJerk: planner.max_jerk.y = atof(key_value); break; + case ZJerk: planner.max_jerk.z = atof(key_value); break; + case EJerk: planner.max_jerk.e = atof(key_value); break; + #endif + + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); planner.refresh_positioning(); break; + case Ystep: planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); planner.refresh_positioning(); break; + case Zstep: planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); planner.refresh_positioning(); break; + case E0step: planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value); planner.refresh_positioning(); break; + case E1step: planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); planner.refresh_positioning(); break; + #endif + + #if AXIS_IS_TMC(X) + case Xcurrent: stepperX.rms_current(atoi(key_value)); break; + #endif + #if AXIS_IS_TMC(Y) + case Ycurrent: stepperY.rms_current(atoi(key_value)); break; + #endif + #if AXIS_IS_TMC(Z) + case Zcurrent: stepperZ.rms_current(atoi(key_value)); break; + #endif + #if AXIS_IS_TMC(E0) + case E0current: stepperE0.rms_current(atoi(key_value)); break; + #endif + #if AXIS_IS_TMC(E1) + case E1current: stepperE1.rms_current(atoi(key_value)); break; + #endif + case pause_pos_x: gCfgItems.pausePosX = atof(key_value); update_spi_flash(); break; case pause_pos_y: gCfgItems.pausePosY = atof(key_value); update_spi_flash(); break; case pause_pos_z: gCfgItems.pausePosZ = atof(key_value); update_spi_flash(); break; + case level_pos_x1: gCfgItems.trammingPos[0].x = atoi(key_value); update_spi_flash(); break; case level_pos_y1: gCfgItems.trammingPos[0].y = atoi(key_value); update_spi_flash(); break; case level_pos_x2: gCfgItems.trammingPos[1].x = atoi(key_value); update_spi_flash(); break; @@ -354,51 +304,51 @@ static void set_value_confirm() { case level_pos_y4: gCfgItems.trammingPos[3].y = atoi(key_value); update_spi_flash(); break; case level_pos_x5: gCfgItems.trammingPos[4].x = atoi(key_value); update_spi_flash(); break; case level_pos_y5: gCfgItems.trammingPos[4].y = atoi(key_value); update_spi_flash(); break; + #if HAS_BED_PROBE - case x_offset: { - #if HAS_PROBE_XY_OFFSET + #if HAS_PROBE_XY_OFFSET + case x_offset: { const float x = atof(key_value); - if (WITHIN(x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX)) - probe.offset.x = x; - #endif - } break; - case y_offset: { - #if HAS_PROBE_XY_OFFSET + if (WITHIN(x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX)) probe.offset.x = x; + } break; + #endif + #if HAS_PROBE_XY_OFFSET + case y_offset: { const float y = atof(key_value); - if (WITHIN(y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX)) - probe.offset.y = y; - #endif - } break; + if (WITHIN(y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX)) probe.offset.y = y; + } break; + #endif case z_offset: { const float z = atof(key_value); - if (WITHIN(z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) - probe.offset.z = z; + if (WITHIN(z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) probe.offset.z = z; } break; #endif + case load_length: gCfgItems.filamentchange_load_length = atoi(key_value); - uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5); + uiCfg.filament_loading_time = uint32_t((gCfgItems.filamentchange_load_length * 60.0f / gCfgItems.filamentchange_load_speed) + 0.5f); update_spi_flash(); break; case load_speed: gCfgItems.filamentchange_load_speed = atoi(key_value); - uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5); + uiCfg.filament_loading_time = uint32_t((gCfgItems.filamentchange_load_length * 60.0f / gCfgItems.filamentchange_load_speed) + 0.5f); update_spi_flash(); break; case unload_length: gCfgItems.filamentchange_unload_length = atoi(key_value); - uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5); + uiCfg.filament_unloading_time = uint32_t((gCfgItems.filamentchange_unload_length * 60.0f / gCfgItems.filamentchange_unload_speed) + 0.5f); update_spi_flash(); break; case unload_speed: gCfgItems.filamentchange_unload_speed = atoi(key_value); - uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5); + uiCfg.filament_unloading_time = uint32_t((gCfgItems.filamentchange_unload_length * 60.0f / gCfgItems.filamentchange_unload_speed) + 0.5f); update_spi_flash(); break; case filament_temp: gCfgItems.filament_limit_temp = atoi(key_value); update_spi_flash(); break; + case x_sensitivity: TERN_(X_SENSORLESS, stepperX.homing_threshold(atoi(key_value))); break; case y_sensitivity: TERN_(Y_SENSORLESS, stepperY.homing_threshold(atoi(key_value))); break; case z_sensitivity: TERN_(Z_SENSORLESS, stepperZ.homing_threshold(atoi(key_value))); break; @@ -530,9 +480,8 @@ void lv_draw_number_key() { } void lv_clear_number_key() { - #if HAS_ROTARY_ENCODER - if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); - #endif + if (TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable)) + lv_group_remove_all_objs(g); lv_obj_del(scr); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_step_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_step_settings.cpp index 4807a63a2c85..ba19173f3132 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_step_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_step_settings.cpp @@ -22,7 +22,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if HAS_TFT_LVGL_UI +#if ALL(HAS_TFT_LVGL_UI, EDITABLE_STEPS_PER_UNIT) #include "draw_ui.h" #include @@ -114,4 +114,4 @@ void lv_clear_step_settings() { lv_obj_del(scr); } -#endif // HAS_TFT_LVGL_UI +#endif // HAS_TFT_LVGL_UI && EDITABLE_STEPS_PER_UNIT diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 13dbb5dee5ff..61ab345dd76e 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -1059,7 +1059,9 @@ void draw_return_ui() { case DELTA_LEVELING_PARA_UI: break; case MANUAL_LEVELING_POSITION_UI: lv_draw_tramming_pos_settings(); break; case MAXFEEDRATE_UI: lv_draw_max_feedrate_settings(); break; - case STEPS_UI: lv_draw_step_settings(); break; + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + case STEPS_UI: lv_draw_step_settings(); break; + #endif case ACCELERATION_UI: lv_draw_acceleration_settings(); break; #if ENABLED(CLASSIC_JERK) case JERK_UI: lv_draw_jerk_settings(); break; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/mks_ui/draw_ui.h index da43f2a49098..10b8dcee2875 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.h @@ -294,9 +294,7 @@ typedef enum { LEVELING_UI, MESHLEVELING_UI, BIND_UI, - #if HAS_BED_PROBE - NOZZLE_PROBE_OFFSET_UI, - #endif + OPTITEM(HAS_BED_PROBE, NOZZLE_PROBE_OFFSET_UI) TOOL_UI, HARDWARE_TEST_UI, WIFI_LIST_UI, @@ -402,11 +400,11 @@ typedef enum { level_pos_y4, level_pos_x5, level_pos_y5, + #if HAS_BED_PROBE - x_offset, - y_offset, - z_offset, + x_offset, y_offset, z_offset, #endif + load_length, load_speed, unload_length, 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 aaddbcb892d2..c4cf725dbbc4 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp @@ -208,12 +208,14 @@ void machine_setting_disp() { machine_menu.Z_Jerk = Z_JERK_CN; machine_menu.E_Jerk = E_JERK_CN; - machine_menu.StepsConfTitle = STEPS_CONF_TITLE_CN; - machine_menu.X_Steps = X_STEPS_CN; - machine_menu.Y_Steps = Y_STEPS_CN; - machine_menu.Z_Steps = Z_STEPS_CN; - machine_menu.E0_Steps = E0_STEPS_CN; - machine_menu.E1_Steps = E1_STEPS_CN; + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + machine_menu.StepsConfTitle = STEPS_CONF_TITLE_CN; + machine_menu.X_Steps = X_STEPS_CN; + machine_menu.Y_Steps = Y_STEPS_CN; + machine_menu.Z_Steps = Z_STEPS_CN; + machine_menu.E0_Steps = E0_STEPS_CN; + machine_menu.E1_Steps = E1_STEPS_CN; + #endif machine_menu.TmcCurrentConfTitle = TMC_CURRENT_CONF_TITLE_CN; machine_menu.X_Current = X_TMC_CURRENT_CN; @@ -436,12 +438,14 @@ void machine_setting_disp() { machine_menu.Z_Jerk = Z_JERK_T_CN; machine_menu.E_Jerk = E_JERK_T_CN; - machine_menu.StepsConfTitle = STEPS_CONF_TITLE_T_CN; - machine_menu.X_Steps = X_STEPS_T_CN; - machine_menu.Y_Steps = Y_STEPS_T_CN; - machine_menu.Z_Steps = Z_STEPS_T_CN; - machine_menu.E0_Steps = E0_STEPS_T_CN; - machine_menu.E1_Steps = E1_STEPS_T_CN; + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + machine_menu.StepsConfTitle = STEPS_CONF_TITLE_T_CN; + machine_menu.X_Steps = X_STEPS_T_CN; + machine_menu.Y_Steps = Y_STEPS_T_CN; + machine_menu.Z_Steps = Z_STEPS_T_CN; + machine_menu.E0_Steps = E0_STEPS_T_CN; + machine_menu.E1_Steps = E1_STEPS_T_CN; + #endif machine_menu.TmcCurrentConfTitle = TMC_CURRENT_CONF_TITLE_T_CN; machine_menu.X_Current = X_TMC_CURRENT_T_CN; @@ -668,12 +672,14 @@ void machine_setting_disp() { machine_menu.Z_Jerk = Z_JERK_EN; machine_menu.E_Jerk = E_JERK_EN; - machine_menu.StepsConfTitle = STEPS_CONF_TITLE_EN; - machine_menu.X_Steps = X_STEPS_EN; - machine_menu.Y_Steps = Y_STEPS_EN; - machine_menu.Z_Steps = Z_STEPS_EN; - machine_menu.E0_Steps = E0_STEPS_EN; - machine_menu.E1_Steps = E1_STEPS_EN; + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + machine_menu.StepsConfTitle = STEPS_CONF_TITLE_EN; + machine_menu.X_Steps = X_STEPS_EN; + machine_menu.Y_Steps = Y_STEPS_EN; + machine_menu.Z_Steps = Z_STEPS_EN; + machine_menu.E0_Steps = E0_STEPS_EN; + machine_menu.E1_Steps = E1_STEPS_EN; + #endif machine_menu.TmcCurrentConfTitle = TMC_CURRENT_CONF_TITLE_EN; machine_menu.X_Current = X_TMC_CURRENT_EN; @@ -1747,12 +1753,14 @@ void disp_language_init() { machine_menu.Z_Jerk = Z_JERK_RU; machine_menu.E_Jerk = E_JERK_RU; - machine_menu.StepsConfTitle = STEPS_CONF_TITLE_RU; - machine_menu.X_Steps = X_STEPS_RU; - machine_menu.Y_Steps = Y_STEPS_RU; - machine_menu.Z_Steps = Z_STEPS_RU; - machine_menu.E0_Steps = E0_STEPS_RU; - machine_menu.E1_Steps = E1_STEPS_RU; + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + machine_menu.StepsConfTitle = STEPS_CONF_TITLE_RU; + machine_menu.X_Steps = X_STEPS_RU; + machine_menu.Y_Steps = Y_STEPS_RU; + machine_menu.Z_Steps = Z_STEPS_RU; + machine_menu.E0_Steps = E0_STEPS_RU; + machine_menu.E1_Steps = E1_STEPS_RU; + #endif machine_menu.TmcCurrentConfTitle = TMC_CURRENT_CONF_TITLE_RU; machine_menu.X_Current = X_TMC_CURRENT_RU; diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 19f4903cc69b..2ba01a694d0e 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -672,16 +672,18 @@ namespace ExtUI { return planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)]; } - void setAxisSteps_per_mm(const_float_t value, const axis_t axis) { - planner.settings.axis_steps_per_mm[axis] = value; - planner.refresh_positioning(); - } + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + void setAxisSteps_per_mm(const_float_t value, const axis_t axis) { + planner.settings.axis_steps_per_mm[axis] = value; + planner.refresh_positioning(); + } - void setAxisSteps_per_mm(const_float_t value, const extruder_t extruder) { - UNUSED(extruder); - planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)] = value; - planner.refresh_positioning(); - } + void setAxisSteps_per_mm(const_float_t value, const extruder_t extruder) { + UNUSED(extruder); + planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)] = value; + planner.refresh_positioning(); + } + #endif feedRate_t getAxisMaxFeedrate_mm_s(const axis_t axis) { return planner.settings.max_feedrate_mm_s[axis]; diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 0d2c3e8d86a5..28c34bd08abb 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -265,8 +265,10 @@ namespace ExtUI { void setAxisPosition_mm(const_float_t, const extruder_t, const feedRate_t=0); // Planner Control - void setAxisSteps_per_mm(const_float_t, const axis_t); - void setAxisSteps_per_mm(const_float_t, const extruder_t); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + void setAxisSteps_per_mm(const_float_t, const axis_t); + void setAxisSteps_per_mm(const_float_t, const extruder_t); + #endif void setAxisMaxFeedrate_mm_s(const feedRate_t, const axis_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const extruder_t); void setAxisMaxAcceleration_mm_s2(const_float_t, const axis_t); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 88d91ac1d7c5..ef6f63c66f9a 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -502,6 +502,7 @@ namespace LanguageNarrow_en { LSTR MSG_RESUME_PRINT = _UxGT("Resume Print"); LSTR MSG_STOP_PRINT = _UxGT("Stop Print"); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Power Outage"); + LSTR MSG_RESUME_BED_TEMP = _UxGT("Resume Bed Temp"); LSTR MSG_HOST_START_PRINT = _UxGT("Host Start"); LSTR MSG_PRINTING_OBJECT = _UxGT("Print Obj"); LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Obj"); diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index a463701f566a..c661e635cc83 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -505,9 +505,10 @@ class MarlinUI { template static void status_printf(int8_t level, FSTR_P const ffmt, Args... more) { status_printf_P(level, FTOP(ffmt), more...); } - #if HAS_DISPLAY + // Periodic or as-needed display update + static void update() IF_DISABLED(HAS_UI_UPDATE, {}); - static void update(); + #if HAS_DISPLAY static void abort_print(); static void pause_print(); @@ -628,7 +629,6 @@ class MarlinUI { #else // No LCD - static void update() {} static void kill_screen(FSTR_P const, FSTR_P const) {} #endif diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 698687b96dcd..840b658d09c9 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -641,32 +641,38 @@ void menu_backlash(); #endif // !SLIM_LCD_MENUS -// M92 Steps-per-mm -void menu_advanced_steps_per_mm() { - START_MENU(); - BACK_ITEM(MSG_ADVANCED_SETTINGS); +#if ENABLED(EDITABLE_STEPS_PER_UNIT) - LOOP_NUM_AXES(a) - EDIT_ITEM_FAST_N(float72, a, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[a], 5, 9999, []{ planner.refresh_positioning(); }); + // M92 Steps-per-mm + void menu_advanced_steps_per_mm() { + START_MENU(); + BACK_ITEM(MSG_ADVANCED_SETTINGS); - #if ENABLED(DISTINCT_E_FACTORS) - for (uint8_t n = 0; n < E_STEPPERS; ++n) - EDIT_ITEM_FAST_N(float72, 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(); - else - 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_N(float72, E_AXIS, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); - #endif + LOOP_NUM_AXES(a) + EDIT_ITEM_FAST_N(float72, a, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[a], 5, 9999, []{ planner.refresh_positioning(); }); - END_MENU(); -} + #if ENABLED(DISTINCT_E_FACTORS) + for (uint8_t n = 0; n < E_STEPPERS; ++n) + EDIT_ITEM_FAST_N(float72, 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(); + else + 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_N(float72, E_AXIS, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); + #endif + + END_MENU(); + } + +#endif // EDITABLE_STEPS_PER_UNIT void menu_advanced_settings() { - const bool is_busy = printer_busy(); + #if ANY(POLARGRAPH, SHAPING_MENU, HAS_BED_PROBE, EDITABLE_STEPS_PER_UNIT) + const bool is_busy = printer_busy(); + #endif #if ENABLED(SD_FIRMWARE_UPDATE) bool sd_update_state = settings.sd_update_status(); @@ -722,8 +728,9 @@ void menu_advanced_settings() { #endif // !SLIM_LCD_MENUS // M92 - Steps Per mm - if (!is_busy) - SUBMENU(MSG_STEPS_PER_MM, menu_advanced_steps_per_mm); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + if (!is_busy) SUBMENU(MSG_STEPS_PER_MM, menu_advanced_steps_per_mm); + #endif #if ENABLED(BACKLASH_GCODE) SUBMENU(MSG_BACKLASH, menu_backlash); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 7347f219e0ab..44021ce35ad0 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -262,9 +262,9 @@ void menu_advanced_settings(); if (c.timeout) GCODES_ITEM(MSG_HOTEND_IDLE_DISABLE, F("M87")); EDIT_ITEM(int3, MSG_TIMEOUT, &c.timeout, 0, 999); - EDIT_ITEM(int3, MSG_TEMPERATURE, &c.trigger, 0, HEATER_0_MAXTEMP); - EDIT_ITEM(int3, MSG_HOTEND_IDLE_NOZZLE_TARGET, &c.nozzle_target, 0, HEATER_0_MAXTEMP); - EDIT_ITEM(int3, MSG_HOTEND_IDLE_BED_TARGET, &c.bed_target, 0, BED_MAXTEMP); + EDIT_ITEM(int3, MSG_TEMPERATURE, &c.trigger, 0, thermalManager.hotend_max_target(0)); + EDIT_ITEM(int3, MSG_HOTEND_IDLE_NOZZLE_TARGET, &c.nozzle_target, 0, thermalManager.hotend_max_target(0)); + EDIT_ITEM(int3, MSG_HOTEND_IDLE_BED_TARGET, &c.bed_target, 0, BED_MAX_TARGET); END_MENU(); } @@ -397,10 +397,10 @@ void menu_advanced_settings(); #if HAS_PREHEAT && DISABLED(SLIM_LCD_MENUS) void _menu_configuration_preheat_settings() { - #define _MINTEMP_ITEM(N) HEATER_##N##_MINTEMP, - #define _MAXTEMP_ITEM(N) HEATER_##N##_MAXTEMP, - #define MINTEMP_ALL _MIN(REPEAT(HOTENDS, _MINTEMP_ITEM) 999) - #define MAXTEMP_ALL _MAX(REPEAT(HOTENDS, _MAXTEMP_ITEM) 0) + #define _MIN_ITEM(N) HEATER_##N##_MINTEMP, + #define _MAX_ITEM(N) thermalManager.hotend_max_target(0), + #define MINTARGET_ALL _MIN(REPEAT(HOTENDS, _MIN_ITEM) 999) + #define MAXTARGET_ALL _MAX(REPEAT(HOTENDS, _MAX_ITEM) 0) const uint8_t m = MenuItemBase::itemIndex; START_MENU(); STATIC_ITEM_F(ui.get_preheat_label(m), SS_DEFAULT|SS_INVERT); @@ -410,7 +410,7 @@ void menu_advanced_settings(); EDIT_ITEM_N(percent, m, MSG_FAN_SPEED, &editable.uint8, 0, 255, []{ ui.material_preset[MenuItemBase::itemIndex].fan_speed = editable.uint8; }); #endif #if HAS_TEMP_HOTEND - EDIT_ITEM(int3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - (HOTEND_OVERSHOOT)); + EDIT_ITEM(int3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTARGET_ALL, MAXTARGET_ALL); #endif #if HAS_HEATED_BED EDIT_ITEM(int3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET); @@ -640,6 +640,9 @@ void menu_configuration() { #if ENABLED(POWER_LOSS_RECOVERY) EDIT_ITEM(bool, MSG_OUTAGE_RECOVERY, &recovery.enabled, recovery.changed); + #if HAS_PLR_BED_THRESHOLD + EDIT_ITEM(int3, MSG_RESUME_BED_TEMP, &recovery.bed_temp_threshold, 0, BED_MAX_TARGET); + #endif #endif // Preheat configurations diff --git a/Marlin/src/lcd/tft/tft_string.cpp b/Marlin/src/lcd/tft/tft_string.cpp index 9b4ab3e0843c..ad1a53c4556f 100644 --- a/Marlin/src/lcd/tft/tft_string.cpp +++ b/Marlin/src/lcd/tft/tft_string.cpp @@ -58,7 +58,7 @@ void TFT_String::set_font(const uint8_t *font) { for (glyph = 0; glyph < EXTRA_GLYPHS; glyph++) glyphs_extra[glyph] = nullptr; #endif - DEBUG_ECHOLNPGM("Format: ", ((unifont_t *)font_header)->format); + DEBUG_ECHOLNPGM("format: ", ((unifont_t *)font_header)->format); DEBUG_ECHOLNPGM("capitalAHeight: ", ((unifont_t *)font_header)->capitalAHeight); DEBUG_ECHOLNPGM("fontStartEncoding: ", ((unifont_t *)font_header)->fontStartEncoding); DEBUG_ECHOLNPGM("fontEndEncoding: ", ((unifont_t *)font_header)->fontEndEncoding); diff --git a/Marlin/src/lcd/tft_io/tft_io.cpp b/Marlin/src/lcd/tft_io/tft_io.cpp index d46c2de418fb..893ba617eb37 100644 --- a/Marlin/src/lcd/tft_io/tft_io.cpp +++ b/Marlin/src/lcd/tft_io/tft_io.cpp @@ -111,37 +111,37 @@ void TFT_IO::initTFT() { switch (lcd_id) { case LTDC_RGB: break; - case ST7796: // ST7796S 480x320 - DEBUG_ECHO_MSG(" ST7796S"); + case ST7796: + DEBUG_ECHO_MSG(" ST7796S"); // 480x320 write_esc_sequence(st7796s_init); break; - case ST7789: // ST7789V 320x240 - DEBUG_ECHO_MSG(" ST7789V"); + case ST7789: + DEBUG_ECHO_MSG(" ST7789V"); // 320x240 write_esc_sequence(st7789v_init); break; - case SSD1963: // SSD1963 + case SSD1963: DEBUG_ECHO_MSG(" SSD1963"); write_esc_sequence(ssd1963_init); break; - case ST7735: // ST7735 160x128 - DEBUG_ECHO_MSG(" ST7735"); + case ST7735: + DEBUG_ECHO_MSG(" ST7735"); // 160x128 write_esc_sequence(st7735_init); break; - case R61505: // R61505U 320x240 - DEBUG_ECHO_MSG(" R61505U"); + case R61505: + DEBUG_ECHO_MSG(" R61505U"); // 320x240 write_esc_sequence(r61505_init); break; - case ILI9328: // ILI9328 320x240 - DEBUG_ECHO_MSG(" ILI9328"); + case ILI9328: + DEBUG_ECHO_MSG(" ILI9328"); // 320x240 write_esc_sequence(ili9328_init); break; - case ILI9341: // ILI9341 320x240 - DEBUG_ECHO_MSG(" ILI9341"); + case ILI9341: + DEBUG_ECHO_MSG(" ILI9341"); // 320x240 write_esc_sequence(ili9341_init); break; - case ILI9488: // ILI9488 480x320 - case ILI9488_ID1: // 0x8066 ILI9488 480x320 - DEBUG_ECHO_MSG(" ILI9488"); + case ILI9488: + case ILI9488_ID1: + DEBUG_ECHO_MSG(" ILI9488"); // 480x320 write_esc_sequence(ili9488_init); break; default: diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index 98ce7407260c..efbd79b7c1f3 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -38,7 +38,7 @@ #endif #ifndef TFT_DRIVER - #define TFT_DRIVER AUTO + #define TFT_DRIVER AUTO #endif #define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x diff --git a/Marlin/src/module/ft_motion.cpp b/Marlin/src/module/ft_motion.cpp index ba1361f922b8..e912255561f1 100644 --- a/Marlin/src/module/ft_motion.cpp +++ b/Marlin/src/module/ft_motion.cpp @@ -55,8 +55,8 @@ FTMotion ftMotion; ft_config_t FTMotion::cfg; bool FTMotion::busy; // = false ft_command_t FTMotion::stepperCmdBuff[FTM_STEPPERCMD_BUFF_SIZE] = {0U}; // Stepper commands buffer. -uint32_t FTMotion::stepperCmdBuff_produceIdx = 0, // Index of next stepper command write to the buffer. - FTMotion::stepperCmdBuff_consumeIdx = 0; // Index of next stepper command read from the buffer. +int32_t FTMotion::stepperCmdBuff_produceIdx = 0, // Index of next stepper command write to the buffer. + FTMotion::stepperCmdBuff_consumeIdx = 0; // Index of next stepper command read from the buffer. bool FTMotion::sts_stepperBusy = false; // The stepper buffer has items and is in use. @@ -123,6 +123,8 @@ uint32_t FTMotion::interpIdx = 0, // Index of current data point b float FTMotion::e_advanced_z1 = 0.0f; // (ms) Unit delay of advanced extruder position. #endif +constexpr uint32_t last_batchIdx = (FTM_WINDOW_SIZE) - (FTM_BATCH_SIZE); + //----------------------------------------------------------------- // Function definitions. //----------------------------------------------------------------- @@ -145,8 +147,16 @@ void FTMotion::runoutBlock() { ratio.reset(); max_intervals = cfg.modeHasShaper() ? shaper_intervals : 0; - if (max_intervals <= TERN(FTM_UNIFIED_BWS, FTM_BW_SIZE, min_max_intervals - (FTM_BATCH_SIZE))) max_intervals = min_max_intervals; - max_intervals += TERN(FTM_UNIFIED_BWS, FTM_BW_SIZE, FTM_WINDOW_SIZE) - makeVector_batchIdx; + if (max_intervals <= TERN(FTM_UNIFIED_BWS, FTM_BATCH_SIZE, min_max_intervals - (FTM_BATCH_SIZE))) + max_intervals = min_max_intervals; + + max_intervals += ( + #if ENABLED(FTM_UNIFIED_BWS) + FTM_WINDOW_SIZE - makeVector_batchIdx + #else + FTM_WINDOW_SIZE - ((last_batchIdx < (FTM_BATCH_SIZE)) ? 0 : makeVector_batchIdx) + #endif + ); blockProcRdy = blockDataIsRunout = true; runoutEna = blockProcDn = false; } @@ -198,7 +208,7 @@ void FTMotion::loop() { ); // Shift the time series back in the window - #define TSHIFT(A) memcpy(traj.A, &traj.A[FTM_BATCH_SIZE], (FTM_WINDOW_SIZE - FTM_BATCH_SIZE) * sizeof(traj.A[0])) + #define TSHIFT(A) memcpy(traj.A, &traj.A[FTM_BATCH_SIZE], last_batchIdx * sizeof(traj.A[0])) LOGICAL_AXIS_CODE( TSHIFT(e), TSHIFT(x), TSHIFT(y), TSHIFT(z), @@ -219,7 +229,7 @@ void FTMotion::loop() { && (interpIdx - interpIdx_z1 < (FTM_STEPS_PER_LOOP)) ) { convertToSteps(interpIdx); - if (++interpIdx == TERN(FTM_UNIFIED_BWS, FTM_BW_SIZE, FTM_BATCH_SIZE)) { + if (++interpIdx == FTM_BATCH_SIZE) { batchRdyForInterp = false; interpIdx = 0; } @@ -449,7 +459,7 @@ void FTMotion::reset() { endPosn_prevBlock.reset(); makeVector_idx = makeVector_idx_z1 = 0; - makeVector_batchIdx = 0; + makeVector_batchIdx = TERN(FTM_UNIFIED_BWS, 0, _MAX(last_batchIdx, FTM_BATCH_SIZE)); steps.reset(); interpIdx = interpIdx_z1 = 0; @@ -464,10 +474,11 @@ void FTMotion::reset() { } // Private functions. + // Auxiliary function to get number of step commands in the buffer. -uint32_t FTMotion::stepperCmdBuffItems() { - const uint32_t udiff = stepperCmdBuff_produceIdx - stepperCmdBuff_consumeIdx; - return stepperCmdBuff_produceIdx < stepperCmdBuff_consumeIdx ? (FTM_STEPPERCMD_BUFF_SIZE) + udiff : udiff; +int32_t FTMotion::stepperCmdBuffItems() { + const int32_t udiff = stepperCmdBuff_produceIdx - stepperCmdBuff_consumeIdx; + return (udiff < 0) ? udiff + (FTM_STEPPERCMD_BUFF_SIZE) : udiff; } // Initializes storage variables before startup. @@ -544,9 +555,9 @@ void FTMotion::loadBlockData(block_t * const current_block) { const float T1 = (F_n - f_s) * oneOverAccel, T3 = (F_n - f_e) * oneOverAccel; - N1 = ceil(T1 * (FTM_FS)); // Accel datapoints based on Hz frequency - N2 = ceil(T2 * (FTM_FS)); // Coast - N3 = ceil(T3 * (FTM_FS)); // Decel + N1 = CEIL(T1 * (FTM_FS)); // Accel datapoints based on Hz frequency + N2 = CEIL(T2 * (FTM_FS)); // Coast + N3 = CEIL(T3 * (FTM_FS)); // Decel const float T1_P = N1 * (FTM_TS), // (s) Accel datapoints x timestep resolution T2_P = N2 * (FTM_TS), // (s) Coast @@ -677,8 +688,8 @@ void FTMotion::makeVector() { #endif // Filled up the queue with regular and shaped steps - if (++makeVector_batchIdx == TERN(FTM_UNIFIED_BWS, FTM_BW_SIZE, (FTM_WINDOW_SIZE - FTM_BATCH_SIZE))) { - makeVector_batchIdx = 0; + if (++makeVector_batchIdx == FTM_WINDOW_SIZE) { + makeVector_batchIdx = last_batchIdx; batchRdy = true; } diff --git a/Marlin/src/module/ft_motion.h b/Marlin/src/module/ft_motion.h index 8c8098873f42..884a18347903 100644 --- a/Marlin/src/module/ft_motion.h +++ b/Marlin/src/module/ft_motion.h @@ -102,12 +102,11 @@ class FTMotion { } static ft_command_t stepperCmdBuff[FTM_STEPPERCMD_BUFF_SIZE]; // Buffer of stepper commands. - static uint32_t stepperCmdBuff_produceIdx, // Index of next stepper command write to the buffer. - stepperCmdBuff_consumeIdx; // Index of next stepper command read from the buffer. + static int32_t stepperCmdBuff_produceIdx, // Index of next stepper command write to the buffer. + stepperCmdBuff_consumeIdx; // Index of next stepper command read from the buffer. static bool sts_stepperBusy; // The stepper buffer has items and is in use. - // Public methods static void init(); static void startBlockProc(); // Set controller states to begin processing a block. @@ -153,10 +152,10 @@ class FTMotion { static uint32_t N1, N2, N3; static uint32_t max_intervals; - static constexpr uint32_t _ftm_size = TERN(FTM_UNIFIED_BWS, FTM_BW_SIZE, FTM_BATCH_SIZE), - _ftm_wind = TERN(FTM_UNIFIED_BWS, 2, CEIL((FTM_WINDOW_SIZE) / _ftm_size)), - shaper_intervals = _ftm_size * CEIL((FTM_ZMAX) / _ftm_size), - min_max_intervals = _ftm_size * _ftm_wind; + #define _DIVCEIL(A,B) (((A) + (B) - 1) / (B)) + static constexpr uint32_t _ftm_ratio = TERN(FTM_UNIFIED_BWS, 2, _DIVCEIL(FTM_WINDOW_SIZE, FTM_BATCH_SIZE)), + shaper_intervals = (FTM_BATCH_SIZE) * _DIVCEIL(FTM_ZMAX, FTM_BATCH_SIZE), + min_max_intervals = (FTM_BATCH_SIZE) * _ftm_ratio; // Make vector variables. static uint32_t makeVector_idx, @@ -203,7 +202,7 @@ class FTMotion { #endif // Private methods - static uint32_t stepperCmdBuffItems(); + static int32_t stepperCmdBuffItems(); static void loadBlockData(block_t *const current_block); static void makeVector(); static void convertToSteps(const uint32_t idx); diff --git a/Marlin/src/module/ft_types.h b/Marlin/src/module/ft_types.h index b17c00974e76..d460853262cc 100644 --- a/Marlin/src/module/ft_types.h +++ b/Marlin/src/module/ft_types.h @@ -44,13 +44,8 @@ enum dynFreqMode_t : uint8_t { #define IS_EI_MODE(N) WITHIN(N, ftMotionMode_EI, ftMotionMode_3HEI) -#if ENABLED(FTM_UNIFIED_BWS) - typedef struct XYZEarray xyze_trajectory_t; - typedef struct XYZEarray xyze_trajectoryMod_t; -#else - typedef struct XYZEarray xyze_trajectory_t; - typedef struct XYZEarray xyze_trajectoryMod_t; -#endif +typedef struct XYZEarray xyze_trajectory_t; +typedef struct XYZEarray xyze_trajectoryMod_t; enum { LIST_N(DOUBLE(LOGICAL_AXES), diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 0c6027bfdead..6b27971d9d1e 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -133,6 +133,12 @@ volatile uint8_t Planner::block_buffer_head, // Index of the next block to be uint16_t Planner::cleaning_buffer_counter; // A counter to disable queuing of blocks uint8_t Planner::delay_before_delivering; // Delay block delivery so initial blocks in an empty queue may merge +#if ENABLED(EDITABLE_STEPS_PER_UNIT) + float Planner::mm_per_step[DISTINCT_AXES]; // (mm) Millimeters per step +#else + constexpr float PlannerSettings::axis_steps_per_mm[DISTINCT_AXES]; + constexpr float Planner::mm_per_step[DISTINCT_AXES]; +#endif planner_settings_t Planner::settings; // Initialized by settings.load() /** @@ -146,8 +152,6 @@ planner_settings_t Planner::settings; // Initialized by settings.load( uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 -float Planner::mm_per_step[DISTINCT_AXES]; // (mm) Millimeters per step - #if HAS_JUNCTION_DEVIATION float Planner::junction_deviation_mm; // (mm) M205 J #if HAS_LINEAR_E_JERK @@ -3308,7 +3312,9 @@ void Planner::refresh_acceleration_rates() { * Must be called whenever settings.axis_steps_per_mm changes! */ void Planner::refresh_positioning() { - LOOP_DISTINCT_AXES(i) mm_per_step[i] = 1.0f / settings.axis_steps_per_mm[i]; + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + LOOP_DISTINCT_AXES(i) mm_per_step[i] = 1.0f / settings.axis_steps_per_mm[i]; + #endif set_position_mm(current_position); refresh_acceleration_rates(); } diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 726ccb4d3f81..42eee677cbc6 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -340,10 +340,30 @@ constexpr uint8_t block_inc_mod(const uint8_t v1, const uint8_t v2) { } laser_state_t; #endif -typedef struct { +#if DISABLED(EDITABLE_STEPS_PER_UNIT) + static constexpr float _dasu[] = DEFAULT_AXIS_STEPS_PER_UNIT; +#endif + +typedef struct PlannerSettings { uint32_t max_acceleration_mm_per_s2[DISTINCT_AXES], // (mm/s^2) M201 XYZE min_segment_time_us; // (µs) M205 B - float axis_steps_per_mm[DISTINCT_AXES]; // (steps) M92 XYZE - Steps per millimeter + + // (steps) M92 XYZE - Steps per millimeter + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + float axis_steps_per_mm[DISTINCT_AXES]; + #else + #define _DLIM(I) _MIN(I, (signed)COUNT(_dasu) - 1) + #define _DASU(N) _dasu[_DLIM(N)], + #define _EASU(N) _dasu[_DLIM(E_AXIS + N)], + static constexpr float axis_steps_per_mm[DISTINCT_AXES] = { + REPEAT(NUM_AXES, _DASU) + TERN_(HAS_EXTRUDERS, REPEAT(DISTINCT_E, _EASU)) + }; + #undef _EASU + #undef _DASU + #undef _DLIM + #endif + feedRate_t max_feedrate_mm_s[DISTINCT_AXES]; // (mm/s) M203 XYZE - Max speeds float acceleration, // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves. retract_acceleration, // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes @@ -450,15 +470,15 @@ class Planner { #endif #if DISABLED(NO_VOLUMETRICS) - static float filament_size[EXTRUDERS], // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder - volumetric_area_nominal, // Nominal cross-sectional area - volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner + static float filament_size[EXTRUDERS], // (mm) Diameter of filament, typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder + volumetric_area_nominal, // (mm^3) Nominal cross-sectional area + volumetric_multiplier[EXTRUDERS]; // (1/mm^2) Reciprocal of cross-sectional area of filament. Pre-calculated to reduce computation in the planner // May be auto-adjusted by a filament width sensor #endif #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - static float volumetric_extruder_limit[EXTRUDERS], // Maximum mm^3/sec the extruder can handle - volumetric_extruder_feedrate_limit[EXTRUDERS]; // Feedrate limit (mm/s) calculated from volume limit + static float volumetric_extruder_limit[EXTRUDERS], // (mm^3/sec) Maximum volume the extruder can handle + volumetric_extruder_feedrate_limit[EXTRUDERS]; // (mm/s) Feedrate limit calculated from volume limit #endif static planner_settings_t settings; @@ -468,7 +488,14 @@ class Planner { #endif static uint32_t max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 - static float mm_per_step[DISTINCT_AXES]; // Millimeters per step + + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + static float mm_per_step[DISTINCT_AXES]; // Millimeters per step + #else + #define _RSTEP(N) RECIPROCAL(settings.axis_steps_per_mm[N]), + static constexpr float mm_per_step[DISTINCT_AXES] = { REPEAT(DISTINCT_AXES, _RSTEP) }; + #undef _RSTEP + #endif #if HAS_JUNCTION_DEVIATION static float junction_deviation_mm; // (mm) M205 J diff --git a/Marlin/src/module/servo.cpp b/Marlin/src/module/servo.cpp index 2782be1f2bd9..6ce12c9abecf 100644 --- a/Marlin/src/module/servo.cpp +++ b/Marlin/src/module/servo.cpp @@ -37,22 +37,30 @@ hal_servo_t servo[NUM_SERVOS]; #endif void servo_init() { - #if NUM_SERVOS >= 1 && HAS_SERVO_0 + #if HAS_SERVO_0 servo[0].attach(SERVO0_PIN); servo[0].detach(); // Just set up the pin. We don't have a position yet. Don't move to a random position. #endif - #if NUM_SERVOS >= 2 && HAS_SERVO_1 + #if HAS_SERVO_1 servo[1].attach(SERVO1_PIN); servo[1].detach(); #endif - #if NUM_SERVOS >= 3 && HAS_SERVO_2 + #if HAS_SERVO_2 servo[2].attach(SERVO2_PIN); servo[2].detach(); #endif - #if NUM_SERVOS >= 4 && HAS_SERVO_3 + #if HAS_SERVO_3 servo[3].attach(SERVO3_PIN); servo[3].detach(); #endif + #if HAS_SERVO_4 + servo[4].attach(SERVO4_PIN); + servo[4].detach(); + #endif + #if HAS_SERVO_5 + servo[5].attach(SERVO5_PIN); + servo[5].detach(); + #endif } #endif // HAS_SERVOS diff --git a/Marlin/src/module/servo.h b/Marlin/src/module/servo.h index 40cfcee3c690..0286fe905bda 100644 --- a/Marlin/src/module/servo.h +++ b/Marlin/src/module/servo.h @@ -107,6 +107,9 @@ , { ASRC(3,0), ASRC(3,1) } #if NUM_SERVOS > 4 , { ASRC(4,0), ASRC(4,1) } + #if NUM_SERVOS > 5 + , { ASRC(5,0), ASRC(5,1) } + #endif #endif #endif #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 4b3888c7a4a4..c57eb00bb4cf 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -92,12 +92,6 @@ #include "servo.h" #endif -#if HAS_SERVOS && HAS_SERVO_ANGLES - #define EEPROM_NUM_SERVOS NUM_SERVOS -#else - #define EEPROM_NUM_SERVOS NUM_SERVO_PLUGS -#endif - #include "../feature/fwretract.h" #if ENABLED(POWER_LOSS_RECOVERY) @@ -204,8 +198,10 @@ typedef struct { bool NUM_AXIS_LIST_(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, // Defaults for reset / fill in on load static const uint32_t _DMA[] PROGMEM = DEFAULT_MAX_ACCELERATION; -static const float _DASU[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT; static const feedRate_t _DMF[] PROGMEM = DEFAULT_MAX_FEEDRATE; +#if ENABLED(EDITABLE_STEPS_PER_UNIT) + static const float _DASU[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT; +#endif /** * Current EEPROM Layout @@ -318,7 +314,9 @@ typedef struct SettingsDataStruct { // // SERVO_ANGLES // - uint16_t servo_angles[EEPROM_NUM_SERVOS][2]; // M281 P L U + #if HAS_SERVO_ANGLES + uint16_t servo_angles[NUM_SERVOS][2]; // M281 P L U + #endif // // Temperature first layer compensation values @@ -448,6 +446,7 @@ typedef struct SettingsDataStruct { // POWER_LOSS_RECOVERY // bool recovery_enabled; // M413 S + celsius_t bed_temp_threshold; // M413 B // // FWRETRACT @@ -1063,13 +1062,12 @@ void MarlinSettings::postprocess() { // // Servo Angles // + #if HAS_SERVO_ANGLES { _FIELD_TEST(servo_angles); - #if !HAS_SERVO_ANGLES - uint16_t servo_angles[EEPROM_NUM_SERVOS][2] = { { 0, 0 } }; - #endif EEPROM_WRITE(servo_angles); } + #endif // // Thermal first layer compensation values @@ -1285,8 +1283,10 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(recovery_enabled); - const bool recovery_enabled = TERN(POWER_LOSS_RECOVERY, recovery.enabled, ENABLED(PLR_ENABLED_DEFAULT)); + const bool recovery_enabled = TERN0(POWER_LOSS_RECOVERY, recovery.enabled); + const celsius_t bed_temp_threshold = TERN0(HAS_PLR_BED_THRESHOLD, recovery.bed_temp_threshold); EEPROM_WRITE(recovery_enabled); + EEPROM_WRITE(bed_temp_threshold); } // @@ -1876,17 +1876,22 @@ 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[NUM_AXES + e_factors]; - float tmp2[NUM_AXES + e_factors]; - feedRate_t tmp3[NUM_AXES + e_factors]; EEPROM_READ((uint8_t *)tmp1, sizeof(tmp1)); // max_acceleration_mm_per_s2 + EEPROM_READ(planner.settings.min_segment_time_us); + + float tmp2[NUM_AXES + e_factors]; EEPROM_READ((uint8_t *)tmp2, sizeof(tmp2)); // axis_steps_per_mm + + feedRate_t tmp3[NUM_AXES + e_factors]; EEPROM_READ((uint8_t *)tmp3, sizeof(tmp3)); // max_feedrate_mm_s if (!validating) LOOP_DISTINCT_AXES(i) { const bool in = (i < e_factors + NUM_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)]); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + planner.settings.axis_steps_per_mm[i] = in ? tmp2[i] : pgm_read_float(&_DASU[ALIM(i, _DASU)]); + #endif planner.settings.max_feedrate_mm_s[i] = in ? tmp3[i] : pgm_read_float(&_DMF[ALIM(i, _DMF)]); } @@ -2101,15 +2106,17 @@ void MarlinSettings::postprocess() { // // SERVO_ANGLES // + #if HAS_SERVO_ANGLES { _FIELD_TEST(servo_angles); #if ENABLED(EDITABLE_SERVO_ANGLES) - uint16_t (&servo_angles_arr)[EEPROM_NUM_SERVOS][2] = servo_angles; + uint16_t (&servo_angles_arr)[NUM_SERVOS][2] = servo_angles; #else - uint16_t servo_angles_arr[EEPROM_NUM_SERVOS][2]; + uint16_t servo_angles_arr[NUM_SERVOS][2]; #endif EEPROM_READ(servo_angles_arr); } + #endif // // Thermal first layer compensation values @@ -2332,10 +2339,15 @@ void MarlinSettings::postprocess() { // Power-Loss Recovery // { - bool recovery_enabled; _FIELD_TEST(recovery_enabled); + bool recovery_enabled; + celsius_t bed_temp_threshold; EEPROM_READ(recovery_enabled); - TERN_(POWER_LOSS_RECOVERY, if (!validating) recovery.enabled = recovery_enabled); + EEPROM_READ(bed_temp_threshold); + if (!validating) { + TERN_(POWER_LOSS_RECOVERY, recovery.enabled = recovery_enabled); + TERN_(HAS_PLR_BED_THRESHOLD, recovery.bed_temp_threshold = bed_temp_threshold); + } } // @@ -3104,7 +3116,9 @@ void MarlinSettings::postprocess() { void MarlinSettings::reset() { LOOP_DISTINCT_AXES(i) { planner.settings.max_acceleration_mm_per_s2[i] = pgm_read_dword(&_DMA[ALIM(i, _DMA)]); - planner.settings.axis_steps_per_mm[i] = pgm_read_float(&_DASU[ALIM(i, _DASU)]); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + planner.settings.axis_steps_per_mm[i] = pgm_read_float(&_DASU[ALIM(i, _DASU)]); + #endif planner.settings.max_feedrate_mm_s[i] = pgm_read_float(&_DMF[ALIM(i, _DMF)]); } @@ -3493,7 +3507,10 @@ void MarlinSettings::reset() { // // Power-Loss Recovery // - TERN_(POWER_LOSS_RECOVERY, recovery.enable(ENABLED(PLR_ENABLED_DEFAULT))); + #if ENABLED(POWER_LOSS_RECOVERY) + recovery.enable(ENABLED(PLR_ENABLED_DEFAULT)); + TERN_(HAS_PLR_BED_THRESHOLD, recovery.bed_temp_threshold = PLR_BED_THRESHOLD); + #endif // // Firmware Retraction @@ -3686,7 +3703,9 @@ void MarlinSettings::reset() { #define CONFIG_ECHO_MSG_P(V...) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPGM_P(V); }while(0) #define CONFIG_ECHO_HEADING(STR) gcode.report_heading(forReplay, F(STR)) - void M92_report(const bool echo=true, const int8_t e=-1); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + void M92_report(const bool echo=true, const int8_t e=-1); + #endif /** * M503 - Report current settings in RAM @@ -3724,7 +3743,9 @@ void MarlinSettings::reset() { // // M92 Steps per Unit // - gcode.M92_report(forReplay); + #if ENABLED(EDITABLE_STEPS_PER_UNIT) + gcode.M92_report(forReplay); + #endif // // M203 Maximum feedrates (units/s) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 9c1668619ba9..8d55d37b96f8 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1508,14 +1508,12 @@ void Stepper::isr() { #if ENABLED(FT_MOTION) if (using_ftMotion) { - if (!nextMainISR) { - nextMainISR = FTM_MIN_TICKS; - ftMotion_stepper(); - endstops.update(); - TERN_(BABYSTEPPING, if (babystep.has_steps()) babystepping_isr()); + if (!nextMainISR) { // Main ISR is ready to fire during this iteration? + nextMainISR = FTM_MIN_TICKS; // Set to minimum interval (a limit on the top speed) + ftMotion_stepper(); // Run FTM Stepping } - interval = nextMainISR; - nextMainISR -= interval; + interval = nextMainISR; // Interval is either some old nextMainISR or FTM_MIN_TICKS + nextMainISR = 0; // For FT Motion fire again ASAP } #endif @@ -3161,7 +3159,7 @@ void Stepper::init() { factor2 += -7.58095488 * zeta2; const float zeta3 = zeta2 * zeta; factor2 += 43.073216 * zeta3; - factor2 = floor(factor2); + factor2 = FLOOR(factor2); } const bool was_on = hal.isr_state(); @@ -3448,7 +3446,8 @@ void Stepper::report_positions() { // Use one byte to restore one stepper command in the format: // |X_step|X_direction|Y_step|Y_direction|Z_step|Z_direction|E_step|E_direction| const ft_command_t command = ftMotion.stepperCmdBuff[ftMotion.stepperCmdBuff_consumeIdx]; - if (++ftMotion.stepperCmdBuff_consumeIdx == (FTM_STEPPERCMD_BUFF_SIZE)) ftMotion.stepperCmdBuff_consumeIdx = 0U; + if (++ftMotion.stepperCmdBuff_consumeIdx == (FTM_STEPPERCMD_BUFF_SIZE)) + ftMotion.stepperCmdBuff_consumeIdx = 0; if (abort_current_block) return; @@ -3492,6 +3491,8 @@ void Stepper::report_positions() { U_APPLY_STEP(axis_did_move.u, false), V_APPLY_STEP(axis_did_move.v, false), W_APPLY_STEP(axis_did_move.w, false) ); + TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); + // Begin waiting for the minimum pulse duration START_TIMED_PULSE(); @@ -3533,6 +3534,12 @@ void Stepper::report_positions() { U_APPLY_STEP(!STEP_STATE_U, false), V_APPLY_STEP(!STEP_STATE_V, false), W_APPLY_STEP(!STEP_STATE_W, false) ); + // Check endstops on every step + IF_DISABLED(ENDSTOP_INTERRUPTS_FEATURE, endstops.update()); + + // Also handle babystepping here + TERN_(BABYSTEPPING, if (babystep.has_steps()) babystepping_isr()); + } // Stepper::ftMotion_stepper void Stepper::ftMotion_blockQueueUpdate() { diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e65297b04a24..ad1daae76245 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -301,13 +301,13 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); // Sanity-check max readable temperatures #define CHECK_MAXTEMP_(N,M,S) static_assert( \ - S >= 998 || M <= _MAX(TT_NAME(S)[0].celsius, TT_NAME(S)[COUNT(TT_NAME(S)) - 1].celsius) - HOTEND_OVERSHOOT, \ + S >= 998 || M <= _MAX(TT_NAME(S)[0].celsius, TT_NAME(S)[COUNT(TT_NAME(S)) - 1].celsius) - (HOTEND_OVERSHOOT), \ "HEATER_" STRINGIFY(N) "_MAXTEMP (" STRINGIFY(M) ") is too high for thermistor_" STRINGIFY(S) ".h with HOTEND_OVERSHOOT=" STRINGIFY(HOTEND_OVERSHOOT) "."); #define CHECK_MAXTEMP(N) TERN(TEMP_SENSOR_##N##_IS_THERMISTOR, CHECK_MAXTEMP_, CODE_0)(N, HEATER_##N##_MAXTEMP, TEMP_SENSOR_##N) REPEAT(HOTENDS, CHECK_MAXTEMP) #if HAS_PREHEAT - #define CHECK_PREHEAT__(N,P,T,M) static_assert(T <= M - HOTEND_OVERSHOOT, "PREHEAT_" STRINGIFY(P) "_TEMP_HOTEND (" STRINGIFY(T) ") must be less than HEATER_" STRINGIFY(N) "_MAXTEMP (" STRINGIFY(M) ") - " STRINGIFY(HOTEND_OVERSHOOT) "."); + #define CHECK_PREHEAT__(N,P,T,M) static_assert(T <= (M) - (HOTEND_OVERSHOOT), "PREHEAT_" STRINGIFY(P) "_TEMP_HOTEND (" STRINGIFY(T) ") must be less than HEATER_" STRINGIFY(N) "_MAXTEMP (" STRINGIFY(M) ") - " STRINGIFY(HOTEND_OVERSHOOT) "."); #define CHECK_PREHEAT_(N,P) CHECK_PREHEAT__(N, P, PREHEAT_##P##_TEMP_HOTEND, HEATER_##N##_MAXTEMP) #define CHECK_PREHEAT(P) REPEAT2(HOTENDS, CHECK_PREHEAT_, P) #if PREHEAT_COUNT >= 1 @@ -490,8 +490,7 @@ 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 - raw_adc_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, - Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; + temp_raw_range_t Temperature::temp_sensor_range_bed = { TEMP_SENSOR_BED_RAW_LO_TEMP, TEMP_SENSOR_BED_RAW_HI_TEMP }; #if WATCH_BED bed_watch_t Temperature::watch_bed; // = { 0 } #endif @@ -505,8 +504,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_HEATED_CHAMBER millis_t next_cool_check_ms = 0; celsius_float_t old_temp = 9999; - raw_adc_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, - Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; + temp_raw_range_t Temperature::temp_sensor_range_chamber = { TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, TEMP_SENSOR_CHAMBER_RAW_HI_TEMP }; #if WATCH_CHAMBER chamber_watch_t Temperature::watch_chamber; // = { 0 } #endif @@ -522,8 +520,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); bool flag_cooler_state; //bool flag_cooler_excess = false; celsius_float_t previous_temp = 9999; - raw_adc_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, - Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; + temp_raw_range_t Temperature::temp_sensor_range_cooler = { TEMP_SENSOR_COOLER_RAW_LO_TEMP, TEMP_SENSOR_COOLER_RAW_HI_TEMP }; #if WATCH_COOLER cooler_watch_t Temperature::watch_cooler; // = { 0 } #endif @@ -538,8 +535,7 @@ 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) - raw_adc_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, - Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; + temp_raw_range_t Temperature::temp_sensor_range_board = { TEMP_SENSOR_BOARD_RAW_LO_TEMP, TEMP_SENSOR_BOARD_RAW_HI_TEMP }; #endif #endif @@ -632,6 +628,36 @@ volatile bool Temperature::raw_temps_ready = false; * Class and Instance Methods */ +#if ANY(HAS_PID_HEATING, MPC_AUTOTUNE) + + /** + * Run the minimal required activities during a tuning loop. + * TODO: Allow tuning routines to call idle() for more complete keepalive. + */ + bool Temperature::tuning_idle(const millis_t &ms) { + + // Run HAL idle tasks + hal.idletask(); + + const bool temp_ready = updateTemperaturesIfReady(); + + #if HAS_FAN_LOGIC + if (temp_ready) manage_extruder_fans(ms); + #else + UNUSED(ms); + #endif + + // Run Controller Fan check (normally handled by manage_inactivity) + TERN_(USE_CONTROLLER_FAN, controllerFan.update()); + + // Run UI update + ui.update(); + + return temp_ready; + } + +#endif + #if HAS_PID_HEATING inline void say_default_() { SERIAL_ECHOPGM("#define DEFAULT_"); } @@ -700,7 +726,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); TERN_(PROUI_PID_TUNE, dwinPidTuning(isbed ? PIDTEMPBED_START : PIDTEMP_START)); - if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { + if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, hotend_max_target(heater_id))) { SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(PROUI_PID_TUNE, dwinPidTuning(PID_TEMP_TOO_HIGH)); @@ -718,7 +744,7 @@ volatile bool Temperature::raw_temps_ready = false; #if ENABLED(PRINTER_EVENT_LEDS) const celsius_float_t start_temp = GHV(degChamber(), degBed(), degHotend(heater_id)); - LEDColor color = ONHEATINGSTART(); + const LEDColor oldcolor = ONHEATINGSTART(); #endif TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = false); @@ -731,7 +757,11 @@ volatile bool Temperature::raw_temps_ready = false; const millis_t ms = millis(); - if (updateTemperaturesIfReady()) { // temp sample ready + // Run minimal necessary machine tasks + const bool temp_ready = tuning_idle(ms); + + // If a new sample has arrived process things + if (temp_ready) { // Get the current temperature and constrain it current_temp = GHV(degChamber(), degBed(), degHotend(heater_id)); @@ -742,8 +772,6 @@ volatile bool Temperature::raw_temps_ready = false; ONHEATING(start_temp, current_temp, target); #endif - TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); - if (heating && current_temp > target && ELAPSED(ms, t2 + 5000UL)) { heating = false; SHV((bias - d) >> 1); @@ -882,25 +910,19 @@ volatile bool Temperature::raw_temps_ready = false; if (set_result) GHV(_set_chamber_pid(tune_pid), _set_bed_pid(tune_pid), _set_hotend_pid(heater_id, tune_pid)); - TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color)); + TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(oldcolor)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); TERN_(PROUI_PID_TUNE, dwinPidTuning(AUTOTUNE_DONE)); goto EXIT_M303; } - - // Run HAL idle tasks - hal.idletask(); - - // Run UI update - TERN(DWIN_CREALITY_LCD, dwinUpdate(), ui.update()); } wait_for_heatup = false; disable_all_heaters(); - TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color)); + TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(oldcolor)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); TERN_(PROUI_PID_TUNE, dwinPidTuning(AUTOTUNE_DONE)); @@ -1143,13 +1165,14 @@ volatile bool Temperature::raw_temps_ready = false; } Temperature::MPC_autotuner::MeasurementState Temperature::MPC_autotuner::housekeeping() { - const millis_t report_interval_ms = 1000UL; + constexpr millis_t report_interval_ms = 1000UL; curr_time_ms = millis(); - if (updateTemperaturesIfReady()) { // temp sample ready - current_temp = degHotend(e); - TERN_(HAS_FAN_LOGIC, manage_extruder_fans(curr_time_ms)); - } + // Run minimal necessary machine tasks + const bool temp_ready = tuning_idle(curr_time_ms); + + // Set MPC temp if a new sample is ready + if (temp_ready) current_temp = degHotend(e); if (ELAPSED(curr_time_ms, next_report_ms)) { next_report_ms += report_interval_ms; @@ -1157,9 +1180,6 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_EOL(); } - hal.idletask(); - TERN(DWIN_CREALITY_LCD, dwinUpdate(), ui.update()); - if (!wait_for_heatup) { SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_INTERRUPTED); TERN_(DWIN_LCD_PROUI, dwinMPCTuning(MPC_INTERRUPTED)); @@ -1674,7 +1694,7 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T } float pid_output = power * 254.0f / mpc.heater_power + 1.0f; // Ensure correct quantization into a range of 0 to 127 - pid_output = constrain(pid_output, 0, MPC_MAX); + LIMIT(pid_output, 0, MPC_MAX); /* <-- add a slash to enable static uint32_t nexttime = millis() + 1000; @@ -1834,12 +1854,18 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T // Check if temperature is within the correct band if (WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP)) { #if ENABLED(BED_LIMIT_SWITCHING) + + // Range-limited "bang-bang" bed heating if (temp_bed.is_above_target(BED_HYSTERESIS)) temp_bed.soft_pwm_amount = 0; else if (temp_bed.is_below_target(BED_HYSTERESIS)) temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1; + #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING + + // Simple (noisy) "bang-bang" bed heating temp_bed.soft_pwm_amount = temp_bed.is_below_target() ? MAX_BED_POWER >> 1 : 0; + #endif } else { @@ -2632,31 +2658,8 @@ void Temperature::updateTemperaturesFromRawValues() { TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); #if HAS_HOTEND - static constexpr int8_t temp_dir[HOTENDS] = { - #if TEMP_SENSOR_IS_ANY_MAX_TC(0) - 0 - #else - TEMPDIR(0) - #endif - #if HAS_MULTI_HOTEND - #if TEMP_SENSOR_IS_ANY_MAX_TC(1) - , 0 - #else - , TEMPDIR(1) - #endif - #endif - #if HOTENDS > 2 - #if TEMP_SENSOR_IS_ANY_MAX_TC(2) - , 0 - #else - , TEMPDIR(2) - #endif - #endif - #if HOTENDS > 3 - #define _TEMPDIR(N) , TEMPDIR(N) - REPEAT_S(3, HOTENDS, _TEMPDIR) - #endif - }; + #define _TEMPDIR(N) TEMP_SENSOR_IS_ANY_MAX_TC(N) ? 0 : TEMPDIR(N), + static constexpr int8_t temp_dir[HOTENDS] = { REPEAT(HOTENDS, _TEMPDIR) }; HOTEND_LOOP() { const raw_adc_t r = temp_hotend[e].getraw(); @@ -2683,31 +2686,37 @@ void Temperature::updateTemperaturesFromRawValues() { #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.getraw(), maxtemp_raw_BED)) MAXTEMP_ERROR(H_BED, temp_bed.celsius); - if (temp_bed.target > 0 && !is_bed_preheating() && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) MINTEMP_ERROR(H_BED, temp_bed.celsius); + if (TP_CMP(BED, temp_bed.getraw(), temp_sensor_range_bed.raw_max)) + MAXTEMP_ERROR(H_BED, temp_bed.celsius); + if (temp_bed.target > 0 && !is_bed_preheating() && TP_CMP(BED, temp_sensor_range_bed.raw_min, temp_bed.getraw())) + MINTEMP_ERROR(H_BED, temp_bed.celsius); #endif #if ALL(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) - if (TP_CMP(CHAMBER, temp_chamber.getraw(), maxtemp_raw_CHAMBER)) MAXTEMP_ERROR(H_CHAMBER, temp_chamber.celsius); - if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw())) MINTEMP_ERROR(H_CHAMBER, temp_chamber.celsius); + if (TP_CMP(CHAMBER, temp_chamber.getraw(), temp_sensor_range_chamber.raw_max)) + MAXTEMP_ERROR(H_CHAMBER, temp_chamber.celsius); + if (temp_chamber.target > 0 && TP_CMP(CHAMBER, temp_sensor_range_chamber.raw_min, temp_chamber.getraw())) + MINTEMP_ERROR(H_CHAMBER, temp_chamber.celsius); #endif #if ALL(HAS_COOLER, THERMAL_PROTECTION_COOLER) - if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), maxtemp_raw_COOLER)) MAXTEMP_ERROR(H_COOLER, temp_cooler.celsius); - if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.getraw())) MINTEMP_ERROR(H_COOLER, temp_cooler.celsius); + if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), temp_sensor_range_cooler.raw_max)) + MAXTEMP_ERROR(H_COOLER, temp_cooler.celsius); + if (TP_CMP(COOLER, temp_sensor_range_cooler.raw_min, temp_cooler.getraw())) + MINTEMP_ERROR(H_COOLER, temp_cooler.celsius); #endif #if ALL(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) - if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) MAXTEMP_ERROR(H_BOARD, temp_board.celsius); - if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) MINTEMP_ERROR(H_BOARD, temp_board.celsius); + if (TP_CMP(BOARD, temp_board.getraw(), temp_sensor_range_board.raw_max)) + MAXTEMP_ERROR(H_BOARD, temp_board.celsius); + if (TP_CMP(BOARD, temp_sensor_range_board.raw_min, temp_board.getraw())) + MINTEMP_ERROR(H_BOARD, temp_board.celsius); #endif #if ALL(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC) if (TP_CMP(SOC, temp_soc.getraw(), maxtemp_raw_SOC)) MAXTEMP_ERROR(H_SOC, temp_soc.celsius); #endif - #undef TP_CMP } // Temperature::updateTemperaturesFromRawValues @@ -2733,7 +2742,6 @@ void Temperature::init() { TERN_(PROBING_HEATERS_OFF, paused_for_probing = false); - // Init (and disable) SPI thermocouples #if TEMP_SENSOR_IS_ANY_MAX_TC(0) && PIN_EXISTS(TEMP_0_CS) OUT_WRITE(TEMP_0_CS_PIN, HIGH); @@ -3051,23 +3059,31 @@ void Temperature::init() { // TODO: combine these into the macros above #if HAS_HEATED_BED - while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR); - while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR); + while (analog_to_celsius_bed(temp_sensor_range_bed.raw_min) < BED_MINTEMP) + temp_sensor_range_bed.raw_min += TEMPDIR(BED) * (OVERSAMPLENR); + while (analog_to_celsius_bed(temp_sensor_range_bed.raw_max) > BED_MAXTEMP) + temp_sensor_range_bed.raw_max -= TEMPDIR(BED) * (OVERSAMPLENR); #endif #if HAS_HEATED_CHAMBER - while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR); - while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR); + while (analog_to_celsius_chamber(temp_sensor_range_chamber.raw_min) < CHAMBER_MINTEMP) + temp_sensor_range_chamber.raw_min += TEMPDIR(CHAMBER) * (OVERSAMPLENR); + while (analog_to_celsius_chamber(temp_sensor_range_chamber.raw_max) > CHAMBER_MAXTEMP) + temp_sensor_range_chamber.raw_max -= TEMPDIR(CHAMBER) * (OVERSAMPLENR); #endif #if HAS_COOLER - while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR); - while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR); + while (analog_to_celsius_cooler(temp_sensor_range_cooler.raw_min) > COOLER_MINTEMP) + temp_sensor_range_cooler.raw_min += TEMPDIR(COOLER) * (OVERSAMPLENR); + while (analog_to_celsius_cooler(temp_sensor_range_cooler.raw_max) < COOLER_MAXTEMP) + temp_sensor_range_cooler.raw_max -= TEMPDIR(COOLER) * (OVERSAMPLENR); #endif #if ALL(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) - while (analog_to_celsius_board(mintemp_raw_BOARD) < BOARD_MINTEMP) mintemp_raw_BOARD += TEMPDIR(BOARD) * (OVERSAMPLENR); - while (analog_to_celsius_board(maxtemp_raw_BOARD) > BOARD_MAXTEMP) maxtemp_raw_BOARD -= TEMPDIR(BOARD) * (OVERSAMPLENR); + while (analog_to_celsius_board(temp_sensor_range_board.raw_min) < BOARD_MINTEMP) + temp_sensor_range_board.raw_min += TEMPDIR(BOARD) * (OVERSAMPLENR); + while (analog_to_celsius_board(temp_sensor_range_board.raw_max) > BOARD_MAXTEMP) + temp_sensor_range_board.raw_max -= TEMPDIR(BOARD) * (OVERSAMPLENR); #endif #if ALL(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC) diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 2acc1205b730..088a17ec1b99 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -522,6 +522,9 @@ struct HeaterWatch { typedef struct HeaterWatch cooler_watch_t; #endif +// Just raw temperature sensor ranges +typedef struct { raw_adc_t raw_min, raw_max; } temp_raw_range_t; + // Temperature sensor read value ranges typedef struct { raw_adc_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t; @@ -594,7 +597,7 @@ class Temperature { #if HAS_HOTEND static hotend_info_t temp_hotend[HOTENDS]; static constexpr celsius_t hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); - static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } + static constexpr celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif #if HAS_HEATED_BED @@ -727,6 +730,7 @@ class Temperature { #endif #if HAS_HOTEND + // Sensor ranges, not user-configured static temp_range_t temp_range[HOTENDS]; #endif @@ -737,7 +741,7 @@ class Temperature { #if DISABLED(PIDTEMPBED) static millis_t next_bed_check_ms; #endif - static raw_adc_t mintemp_raw_BED, maxtemp_raw_BED; + static temp_raw_range_t temp_sensor_range_bed; #endif #if HAS_HEATED_CHAMBER @@ -747,7 +751,7 @@ class Temperature { #if DISABLED(PIDTEMPCHAMBER) static millis_t next_chamber_check_ms; #endif - static raw_adc_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; + static temp_raw_range_t temp_sensor_range_chamber; #endif #if HAS_COOLER @@ -755,11 +759,11 @@ class Temperature { static cooler_watch_t watch_cooler; #endif static millis_t next_cooler_check_ms, cooler_fan_flush_ms; - static raw_adc_t mintemp_raw_COOLER, maxtemp_raw_COOLER; + static temp_raw_range_t temp_sensor_range_cooler; #endif #if ALL(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) - static raw_adc_t mintemp_raw_BOARD, maxtemp_raw_BOARD; + static temp_raw_range_t temp_sensor_range_board; #endif #if ALL(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC) @@ -1193,8 +1197,10 @@ class Temperature { static constexpr bool adaptive_fan_slowing = true; #endif + static bool tuning_idle(const millis_t &ms); + /** - * Perform auto-tuning for hotend or bed in response to M303 + * M303 PID auto-tuning for hotends or bed */ #if HAS_PID_HEATING @@ -1219,6 +1225,9 @@ class Temperature { #endif // HAS_PID_HEATING + /** + * M306 MPC auto-tuning for hotends + */ #if ENABLED(MPC_AUTOTUNE) // Utility class to perform MPCTEMP auto tuning measurements diff --git a/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h b/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h index 360501aa08ac..65f734c7605d 100644 --- a/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h +++ b/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h @@ -34,7 +34,9 @@ // // I2S (steppers & other output-only pins) // -#define I2S_STEPPER_STREAM +#ifndef I2S_STEPPER_STREAM + #define I2S_STEPPER_STREAM +#endif #if ENABLED(I2S_STEPPER_STREAM) #define I2S_WS 17 #define I2S_BCK 22 diff --git a/Marlin/src/pins/esp32/pins_ESP32.h b/Marlin/src/pins/esp32/pins_ESP32.h index 1c01be8a88bc..9c9b06ca6437 100644 --- a/Marlin/src/pins/esp32/pins_ESP32.h +++ b/Marlin/src/pins/esp32/pins_ESP32.h @@ -32,7 +32,9 @@ // // I2S (steppers & other output-only pins) // -#define I2S_STEPPER_STREAM +#ifndef I2S_STEPPER_STREAM + #define I2S_STEPPER_STREAM +#endif #if ENABLED(I2S_STEPPER_STREAM) #define I2S_WS 25 #define I2S_BCK 26 diff --git a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h index 43196bafa91b..69afcc1aeb73 100644 --- a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h +++ b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h @@ -56,7 +56,9 @@ // // Enable I2S stepper stream // -#define I2S_STEPPER_STREAM +#ifndef I2S_STEPPER_STREAM + #define I2S_STEPPER_STREAM +#endif #if ENABLED(I2S_STEPPER_STREAM) #define I2S_WS 26 #define I2S_BCK 25 diff --git a/Marlin/src/pins/esp32/pins_MM_JOKER.h b/Marlin/src/pins/esp32/pins_MM_JOKER.h index 52ed543c33fd..b992fe89c3c8 100644 --- a/Marlin/src/pins/esp32/pins_MM_JOKER.h +++ b/Marlin/src/pins/esp32/pins_MM_JOKER.h @@ -85,7 +85,9 @@ // // Enable I2S stepper stream // -#define I2S_STEPPER_STREAM +#ifndef I2S_STEPPER_STREAM + #define I2S_STEPPER_STREAM +#endif #if ENABLED(I2S_STEPPER_STREAM) #define I2S_WS 26 #define I2S_BCK 25 diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPE.h b/Marlin/src/pins/esp32/pins_MRR_ESPE.h index d88a3ab35968..90ff78487f33 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPE.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPE.h @@ -51,7 +51,9 @@ // // Enable I2S stepper stream // -#define I2S_STEPPER_STREAM +#ifndef I2S_STEPPER_STREAM + #define I2S_STEPPER_STREAM +#endif #if ENABLED(I2S_STEPPER_STREAM) #define I2S_WS 26 #define I2S_BCK 25 diff --git a/Marlin/src/pins/esp32/pins_RESP32_CUSTOM.h b/Marlin/src/pins/esp32/pins_RESP32_CUSTOM.h index 5d3f75574d89..f627909a7a32 100644 --- a/Marlin/src/pins/esp32/pins_RESP32_CUSTOM.h +++ b/Marlin/src/pins/esp32/pins_RESP32_CUSTOM.h @@ -34,4 +34,6 @@ // // I2S (steppers & other output-only pins) // -#define I2S_STEPPER_STREAM +#ifndef I2S_STEPPER_STREAM + #define I2S_STEPPER_STREAM +#endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index e5467833e56b..e97b6ceaa440 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -487,8 +487,20 @@ #define SUICIDE_PIN_STATE LOW #endif -#ifndef NUM_SERVO_PLUGS +#if PIN_EXISTS(SERVO5) + #define NUM_SERVO_PLUGS 6 +#elif PIN_EXISTS(SERVO4) + #define NUM_SERVO_PLUGS 5 +#elif PIN_EXISTS(SERVO3) #define NUM_SERVO_PLUGS 4 +#elif PIN_EXISTS(SERVO2) + #define NUM_SERVO_PLUGS 3 +#elif PIN_EXISTS(SERVO1) + #define NUM_SERVO_PLUGS 2 +#elif PIN_EXISTS(SERVO0) + #define NUM_SERVO_PLUGS 1 +#else + #define NUM_SERVO_PLUGS 0 #endif // Only used within pins files diff --git a/buildroot/tests/BIGTREE_GTR_V1_0 b/buildroot/tests/BIGTREE_GTR_V1_0 index 62ca3c24f274..e2e70e5f81e3 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0 +++ b/buildroot/tests/BIGTREE_GTR_V1_0 @@ -33,6 +33,7 @@ exec_test $1 $2 "BigTreeTech GTR | 6 Extruders | Quad Z + Endstops" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ EXTRUDERS 3 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 \ + SERVO1_PIN PE9 SERVO2_PIN PE11 \ SERVO_DELAY '{ 300, 300, 300 }' \ SWITCHING_TOOLHEAD_X_POS '{ 215, 0 ,0 }' \ MPC_HEATER_POWER '{ 40.0f, 40.0f, 40.0f }' \ diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 1fbdd6b58b20..c41e73640d44 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -87,7 +87,7 @@ opt_disable X_DRIVER_TYPE Y_DRIVER_TYPE Z_DRIVER_TYPE exec_test $1 $2 "E Axis Only | DOGM MarlinUI" "$3" # -# Mixing Extruder with 5 steppers, Greek +# Mixing Extruder with 5 steppers, Russian # restore_configs opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO MIXING_STEPPERS 5 LCD_LANGUAGE ru \ @@ -98,7 +98,7 @@ opt_enable MIXING_EXTRUDER GRADIENT_MIX GRADIENT_VTOOL CR10_STOCKDISPLAY \ XY_AFTER_HOMING EVENT_GCODE_AFTER_HOMING \ FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE INPUT_SHAPING_X INPUT_SHAPING_Y opt_disable DISABLE_OTHER_EXTRUDERS -exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Input Shaping | Greek" "$3" +exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Input Shaping | Russian" "$3" # # Test SPEAKER with BOARD_BQ_ZUM_MEGA_3D and BQ_LCD_SMART_CONTROLLER diff --git a/ini/esp32.ini b/ini/esp32.ini index 98c3e067552e..909394eae1e4 100644 --- a/ini/esp32.ini +++ b/ini/esp32.ini @@ -13,15 +13,17 @@ # Espressif ESP32 # [env:esp32] -platform = espressif32@2.1.0 -board = esp32dev -build_flags = ${common.build_flags} -DCORE_DEBUG_LEVEL=0 -build_src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet -upload_speed = 500000 -monitor_speed = 250000 -monitor_filters = colorize, time, send_on_enter, log2file, esp32_exception_decoder -#upload_port = marlinesp.local +platform = espressif32@2.1.0 +platform_packages = espressif/toolchain-xtensa-esp32s3 +board = esp32dev +build_flags = ${common.build_flags} -DCORE_DEBUG_LEVEL=0 -std=gnu++17 +build_unflags = -std=gnu11 -std=gnu++11 +build_src_filter = ${common.default_src_filter} + +lib_ignore = NativeEthernet +upload_speed = 500000 +monitor_speed = 250000 +monitor_filters = colorize, time, send_on_enter, log2file, esp32_exception_decoder +#upload_port = marlinesp.local #board_build.flash_mode = qio [env:FYSETC_E4] diff --git a/ini/features.ini b/ini/features.ini index c4af1d0d951f..8e0cb964f18b 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -288,6 +288,7 @@ HAS_EXTRA_ENDSTOPS = build_src_filter=+ DIRECT_PIN_CONTROL = build_src_filter=+ + PINS_DEBUGGING = build_src_filter=+ +EDITABLE_STEPS_PER_UNIT = build_src_filter=+ HAS_MULTI_EXTRUDER = build_src_filter=+ HAS_HOTEND_OFFSET = build_src_filter=+ EDITABLE_SERVO_ANGLES = build_src_filter=+ diff --git a/platformio.ini b/platformio.ini index e6adfe2b6be5..76200cbbd5c3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -97,7 +97,6 @@ default_src_filter = + - - ; Minimal Requirements ; + - + + + +