From a653c3aca02f4b0eb8da0c2b7f90c0bb33d8cb9c Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 19 Apr 2025 10:36:22 +1200 Subject: [PATCH 01/51] =?UTF-8?q?=F0=9F=8E=A8=20Binary=20Stream=20cleanup?= =?UTF-8?q?=20(#27799)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/binary_stream.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index b2d76c045a..304fdae300 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -134,19 +134,19 @@ private: public: static void idle() { - // If a transfer is interrupted and a file is left open, abort it after TIMEOUT ms + // If a transfer is interrupted and a file is left open, abort it after 'idle_period' ms const millis_t ms = millis(); if (transfer_active && ELAPSED(ms, idle_timeout)) { - idle_timeout = ms + IDLE_PERIOD; + idle_timeout = ms + idle_period; if (ELAPSED(ms, transfer_timeout)) transfer_abort(); } } static void process(uint8_t packet_type, char *buffer, const uint16_t length) { - transfer_timeout = millis() + TIMEOUT; + transfer_timeout = millis() + timeout; switch (static_cast(packet_type)) { case FileTransfer::QUERY: - SERIAL_ECHO(F("PFT:version:"), VERSION_MAJOR, C('.'), VERSION_MINOR, C('.'), VERSION_PATCH); + SERIAL_ECHO(F("PFT:version:"), version_major, C('.'), version_minor, C('.'), version_patch); #if ENABLED(BINARY_STREAM_COMPRESSION) SERIAL_ECHOLN(F(":compression:heatshrink,"), HEATSHRINK_STATIC_WINDOW_BITS, C(','), HEATSHRINK_STATIC_LOOKAHEAD_BITS); #else @@ -194,7 +194,7 @@ public: } } - static const uint16_t VERSION_MAJOR = 0, VERSION_MINOR = 1, VERSION_PATCH = 0, TIMEOUT = 10000, IDLE_PERIOD = 1000; + static const uint16_t version_major = 0, version_minor = 1, version_patch = 0, timeout = 10000, idle_period = 1000; }; class BinaryStream { @@ -209,7 +209,7 @@ public: struct Packet { // 10 byte protocol overhead, ascii with checksum and line number has a minimum of 7 increasing with line union Header { - static constexpr uint16_t HEADER_TOKEN = 0xB5AD; + static constexpr uint16_t header_token = 0xB5AD; struct [[gnu::packed]] { uint16_t token; // packet start token uint8_t sync; // stream sync, resend id and packet loss detection @@ -245,7 +245,7 @@ public: bytes_received = 0; checksum = 0; header_checksum = 0; - timeout = millis() + PACKET_MAX_WAIT; + timeout = millis() + packet_max_wait; buffer = nullptr; } } packet{}; @@ -272,14 +272,14 @@ public: } if (!bs_serial_data_available(card.transfer_port_index)) return false; data = bs_read_serial(card.transfer_port_index); - packet.timeout = millis() + PACKET_MAX_WAIT; + packet.timeout = millis() + packet_max_wait; return true; } template void receive(char (&buffer)[buffer_size]) { uint8_t data = 0; - millis_t transfer_window = millis() + RX_TIMESLICE; + millis_t transfer_window = millis() + rx_timeslice; #if HAS_MEDIA PORT_REDIRECT(SERIAL_PORTMASK(card.transfer_port_index)); @@ -299,7 +299,7 @@ public: case StreamState::PACKET_WAIT: if (!stream_read(data)) { idle(); return; } // no active packet so don't wait packet.header.data[1] = data; - if (packet.header.token == packet.header.HEADER_TOKEN) { + if (packet.header.token == packet.header.header_token) { packet.bytes_received = 2; stream_state = StreamState::PACKET_HEADER; } @@ -322,7 +322,7 @@ public: if (packet.header.checksum == packet.header_checksum) { // The SYNC control packet is a special case in that it doesn't require the stream sync to be correct if (static_cast(packet.header.protocol()) == Protocol::CONTROL && static_cast(packet.header.type()) == ProtocolControl::SYNC) { - SERIAL_ECHOLN(F("ss"), sync, C(','), buffer_size, C(','), VERSION_MAJOR, C('.'), VERSION_MINOR, C('.'), VERSION_PATCH); + SERIAL_ECHOLN(F("ss"), sync, C(','), buffer_size, C(','), version_major, C('.'), version_minor, C('.'), version_patch); stream_state = StreamState::PACKET_RESET; break; } @@ -398,7 +398,7 @@ public: stream_state = StreamState::PACKET_RESET; break; case StreamState::PACKET_RESEND: - if (packet_retries < MAX_RETRIES || MAX_RETRIES == 0) { + if (packet_retries < max_retries || max_retries == 0) { packet_retries++; stream_state = StreamState::PACKET_RESET; SERIAL_ECHO_MSG("Resend request ", packet_retries); @@ -446,7 +446,7 @@ public: SDFileTransferProtocol::idle(); } - static const uint16_t PACKET_MAX_WAIT = 500, RX_TIMESLICE = 20, MAX_RETRIES = 0, VERSION_MAJOR = 0, VERSION_MINOR = 1, VERSION_PATCH = 0; + static const uint16_t packet_max_wait = 500, rx_timeslice = 20, max_retries = 0, version_major = 0, version_minor = 1, version_patch = 0; uint8_t packet_retries, sync; uint16_t buffer_next_index; uint32_t bytes_received; From 3c32770faf895b9306a8433b6849da37a1b4e554 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 19 Apr 2025 00:28:50 +0000 Subject: [PATCH 02/51] [cron] Bump distribution date (2025-04-19) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 2260bfc119..bf36617e2c 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 "2025-04-18" +//#define STRING_DISTRIBUTION_DATE "2025-04-19" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index e4d0c6679b..b03913446a 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 "2025-04-18" + #define STRING_DISTRIBUTION_DATE "2025-04-19" #endif /** From d009c48b11d65897b7432a089c829c6ef2adee53 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 19 Apr 2025 12:43:31 +1200 Subject: [PATCH 03/51] =?UTF-8?q?=E2=9C=A8=20Simulator:=20Virtual=20servos?= =?UTF-8?q?,=20BLTouch=20(#27779)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Christopher Pepper --- Marlin/src/HAL/NATIVE_SIM/HAL.h | 10 +- Marlin/src/HAL/NATIVE_SIM/Servo.cpp | 104 ++++++++++++++++++ Marlin/src/HAL/NATIVE_SIM/Servo.h | 48 ++++++++ .../src/HAL/NATIVE_SIM/endstop_interrupts.h | 30 +++++ Marlin/src/HAL/NATIVE_SIM/servo_private.h | 79 ------------- Marlin/src/HAL/shared/servo.h | 30 ++--- ini/native.ini | 2 +- 7 files changed, 206 insertions(+), 97 deletions(-) create mode 100644 Marlin/src/HAL/NATIVE_SIM/Servo.cpp create mode 100644 Marlin/src/HAL/NATIVE_SIM/Servo.h create mode 100644 Marlin/src/HAL/NATIVE_SIM/endstop_interrupts.h delete mode 100644 Marlin/src/HAL/NATIVE_SIM/servo_private.h diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index f741d0b246..ffede7ef34 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -52,7 +52,9 @@ uint8_t _getc(); // ------------------------ #define CPU_32_BIT -#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; #define F_CPU 100000000 #define SystemCoreClock F_CPU @@ -232,8 +234,10 @@ public: * No option to invert the duty cycle [default = false] * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] */ - static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { - analogWrite(pin, v); + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false) { + auto value = map(v, 0, v_size, 0, UINT16_MAX); + value = invert ? UINT16_MAX - value : value; + analogWrite(pin, value); } static void set_pwm_frequency(const pin_t, int) {} diff --git a/Marlin/src/HAL/NATIVE_SIM/Servo.cpp b/Marlin/src/HAL/NATIVE_SIM/Servo.cpp new file mode 100644 index 0000000000..a15eda1bf6 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/Servo.cpp @@ -0,0 +1,104 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "../platforms.h" + +#ifdef __PLAT_NATIVE_SIM__ + +#include "../../inc/MarlinConfig.h" + +#if HAS_SERVOS + +#include "Servo.h" + +//#define DEBUG_SERVOS +#define DEBUG_OUT ENABLED(DEBUG_SERVOS) +#include "../../../core/debug_out.h" + +uint8_t ServoCount = 0; // the total number of attached servos + +Servo::Servo() { + // Constructor stub + DEBUG_ECHOLNPGM("Debug Servo: constructor"); + this->servoIndex = ServoCount++; // assign a servo index to this instance +} + +uint8_t Servo::attach(int pin) { + // Attach stub + DEBUG_ECHOLNPGM("Debug Servo: attach to pin ", pin, " servo index ", this->servoIndex); + return attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); +} + +uint8_t Servo::attach(int pin, int min, int max) { + // Attach with min and max stub + DEBUG_ECHOLNPGM("Debug Servo: attach to pin ", pin, " with min ", min, " and max ", max); + if (pin > 0) servo_pin = pin; + return this->servoIndex; +} + +void Servo::detach() { + // Detach stub + DEBUG_ECHOLNPGM("Debug Servo: detach"); +} + +// If value is < 200 it is treated as an angle, otherwise as pulse width in microseconds +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_US(min), SERVO_MAX_US(max)); + } + writeMicroseconds(value); + DEBUG_ECHOLNPGM("Debug Servo: write ", value); +} + +void Servo::writeMicroseconds(int value) { + // Simulate the servo movement + this->value = value; + hal.set_pwm_duty(pin_t(this->servo_pin), (float(value) / 20000) * UINT16_MAX, UINT16_MAX); + DEBUG_ECHOLNPGM("Debug Servo: write microseconds ", value); +} + +int Servo::read() { + // Read stub + DEBUG_ECHOLNPGM("Debug Servo: read ", this->value); + return this->value; +} + +int Servo::readMicroseconds() { + // Read microseconds stub + DEBUG_ECHOLNPGM("Debug Servo: read microseconds"); + return 0; +} + +bool Servo::attached() { + // Attached stub + DEBUG_ECHOLNPGM("Debug Servo: attached"); + return false; +} + +int Servo::move(const unsigned char cmd) { + // Move stub + DEBUG_ECHOLNPGM("Debug Servo: move ", cmd); + write(cmd); + return 0; +} + +#endif // HAS_SERVOS +#endif // __PLAT_NATIVE_SIM__ diff --git a/Marlin/src/HAL/NATIVE_SIM/Servo.h b/Marlin/src/HAL/NATIVE_SIM/Servo.h new file mode 100644 index 0000000000..428871142c --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/Servo.h @@ -0,0 +1,48 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo +#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo +#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached +#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 + +class Servo { +public: + Servo(); + uint8_t attach(int pin); // Attach the given pin to the next free channel, set pinMode, return channel number or INVALID_SERVO if failure + uint8_t attach(int pin, int min, int max); // As above but also set min and max values for writes. + void detach(); + void write(int value); // If value is < 200 it's treated as an angle, otherwise as pulse width in microseconds + void writeMicroseconds(int value); // Write pulse width in microseconds + int read(); // Return current pulse width as an angle between 0 and 180 degrees + int readMicroseconds(); // Return current pulse width in microseconds for this servo + bool attached(); // Return true if this servo is attached, otherwise false + int move (const unsigned char cmd); +private: + uint8_t servoIndex; // Index into the channel data for this servo + int8_t min; // Minimum is this value times 4 added to MIN_PULSE_WIDTH + int8_t max; // Maximum is this value times 4 added to MAX_PULSE_WIDTH + int value; // Pulse width in microseconds for this servo + int servo_pin = 0; // pin number for this servo +}; diff --git a/Marlin/src/HAL/NATIVE_SIM/endstop_interrupts.h b/Marlin/src/HAL/NATIVE_SIM/endstop_interrupts.h new file mode 100644 index 0000000000..e74c312274 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/endstop_interrupts.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#error "ENDSTOP_INTERRUPTS_FEATURE is not supported in this simulation environment." + +void setup_endstop_interrupts() { + // This function is a stub for setting up endstop interrupts. + // Since this is a simulation environment, actual hardware interrupts + // are not applicable. Add any necessary simulation-specific logic here. +} diff --git a/Marlin/src/HAL/NATIVE_SIM/servo_private.h b/Marlin/src/HAL/NATIVE_SIM/servo_private.h deleted file mode 100644 index e0eb30ab28..0000000000 --- a/Marlin/src/HAL/NATIVE_SIM/servo_private.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/** - * servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 - * Copyright (c) 2009 Michael Margolis. All right reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * Based on "servo.h - Interrupt driven Servo library for Arduino using 16 bit timers - - * Version 2 Copyright (c) 2009 Michael Margolis. All right reserved. - * - * The only modification was to update/delete macros to match the LPC176x. - * - */ - -#include - -// Macros -//values in microseconds -#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo -#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo -#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached -#define REFRESH_INTERVAL 20000 // minimum time to refresh servos in microseconds - -#define MAX_SERVOS 4 - -#define INVALID_SERVO 255 // flag indicating an invalid servo index - -// Types - -typedef struct { - uint8_t nbr : 8 ; // a pin number from 0 to 254 (255 signals invalid pin) - uint8_t isActive : 1 ; // true if this channel is enabled, pin not pulsed if false -} ServoPin_t; - -typedef struct { - ServoPin_t Pin; - unsigned int pulse_width; // pulse width in microseconds -} ServoInfo_t; - -// Global variables - -extern uint8_t ServoCount; -extern ServoInfo_t servo_info[MAX_SERVOS]; diff --git a/Marlin/src/HAL/shared/servo.h b/Marlin/src/HAL/shared/servo.h index 0101fcb628..85e645146c 100644 --- a/Marlin/src/HAL/shared/servo.h +++ b/Marlin/src/HAL/shared/servo.h @@ -59,7 +59,7 @@ * write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) * writeMicroseconds() - Sets the servo pulse width in microseconds * read() - Gets the last written servo pulse width as an angle between 0 and 180. - * readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) + * readMicroseconds() - Gets the last written servo pulse width in microseconds. * attached() - Returns true if there is a servo attached. * detach() - Stops an attached servos from pulsing its i/o pin. * move(angle) - Sequence of attach(0), write(angle), @@ -86,6 +86,8 @@ #include "../ESP32/Servo.h" #elif defined(__PLAT_RP2040__) #include "../RP2040/Servo.h" +#elif defined(__PLAT_NATIVE_SIM__) + #include "../NATIVE_SIM/Servo.h" #else #include @@ -100,22 +102,22 @@ class Servo { public: Servo(); - int8_t attach(const int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail) - int8_t attach(const int pin, const int min, const int max); // as above but also sets min and max values for writes. + int8_t attach(const int pin); // Attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail) + int8_t attach(const int pin, const int min, const int max); // As above but also set min and max values for writes. void detach(); - void write(int value); // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds - void writeMicroseconds(int value); // write pulse width in microseconds - void move(const int value); // attach the servo, then move to value - // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds - // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach - int read(); // returns current pulse width as an angle between 0 and 180 degrees - int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) - bool attached(); // return true if this servo is attached, otherwise false + void write(int value); // If value is < 200 it is treated as an angle, otherwise as pulse width in microseconds + void writeMicroseconds(int value); // Write pulse width in microseconds + void move(const int value); // Attach the servo, then move to value + // If value is < 200 it is treated as an angle, otherwise as pulse width in microseconds + // If DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach + int read(); // Return current pulse width as an angle between 0 and 180 degrees + int readMicroseconds(); // Return current pulse width in microseconds for this servo + bool attached(); // Return true if this servo is attached, otherwise false private: - uint8_t servoIndex; // index into the channel data for this servo - int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH - int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH + uint8_t servoIndex; // Index into the channel data for this servo + int8_t min; // Minimum is this value times 4 added to MIN_PULSE_WIDTH + int8_t max; // Maximum is this value times 4 added to MAX_PULSE_WIDTH }; #endif diff --git a/ini/native.ini b/ini/native.ini index 479155a78c..f01e72ca67 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -58,7 +58,7 @@ debug_build_flags = -fstack-protector-strong -g -g3 -ggdb lib_compat_mode = off build_src_filter = ${common.default_src_filter} + lib_deps = ${common.lib_deps} - MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/afe7c1c293.zip + MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/6ea016e104.zip Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/c6b319f447.zip LiquidCrystal=https://github.com/p3p/LiquidCrystal/archive/322fb5fc23.zip extra_scripts = ${common.extra_scripts} From d40bf0d6b271baa6cea9181faef8470ac033fd3c Mon Sep 17 00:00:00 2001 From: B Date: Fri, 18 Apr 2025 17:53:18 -0700 Subject: [PATCH 04/51] =?UTF-8?q?=F0=9F=90=9B=20Fix=20GD32=20ignoring=20SE?= =?UTF-8?q?RIAL=5FDMA=20on=20init=20(#27800)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/GD32_MFL/MarlinSerial.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Marlin/src/HAL/GD32_MFL/MarlinSerial.cpp b/Marlin/src/HAL/GD32_MFL/MarlinSerial.cpp index c9b76a4ca4..271247295c 100644 --- a/Marlin/src/HAL/GD32_MFL/MarlinSerial.cpp +++ b/Marlin/src/HAL/GD32_MFL/MarlinSerial.cpp @@ -60,10 +60,9 @@ MarlinSerial& MarlinSerial::get_instance(usart::USART_Base Base, pin_size_t rxPi static MarlinSerial* current_serial_instance = nullptr; static void emergency_callback() { - if (current_serial_instance) { - uint8_t last_data = current_serial_instance->get_last_data(); - emergency_parser.update(current_serial_instance->emergency_state, last_data); - } + if (!current_serial_instance) return; + const uint8_t last_data = current_serial_instance->get_last_data(); + emergency_parser.update(current_serial_instance->emergency_state, last_data); } void MarlinSerial::register_emergency_callback(void (*callback)()) { @@ -72,26 +71,23 @@ MarlinSerial& MarlinSerial::get_instance(usart::USART_Base Base, pin_size_t rxPi #endif void MarlinSerial::begin(unsigned long baudrate, uint16_t config) { - UsartSerial::begin(baudrate, config); - #if DISABLED(SERIAL_DMA) - #if ENABLED(EMERGENCY_PARSER) - current_serial_instance = this; - register_emergency_callback(emergency_callback); - #endif + UsartSerial::begin(baudrate, config, ENABLED(SERIAL_DMA)); + #if ENABLED(EMERGENCY_PARSER) && DISABLED(SERIAL_DMA) + current_serial_instance = this; + register_emergency_callback(emergency_callback); #endif } void MarlinSerial::updateRxDmaBuffer() { #if ENABLED(EMERGENCY_PARSER) // Get the number of bytes available in the receive buffer - size_t available_bytes = usart_.available_for_read(true); - uint8_t data; + const size_t available_bytes = usart_.available_for_read(true); // Process only the available data for (size_t i = 0; i < available_bytes; ++i) { - if (usart_.read_rx_buffer(data)) { + uint8_t data; + if (usart_.read_rx_buffer(data)) emergency_parser.update(emergency_state, data); - } } #endif // Call the base class implementation to handle any additional updates From 067c830e840b69f04b7ce9f9d9a647cdf58090e1 Mon Sep 17 00:00:00 2001 From: B Date: Fri, 18 Apr 2025 17:55:26 -0700 Subject: [PATCH 05/51] =?UTF-8?q?=F0=9F=93=8C=20GD32=20platform=20v1.0.3?= =?UTF-8?q?=20(and=20Arduino=20v1.0.4)=20(#27801)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/gd32.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ini/gd32.ini b/ini/gd32.ini index e983f496ec..5187895021 100644 --- a/ini/gd32.ini +++ b/ini/gd32.ini @@ -10,7 +10,7 @@ #################################### [gd32_base] -platform = https://github.com/bmourit/platform-mfl/archive/refs/tags/V1.0.2.zip +platform = https://github.com/bmourit/platform-mfl/archive/refs/tags/V1.0.3.zip board_build.core = gd32 build_src_filter = ${common.default_src_filter} + + build_unflags = -std=gnu++11 -std=gnu++14 -std=gnu++17 From 26b3f0b00f897a0624fd96d064f50cb3cf54d3b2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 18 Apr 2025 19:56:46 -0500 Subject: [PATCH 06/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Plann?= =?UTF-8?q?er::max=5Fjerk=20always=20xyze=5Fpos=5Ft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/planner.cpp | 2 +- Marlin/src/module/planner.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index b3df490cf0..881e11f4c0 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -157,7 +157,7 @@ uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) D float Planner::max_e_jerk[DISTINCT_E]; // Calculated from junction_deviation_mm #endif #else // CLASSIC_JERK - TERN(HAS_LINEAR_E_JERK, xyz_pos_t, xyze_pos_t) Planner::max_jerk; + xyze_pos_t Planner::max_jerk; #endif #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 318be33131..e8bacddd9f 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -494,7 +494,7 @@ class Planner { #endif #else // CLASSIC_JERK // (mm/s^2) M205 XYZ(E) - The largest speed change requiring no acceleration. - static TERN(HAS_LINEAR_E_JERK, xyz_pos_t, xyze_pos_t) max_jerk; + static xyze_pos_t max_jerk; #endif #if HAS_LEVELING From 87f26e77ff2180fc487e2547487915eee4d526cd Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 20 Apr 2025 00:33:22 +0000 Subject: [PATCH 07/51] [cron] Bump distribution date (2025-04-20) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index bf36617e2c..85663d4899 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 "2025-04-19" +//#define STRING_DISTRIBUTION_DATE "2025-04-20" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index b03913446a..f46988c11b 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 "2025-04-19" + #define STRING_DISTRIBUTION_DATE "2025-04-20" #endif /** From b97b09413f1cd805743240a1f3f0c94f4a10d1e2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 19 Apr 2025 20:04:59 -0500 Subject: [PATCH 08/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20stepper/control.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/DUE/fastio/G2_PWM.cpp | 3 +- Marlin/src/HAL/DUE/fastio/G2_PWM.h | 5 +- Marlin/src/inc/Conditionals-5-post.h | 4 + Marlin/src/module/stepper.cpp | 735 --------------------- Marlin/src/module/stepper/control.cpp | 764 ++++++++++++++++++++++ Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h | 8 +- ini/features.ini | 1 + 7 files changed, 776 insertions(+), 744 deletions(-) create mode 100644 Marlin/src/module/stepper/control.cpp diff --git a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp index 403e3356e1..745e4205bc 100644 --- a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp +++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp @@ -40,11 +40,12 @@ * Some jitter in the Vref signal is OK so the interrupt priority is left at its default value. */ -#include "../../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfigPre.h" #if MB(PRINTRBOARD_G2) #include "G2_PWM.h" +#include "../../../module/stepper.h" #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) #define G2_PWM_X 1 diff --git a/Marlin/src/HAL/DUE/fastio/G2_PWM.h b/Marlin/src/HAL/DUE/fastio/G2_PWM.h index 054eb2cf80..7fb2aaf7a8 100644 --- a/Marlin/src/HAL/DUE/fastio/G2_PWM.h +++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.h @@ -26,10 +26,7 @@ * PR #7500. It is hardwired for the PRINTRBOARD_G2 Motor Current needs. */ -#include "../../../inc/MarlinConfigPre.h" -#include "../../../module/stepper.h" -//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\stepper.h -//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\HAL\HAL_DUE\G2_PWM.h +#include #define PWM_PERIOD_US 100 // base repetition rate in micro seconds diff --git a/Marlin/src/inc/Conditionals-5-post.h b/Marlin/src/inc/Conditionals-5-post.h index 380e8e6071..920031dcdb 100644 --- a/Marlin/src/inc/Conditionals-5-post.h +++ b/Marlin/src/inc/Conditionals-5-post.h @@ -3012,6 +3012,10 @@ #undef MICROSTEP_MODES #endif +#if MB(PRINTRBOARD_G2) || ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MICROSTEPS) + #define HAS_STEPPER_CONTROL 1 +#endif + /** * Helper Macros for heaters and extruder fan */ diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 85c7521960..1340cd9157 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -3627,738 +3627,3 @@ void Stepper::report_positions() { } #endif // BABYSTEPPING - -/** - * Software-controlled Stepper Motor Current - */ - -#if HAS_MOTOR_CURRENT_SPI - - // From Arduino DigitalPotControl example - void Stepper::set_digipot_value_spi(const int16_t address, const int16_t value) { - WRITE(DIGIPOTSS_PIN, LOW); // Take the SS pin low to select the chip - SPI.transfer(address); // Send the address and value via SPI - SPI.transfer(value); - WRITE(DIGIPOTSS_PIN, HIGH); // Take the SS pin high to de-select the chip - //delay(10); - } - -#endif // HAS_MOTOR_CURRENT_SPI - -#if HAS_MOTOR_CURRENT_PWM - - void Stepper::refresh_motor_power() { - if (!initialized) return; - for (uint8_t i = 0; i < COUNT(motor_current_setting); ++i) { - switch (i) { - #if ANY_PIN(MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K, MOTOR_CURRENT_PWM_U, MOTOR_CURRENT_PWM_V, MOTOR_CURRENT_PWM_W) - case 0: - #endif - #if HAS_MOTOR_CURRENT_PWM_Z - case 1: - #endif - #if HAS_MOTOR_CURRENT_PWM_E - case 2: - #endif - set_digipot_current(i, motor_current_setting[i]); - default: break; - } - } - } - -#endif // HAS_MOTOR_CURRENT_PWM - -#if !MB(PRINTRBOARD_G2) - - #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM - - void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { - if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1)) - motor_current_setting[driver] = current; // update motor_current_setting - - if (!initialized) return; - - #if HAS_MOTOR_CURRENT_SPI - - //SERIAL_ECHOLNPGM("Digipotss current ", current); - - const uint8_t digipot_ch[] = DIGIPOT_CHANNELS; - set_digipot_value_spi(digipot_ch[driver], current); - - #elif HAS_MOTOR_CURRENT_PWM - - #define _WRITE_CURRENT_PWM(P) hal.set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) - switch (driver) { - case 0: - #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) - _WRITE_CURRENT_PWM(X); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) - _WRITE_CURRENT_PWM(Y); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - _WRITE_CURRENT_PWM(XY); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_I) - _WRITE_CURRENT_PWM(I); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_J) - _WRITE_CURRENT_PWM(J); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_K) - _WRITE_CURRENT_PWM(K); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_U) - _WRITE_CURRENT_PWM(U); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_V) - _WRITE_CURRENT_PWM(V); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_W) - _WRITE_CURRENT_PWM(W); - #endif - break; - case 1: - #if HAS_MOTOR_CURRENT_PWM_Z - _WRITE_CURRENT_PWM(Z); - #endif - break; - case 2: - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - _WRITE_CURRENT_PWM(E); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) - _WRITE_CURRENT_PWM(E0); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) - _WRITE_CURRENT_PWM(E1); - #endif - break; - } - #endif - } - - void Stepper::digipot_init() { - - #if HAS_MOTOR_CURRENT_SPI - - SPI.begin(); - SET_OUTPUT(DIGIPOTSS_PIN); - - for (uint8_t i = 0; i < COUNT(motor_current_setting); ++i) - set_digipot_current(i, motor_current_setting[i]); - - #elif HAS_MOTOR_CURRENT_PWM - - #ifdef __SAM3X8E__ - #define _RESET_CURRENT_PWM_FREQ(P) NOOP - #else - #define _RESET_CURRENT_PWM_FREQ(P) hal.set_pwm_frequency(pin_t(P), MOTOR_CURRENT_PWM_FREQUENCY) - #endif - #define INIT_CURRENT_PWM(P) do{ SET_PWM(MOTOR_CURRENT_PWM_## P ##_PIN); _RESET_CURRENT_PWM_FREQ(MOTOR_CURRENT_PWM_## P ##_PIN); }while(0) - - #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) - INIT_CURRENT_PWM(X); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) - INIT_CURRENT_PWM(Y); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - INIT_CURRENT_PWM(XY); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_I) - INIT_CURRENT_PWM(I); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_J) - INIT_CURRENT_PWM(J); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_K) - INIT_CURRENT_PWM(K); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_U) - INIT_CURRENT_PWM(U); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_V) - INIT_CURRENT_PWM(V); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_W) - INIT_CURRENT_PWM(W); - #endif - #if HAS_MOTOR_CURRENT_PWM_Z - INIT_CURRENT_PWM(Z); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - INIT_CURRENT_PWM(E); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) - INIT_CURRENT_PWM(E0); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) - INIT_CURRENT_PWM(E1); - #endif - - refresh_motor_power(); - - #endif - } - - #endif - -#else // PRINTRBOARD_G2 - - #include HAL_PATH(.., fastio/G2_PWM.h) - -#endif - -#if HAS_MICROSTEPS - - /** - * Software-controlled Microstepping - */ - - void Stepper::microstep_init() { - #if HAS_X_MS_PINS - SET_OUTPUT(X_MS1_PIN); SET_OUTPUT(X_MS2_PIN); - #if PIN_EXISTS(X_MS3) - SET_OUTPUT(X_MS3_PIN); - #endif - #endif - #if HAS_X2_MS_PINS - SET_OUTPUT(X2_MS1_PIN); SET_OUTPUT(X2_MS2_PIN); - #if PIN_EXISTS(X2_MS3) - SET_OUTPUT(X2_MS3_PIN); - #endif - #endif - #if HAS_Y_MS_PINS - SET_OUTPUT(Y_MS1_PIN); SET_OUTPUT(Y_MS2_PIN); - #if PIN_EXISTS(Y_MS3) - SET_OUTPUT(Y_MS3_PIN); - #endif - #endif - #if HAS_Y2_MS_PINS - SET_OUTPUT(Y2_MS1_PIN); SET_OUTPUT(Y2_MS2_PIN); - #if PIN_EXISTS(Y2_MS3) - SET_OUTPUT(Y2_MS3_PIN); - #endif - #endif - #if HAS_Z_MS_PINS - SET_OUTPUT(Z_MS1_PIN); SET_OUTPUT(Z_MS2_PIN); - #if PIN_EXISTS(Z_MS3) - SET_OUTPUT(Z_MS3_PIN); - #endif - #endif - #if HAS_Z2_MS_PINS - SET_OUTPUT(Z2_MS1_PIN); SET_OUTPUT(Z2_MS2_PIN); - #if PIN_EXISTS(Z2_MS3) - SET_OUTPUT(Z2_MS3_PIN); - #endif - #endif - #if HAS_Z3_MS_PINS - SET_OUTPUT(Z3_MS1_PIN); SET_OUTPUT(Z3_MS2_PIN); - #if PIN_EXISTS(Z3_MS3) - SET_OUTPUT(Z3_MS3_PIN); - #endif - #endif - #if HAS_Z4_MS_PINS - SET_OUTPUT(Z4_MS1_PIN); SET_OUTPUT(Z4_MS2_PIN); - #if PIN_EXISTS(Z4_MS3) - SET_OUTPUT(Z4_MS3_PIN); - #endif - #endif - #if HAS_I_MS_PINS - SET_OUTPUT(I_MS1_PIN); SET_OUTPUT(I_MS2_PIN); - #if PIN_EXISTS(I_MS3) - SET_OUTPUT(I_MS3_PIN); - #endif - #endif - #if HAS_J_MS_PINS - SET_OUTPUT(J_MS1_PIN); SET_OUTPUT(J_MS2_PIN); - #if PIN_EXISTS(J_MS3) - SET_OUTPUT(J_MS3_PIN); - #endif - #endif - #if HAS_K_MS_PINS - SET_OUTPUT(K_MS1_PIN); SET_OUTPUT(K_MS2_PIN); - #if PIN_EXISTS(K_MS3) - SET_OUTPUT(K_MS3_PIN); - #endif - #endif - #if HAS_U_MS_PINS - SET_OUTPUT(U_MS1_PIN); SET_OUTPUT(U_MS2_PIN); - #if PIN_EXISTS(U_MS3) - SET_OUTPUT(U_MS3_PIN); - #endif - #endif - #if HAS_V_MS_PINS - SET_OUTPUT(V_MS1_PIN); SET_OUTPUT(V_MS2_PIN); - #if PIN_EXISTS(V_MS3) - SET_OUTPUT(V_MS3_PIN); - #endif - #endif - #if HAS_W_MS_PINS - SET_OUTPUT(W_MS1_PIN); SET_OUTPUT(W_MS2_PIN); - #if PIN_EXISTS(W_MS3) - SET_OUTPUT(W_MS3_PIN); - #endif - #endif - #if HAS_E0_MS_PINS - SET_OUTPUT(E0_MS1_PIN); SET_OUTPUT(E0_MS2_PIN); - #if PIN_EXISTS(E0_MS3) - SET_OUTPUT(E0_MS3_PIN); - #endif - #endif - #if HAS_E1_MS_PINS - SET_OUTPUT(E1_MS1_PIN); SET_OUTPUT(E1_MS2_PIN); - #if PIN_EXISTS(E1_MS3) - SET_OUTPUT(E1_MS3_PIN); - #endif - #endif - #if HAS_E2_MS_PINS - SET_OUTPUT(E2_MS1_PIN); SET_OUTPUT(E2_MS2_PIN); - #if PIN_EXISTS(E2_MS3) - SET_OUTPUT(E2_MS3_PIN); - #endif - #endif - #if HAS_E3_MS_PINS - SET_OUTPUT(E3_MS1_PIN); SET_OUTPUT(E3_MS2_PIN); - #if PIN_EXISTS(E3_MS3) - SET_OUTPUT(E3_MS3_PIN); - #endif - #endif - #if HAS_E4_MS_PINS - SET_OUTPUT(E4_MS1_PIN); SET_OUTPUT(E4_MS2_PIN); - #if PIN_EXISTS(E4_MS3) - SET_OUTPUT(E4_MS3_PIN); - #endif - #endif - #if HAS_E5_MS_PINS - SET_OUTPUT(E5_MS1_PIN); SET_OUTPUT(E5_MS2_PIN); - #if PIN_EXISTS(E5_MS3) - SET_OUTPUT(E5_MS3_PIN); - #endif - #endif - #if HAS_E6_MS_PINS - SET_OUTPUT(E6_MS1_PIN); SET_OUTPUT(E6_MS2_PIN); - #if PIN_EXISTS(E6_MS3) - SET_OUTPUT(E6_MS3_PIN); - #endif - #endif - #if HAS_E7_MS_PINS - SET_OUTPUT(E7_MS1_PIN); SET_OUTPUT(E7_MS2_PIN); - #if PIN_EXISTS(E7_MS3) - SET_OUTPUT(E7_MS3_PIN); - #endif - #endif - - static const uint8_t microstep_modes[] = MICROSTEP_MODES; - for (uint16_t i = 0; i < COUNT(microstep_modes); i++) - microstep_mode(i, microstep_modes[i]); - } - - void Stepper::microstep_ms(const uint8_t driver, const int8_t ms1, const int8_t ms2, const int8_t ms3) { - if (ms1 >= 0) switch (driver) { - #if HAS_X_MS_PINS || HAS_X2_MS_PINS - case X_AXIS: - #if HAS_X_MS_PINS - WRITE(X_MS1_PIN, ms1); - #endif - #if HAS_X2_MS_PINS - WRITE(X2_MS1_PIN, ms1); - #endif - break; - #endif - #if HAS_Y_MS_PINS || HAS_Y2_MS_PINS - case Y_AXIS: - #if HAS_Y_MS_PINS - WRITE(Y_MS1_PIN, ms1); - #endif - #if HAS_Y2_MS_PINS - WRITE(Y2_MS1_PIN, ms1); - #endif - break; - #endif - #if HAS_SOME_Z_MS_PINS - case Z_AXIS: - #if HAS_Z_MS_PINS - WRITE(Z_MS1_PIN, ms1); - #endif - #if HAS_Z2_MS_PINS - WRITE(Z2_MS1_PIN, ms1); - #endif - #if HAS_Z3_MS_PINS - WRITE(Z3_MS1_PIN, ms1); - #endif - #if HAS_Z4_MS_PINS - WRITE(Z4_MS1_PIN, ms1); - #endif - break; - #endif - #if HAS_I_MS_PINS - case I_AXIS: WRITE(I_MS1_PIN, ms1); break; - #endif - #if HAS_J_MS_PINS - case J_AXIS: WRITE(J_MS1_PIN, ms1); break; - #endif - #if HAS_K_MS_PINS - case K_AXIS: WRITE(K_MS1_PIN, ms1); break; - #endif - #if HAS_U_MS_PINS - case U_AXIS: WRITE(U_MS1_PIN, ms1); break; - #endif - #if HAS_V_MS_PINS - case V_AXIS: WRITE(V_MS1_PIN, ms1); break; - #endif - #if HAS_W_MS_PINS - case W_AXIS: WRITE(W_MS1_PIN, ms1); break; - #endif - #if HAS_E0_MS_PINS - case E_AXIS: WRITE(E0_MS1_PIN, ms1); break; - #endif - #if HAS_E1_MS_PINS - case (E_AXIS + 1): WRITE(E1_MS1_PIN, ms1); break; - #endif - #if HAS_E2_MS_PINS - case (E_AXIS + 2): WRITE(E2_MS1_PIN, ms1); break; - #endif - #if HAS_E3_MS_PINS - case (E_AXIS + 3): WRITE(E3_MS1_PIN, ms1); break; - #endif - #if HAS_E4_MS_PINS - case (E_AXIS + 4): WRITE(E4_MS1_PIN, ms1); break; - #endif - #if HAS_E5_MS_PINS - case (E_AXIS + 5): WRITE(E5_MS1_PIN, ms1); break; - #endif - #if HAS_E6_MS_PINS - case (E_AXIS + 6): WRITE(E6_MS1_PIN, ms1); break; - #endif - #if HAS_E7_MS_PINS - case (E_AXIS + 7): WRITE(E7_MS1_PIN, ms1); break; - #endif - } - if (ms2 >= 0) switch (driver) { - #if HAS_X_MS_PINS || HAS_X2_MS_PINS - case X_AXIS: - #if HAS_X_MS_PINS - WRITE(X_MS2_PIN, ms2); - #endif - #if HAS_X2_MS_PINS - WRITE(X2_MS2_PIN, ms2); - #endif - break; - #endif - #if HAS_Y_MS_PINS || HAS_Y2_MS_PINS - case Y_AXIS: - #if HAS_Y_MS_PINS - WRITE(Y_MS2_PIN, ms2); - #endif - #if HAS_Y2_MS_PINS - WRITE(Y2_MS2_PIN, ms2); - #endif - break; - #endif - #if HAS_SOME_Z_MS_PINS - case Z_AXIS: - #if HAS_Z_MS_PINS - WRITE(Z_MS2_PIN, ms2); - #endif - #if HAS_Z2_MS_PINS - WRITE(Z2_MS2_PIN, ms2); - #endif - #if HAS_Z3_MS_PINS - WRITE(Z3_MS2_PIN, ms2); - #endif - #if HAS_Z4_MS_PINS - WRITE(Z4_MS2_PIN, ms2); - #endif - break; - #endif - #if HAS_I_MS_PINS - case I_AXIS: WRITE(I_MS2_PIN, ms2); break; - #endif - #if HAS_J_MS_PINS - case J_AXIS: WRITE(J_MS2_PIN, ms2); break; - #endif - #if HAS_K_MS_PINS - case K_AXIS: WRITE(K_MS2_PIN, ms2); break; - #endif - #if HAS_U_MS_PINS - case U_AXIS: WRITE(U_MS2_PIN, ms2); break; - #endif - #if HAS_V_MS_PINS - case V_AXIS: WRITE(V_MS2_PIN, ms2); break; - #endif - #if HAS_W_MS_PINS - case W_AXIS: WRITE(W_MS2_PIN, ms2); break; - #endif - #if HAS_E0_MS_PINS - case E_AXIS: WRITE(E0_MS2_PIN, ms2); break; - #endif - #if HAS_E1_MS_PINS - case (E_AXIS + 1): WRITE(E1_MS2_PIN, ms2); break; - #endif - #if HAS_E2_MS_PINS - case (E_AXIS + 2): WRITE(E2_MS2_PIN, ms2); break; - #endif - #if HAS_E3_MS_PINS - case (E_AXIS + 3): WRITE(E3_MS2_PIN, ms2); break; - #endif - #if HAS_E4_MS_PINS - case (E_AXIS + 4): WRITE(E4_MS2_PIN, ms2); break; - #endif - #if HAS_E5_MS_PINS - case (E_AXIS + 5): WRITE(E5_MS2_PIN, ms2); break; - #endif - #if HAS_E6_MS_PINS - case (E_AXIS + 6): WRITE(E6_MS2_PIN, ms2); break; - #endif - #if HAS_E7_MS_PINS - case (E_AXIS + 7): WRITE(E7_MS2_PIN, ms2); break; - #endif - } - if (ms3 >= 0) switch (driver) { - #if HAS_X_MS_PINS || HAS_X2_MS_PINS - case X_AXIS: - #if HAS_X_MS_PINS && PIN_EXISTS(X_MS3) - WRITE(X_MS3_PIN, ms3); - #endif - #if HAS_X2_MS_PINS && PIN_EXISTS(X2_MS3) - WRITE(X2_MS3_PIN, ms3); - #endif - break; - #endif - #if HAS_Y_MS_PINS || HAS_Y2_MS_PINS - case Y_AXIS: - #if HAS_Y_MS_PINS && PIN_EXISTS(Y_MS3) - WRITE(Y_MS3_PIN, ms3); - #endif - #if HAS_Y2_MS_PINS && PIN_EXISTS(Y2_MS3) - WRITE(Y2_MS3_PIN, ms3); - #endif - break; - #endif - #if HAS_SOME_Z_MS_PINS - case Z_AXIS: - #if HAS_Z_MS_PINS && PIN_EXISTS(Z_MS3) - WRITE(Z_MS3_PIN, ms3); - #endif - #if HAS_Z2_MS_PINS && PIN_EXISTS(Z2_MS3) - WRITE(Z2_MS3_PIN, ms3); - #endif - #if HAS_Z3_MS_PINS && PIN_EXISTS(Z3_MS3) - WRITE(Z3_MS3_PIN, ms3); - #endif - #if HAS_Z4_MS_PINS && PIN_EXISTS(Z4_MS3) - WRITE(Z4_MS3_PIN, ms3); - #endif - break; - #endif - #if HAS_I_MS_PINS && PIN_EXISTS(I_MS3) - case I_AXIS: WRITE(I_MS3_PIN, ms3); break; - #endif - #if HAS_J_MS_PINS && PIN_EXISTS(J_MS3) - case J_AXIS: WRITE(J_MS3_PIN, ms3); break; - #endif - #if HAS_K_MS_PINS && PIN_EXISTS(K_MS3) - case K_AXIS: WRITE(K_MS3_PIN, ms3); break; - #endif - #if HAS_U_MS_PINS && PIN_EXISTS(U_MS3) - case U_AXIS: WRITE(U_MS3_PIN, ms3); break; - #endif - #if HAS_V_MS_PINS && PIN_EXISTS(V_MS3) - case V_AXIS: WRITE(V_MS3_PIN, ms3); break; - #endif - #if HAS_W_MS_PINS && PIN_EXISTS(W_MS3) - case W_AXIS: WRITE(W_MS3_PIN, ms3); break; - #endif - #if HAS_E0_MS_PINS && PIN_EXISTS(E0_MS3) - case E_AXIS: WRITE(E0_MS3_PIN, ms3); break; - #endif - #if HAS_E1_MS_PINS && PIN_EXISTS(E1_MS3) - case (E_AXIS + 1): WRITE(E1_MS3_PIN, ms3); break; - #endif - #if HAS_E2_MS_PINS && PIN_EXISTS(E2_MS3) - case (E_AXIS + 2): WRITE(E2_MS3_PIN, ms3); break; - #endif - #if HAS_E3_MS_PINS && PIN_EXISTS(E3_MS3) - case (E_AXIS + 3): WRITE(E3_MS3_PIN, ms3); break; - #endif - #if HAS_E4_MS_PINS && PIN_EXISTS(E4_MS3) - case (E_AXIS + 4): WRITE(E4_MS3_PIN, ms3); break; - #endif - #if HAS_E5_MS_PINS && PIN_EXISTS(E5_MS3) - case (E_AXIS + 5): WRITE(E5_MS3_PIN, ms3); break; - #endif - #if HAS_E6_MS_PINS && PIN_EXISTS(E6_MS3) - case (E_AXIS + 6): WRITE(E6_MS3_PIN, ms3); break; - #endif - #if HAS_E7_MS_PINS && PIN_EXISTS(E7_MS3) - case (E_AXIS + 7): WRITE(E7_MS3_PIN, ms3); break; - #endif - } - } - - // MS1 MS2 MS3 Stepper Driver Microstepping mode table - #ifndef MICROSTEP1 - #define MICROSTEP1 LOW,LOW,LOW - #endif - #if ENABLED(HEROIC_STEPPER_DRIVERS) - #ifndef MICROSTEP128 - #define MICROSTEP128 LOW,HIGH,LOW - #endif - #else - #ifndef MICROSTEP2 - #define MICROSTEP2 HIGH,LOW,LOW - #endif - #ifndef MICROSTEP4 - #define MICROSTEP4 LOW,HIGH,LOW - #endif - #endif - #ifndef MICROSTEP8 - #define MICROSTEP8 HIGH,HIGH,LOW - #endif - #ifndef MICROSTEP16 - #define MICROSTEP16 HIGH,HIGH,LOW - #endif - - void Stepper::microstep_mode(const uint8_t driver, const uint8_t stepping_mode) { - switch (stepping_mode) { - #ifdef MICROSTEP1 - case 1: microstep_ms(driver, MICROSTEP1); break; - #endif - #ifdef MICROSTEP2 - case 2: microstep_ms(driver, MICROSTEP2); break; - #endif - #ifdef MICROSTEP4 - case 4: microstep_ms(driver, MICROSTEP4); break; - #endif - #ifdef MICROSTEP8 - case 8: microstep_ms(driver, MICROSTEP8); break; - #endif - #ifdef MICROSTEP16 - case 16: microstep_ms(driver, MICROSTEP16); break; - #endif - #ifdef MICROSTEP32 - case 32: microstep_ms(driver, MICROSTEP32); break; - #endif - #ifdef MICROSTEP64 - case 64: microstep_ms(driver, MICROSTEP64); break; - #endif - #ifdef MICROSTEP128 - case 128: microstep_ms(driver, MICROSTEP128); break; - #endif - - default: SERIAL_ERROR_MSG("Microsteps unavailable"); break; - } - } - - void Stepper::microstep_readings() { - #define PIN_CHAR(P) SERIAL_CHAR('0' + READ(P##_PIN)) - #define MS_LINE(A) do{ SERIAL_ECHOPGM(" " STRINGIFY(A) ":"); PIN_CHAR(A##_MS1); PIN_CHAR(A##_MS2); }while(0) - SERIAL_ECHOPGM("MS1|2|3 Pins"); - #if HAS_X_MS_PINS - MS_LINE(X); - #if PIN_EXISTS(X_MS3) - PIN_CHAR(X_MS3); - #endif - #endif - #if HAS_Y_MS_PINS - MS_LINE(Y); - #if PIN_EXISTS(Y_MS3) - PIN_CHAR(Y_MS3); - #endif - #endif - #if HAS_Z_MS_PINS - MS_LINE(Z); - #if PIN_EXISTS(Z_MS3) - PIN_CHAR(Z_MS3); - #endif - #endif - #if HAS_I_MS_PINS - MS_LINE(I); - #if PIN_EXISTS(I_MS3) - PIN_CHAR(I_MS3); - #endif - #endif - #if HAS_J_MS_PINS - MS_LINE(J); - #if PIN_EXISTS(J_MS3) - PIN_CHAR(J_MS3); - #endif - #endif - #if HAS_K_MS_PINS - MS_LINE(K); - #if PIN_EXISTS(K_MS3) - PIN_CHAR(K_MS3); - #endif - #endif - #if HAS_U_MS_PINS - MS_LINE(U); - #if PIN_EXISTS(U_MS3) - PIN_CHAR(U_MS3); - #endif - #endif - #if HAS_V_MS_PINS - MS_LINE(V); - #if PIN_EXISTS(V_MS3) - PIN_CHAR(V_MS3); - #endif - #endif - #if HAS_W_MS_PINS - MS_LINE(W); - #if PIN_EXISTS(W_MS3) - PIN_CHAR(W_MS3); - #endif - #endif - #if HAS_E0_MS_PINS - MS_LINE(E0); - #if PIN_EXISTS(E0_MS3) - PIN_CHAR(E0_MS3); - #endif - #endif - #if HAS_E1_MS_PINS - MS_LINE(E1); - #if PIN_EXISTS(E1_MS3) - PIN_CHAR(E1_MS3); - #endif - #endif - #if HAS_E2_MS_PINS - MS_LINE(E2); - #if PIN_EXISTS(E2_MS3) - PIN_CHAR(E2_MS3); - #endif - #endif - #if HAS_E3_MS_PINS - MS_LINE(E3); - #if PIN_EXISTS(E3_MS3) - PIN_CHAR(E3_MS3); - #endif - #endif - #if HAS_E4_MS_PINS - MS_LINE(E4); - #if PIN_EXISTS(E4_MS3) - PIN_CHAR(E4_MS3); - #endif - #endif - #if HAS_E5_MS_PINS - MS_LINE(E5); - #if PIN_EXISTS(E5_MS3) - PIN_CHAR(E5_MS3); - #endif - #endif - #if HAS_E6_MS_PINS - MS_LINE(E6); - #if PIN_EXISTS(E6_MS3) - PIN_CHAR(E6_MS3); - #endif - #endif - #if HAS_E7_MS_PINS - MS_LINE(E7); - #if PIN_EXISTS(E7_MS3) - PIN_CHAR(E7_MS3); - #endif - #endif - SERIAL_EOL(); - } - -#endif // HAS_MICROSTEPS diff --git a/Marlin/src/module/stepper/control.cpp b/Marlin/src/module/stepper/control.cpp new file mode 100644 index 0000000000..0d523c8ed5 --- /dev/null +++ b/Marlin/src/module/stepper/control.cpp @@ -0,0 +1,764 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * stepper/control.cpp + * Control for Stepper Motor Current and Driver Micro-stepping + * (other than Trinamic UART / SPI). + */ + +#include "../stepper.h" + +#if MB(PRINTRBOARD_G2) + #include HAL_PATH(../.., fastio/G2_PWM.h) +#endif + +/** + * Software-controlled Stepper Motor Current + */ + +#if HAS_MOTOR_CURRENT_SPI + + // From Arduino DigitalPotControl example + void Stepper::set_digipot_value_spi(const int16_t address, const int16_t value) { + WRITE(DIGIPOTSS_PIN, LOW); // Take the SS pin low to select the chip + SPI.transfer(address); // Send the address and value via SPI + SPI.transfer(value); + WRITE(DIGIPOTSS_PIN, HIGH); // Take the SS pin high to de-select the chip + //delay(10); + } + +#endif // HAS_MOTOR_CURRENT_SPI + +#if HAS_MOTOR_CURRENT_PWM + + void Stepper::refresh_motor_power() { + if (!initialized) return; + for (uint8_t i = 0; i < COUNT(motor_current_setting); ++i) { + switch (i) { + #if ANY_PIN(MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K, MOTOR_CURRENT_PWM_U, MOTOR_CURRENT_PWM_V, MOTOR_CURRENT_PWM_W) + case 0: + #endif + #if HAS_MOTOR_CURRENT_PWM_Z + case 1: + #endif + #if HAS_MOTOR_CURRENT_PWM_E + case 2: + #endif + set_digipot_current(i, motor_current_setting[i]); + default: break; + } + } + } + +#endif // HAS_MOTOR_CURRENT_PWM + +/** + * PWM-controlled Stepper Motor Current + */ + +#if !MB(PRINTRBOARD_G2) && (HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM) + + void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { + if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1)) + motor_current_setting[driver] = current; // update motor_current_setting + + if (!initialized) return; + + #if HAS_MOTOR_CURRENT_SPI + + //SERIAL_ECHOLNPGM("Digipotss current ", current); + + const uint8_t digipot_ch[] = DIGIPOT_CHANNELS; + set_digipot_value_spi(digipot_ch[driver], current); + + #elif HAS_MOTOR_CURRENT_PWM + + #define _WRITE_CURRENT_PWM(P) hal.set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) + switch (driver) { + case 0: + #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) + _WRITE_CURRENT_PWM(X); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) + _WRITE_CURRENT_PWM(Y); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) + _WRITE_CURRENT_PWM(XY); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_I) + _WRITE_CURRENT_PWM(I); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_J) + _WRITE_CURRENT_PWM(J); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_K) + _WRITE_CURRENT_PWM(K); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_U) + _WRITE_CURRENT_PWM(U); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_V) + _WRITE_CURRENT_PWM(V); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_W) + _WRITE_CURRENT_PWM(W); + #endif + break; + case 1: + #if HAS_MOTOR_CURRENT_PWM_Z + _WRITE_CURRENT_PWM(Z); + #endif + break; + case 2: + #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + _WRITE_CURRENT_PWM(E); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) + _WRITE_CURRENT_PWM(E0); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) + _WRITE_CURRENT_PWM(E1); + #endif + break; + } + #endif + } + + void Stepper::digipot_init() { + + #if HAS_MOTOR_CURRENT_SPI + + SPI.begin(); + SET_OUTPUT(DIGIPOTSS_PIN); + + for (uint8_t i = 0; i < COUNT(motor_current_setting); ++i) + set_digipot_current(i, motor_current_setting[i]); + + #elif HAS_MOTOR_CURRENT_PWM + + #ifdef __SAM3X8E__ + #define _RESET_CURRENT_PWM_FREQ(P) NOOP + #else + #define _RESET_CURRENT_PWM_FREQ(P) hal.set_pwm_frequency(pin_t(P), MOTOR_CURRENT_PWM_FREQUENCY) + #endif + #define INIT_CURRENT_PWM(P) do{ SET_PWM(MOTOR_CURRENT_PWM_## P ##_PIN); _RESET_CURRENT_PWM_FREQ(MOTOR_CURRENT_PWM_## P ##_PIN); }while(0) + + #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) + INIT_CURRENT_PWM(X); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) + INIT_CURRENT_PWM(Y); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) + INIT_CURRENT_PWM(XY); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_I) + INIT_CURRENT_PWM(I); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_J) + INIT_CURRENT_PWM(J); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_K) + INIT_CURRENT_PWM(K); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_U) + INIT_CURRENT_PWM(U); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_V) + INIT_CURRENT_PWM(V); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_W) + INIT_CURRENT_PWM(W); + #endif + #if HAS_MOTOR_CURRENT_PWM_Z + INIT_CURRENT_PWM(Z); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + INIT_CURRENT_PWM(E); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) + INIT_CURRENT_PWM(E0); + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) + INIT_CURRENT_PWM(E1); + #endif + + refresh_motor_power(); + + #endif + } + +#endif + +/** + * Software-controlled Microstepping with digital pins + */ + +#if HAS_MICROSTEPS + + void Stepper::microstep_init() { + #if HAS_X_MS_PINS + SET_OUTPUT(X_MS1_PIN); SET_OUTPUT(X_MS2_PIN); + #if PIN_EXISTS(X_MS3) + SET_OUTPUT(X_MS3_PIN); + #endif + #endif + #if HAS_X2_MS_PINS + SET_OUTPUT(X2_MS1_PIN); SET_OUTPUT(X2_MS2_PIN); + #if PIN_EXISTS(X2_MS3) + SET_OUTPUT(X2_MS3_PIN); + #endif + #endif + #if HAS_Y_MS_PINS + SET_OUTPUT(Y_MS1_PIN); SET_OUTPUT(Y_MS2_PIN); + #if PIN_EXISTS(Y_MS3) + SET_OUTPUT(Y_MS3_PIN); + #endif + #endif + #if HAS_Y2_MS_PINS + SET_OUTPUT(Y2_MS1_PIN); SET_OUTPUT(Y2_MS2_PIN); + #if PIN_EXISTS(Y2_MS3) + SET_OUTPUT(Y2_MS3_PIN); + #endif + #endif + #if HAS_Z_MS_PINS + SET_OUTPUT(Z_MS1_PIN); SET_OUTPUT(Z_MS2_PIN); + #if PIN_EXISTS(Z_MS3) + SET_OUTPUT(Z_MS3_PIN); + #endif + #endif + #if HAS_Z2_MS_PINS + SET_OUTPUT(Z2_MS1_PIN); SET_OUTPUT(Z2_MS2_PIN); + #if PIN_EXISTS(Z2_MS3) + SET_OUTPUT(Z2_MS3_PIN); + #endif + #endif + #if HAS_Z3_MS_PINS + SET_OUTPUT(Z3_MS1_PIN); SET_OUTPUT(Z3_MS2_PIN); + #if PIN_EXISTS(Z3_MS3) + SET_OUTPUT(Z3_MS3_PIN); + #endif + #endif + #if HAS_Z4_MS_PINS + SET_OUTPUT(Z4_MS1_PIN); SET_OUTPUT(Z4_MS2_PIN); + #if PIN_EXISTS(Z4_MS3) + SET_OUTPUT(Z4_MS3_PIN); + #endif + #endif + #if HAS_I_MS_PINS + SET_OUTPUT(I_MS1_PIN); SET_OUTPUT(I_MS2_PIN); + #if PIN_EXISTS(I_MS3) + SET_OUTPUT(I_MS3_PIN); + #endif + #endif + #if HAS_J_MS_PINS + SET_OUTPUT(J_MS1_PIN); SET_OUTPUT(J_MS2_PIN); + #if PIN_EXISTS(J_MS3) + SET_OUTPUT(J_MS3_PIN); + #endif + #endif + #if HAS_K_MS_PINS + SET_OUTPUT(K_MS1_PIN); SET_OUTPUT(K_MS2_PIN); + #if PIN_EXISTS(K_MS3) + SET_OUTPUT(K_MS3_PIN); + #endif + #endif + #if HAS_U_MS_PINS + SET_OUTPUT(U_MS1_PIN); SET_OUTPUT(U_MS2_PIN); + #if PIN_EXISTS(U_MS3) + SET_OUTPUT(U_MS3_PIN); + #endif + #endif + #if HAS_V_MS_PINS + SET_OUTPUT(V_MS1_PIN); SET_OUTPUT(V_MS2_PIN); + #if PIN_EXISTS(V_MS3) + SET_OUTPUT(V_MS3_PIN); + #endif + #endif + #if HAS_W_MS_PINS + SET_OUTPUT(W_MS1_PIN); SET_OUTPUT(W_MS2_PIN); + #if PIN_EXISTS(W_MS3) + SET_OUTPUT(W_MS3_PIN); + #endif + #endif + #if HAS_E0_MS_PINS + SET_OUTPUT(E0_MS1_PIN); SET_OUTPUT(E0_MS2_PIN); + #if PIN_EXISTS(E0_MS3) + SET_OUTPUT(E0_MS3_PIN); + #endif + #endif + #if HAS_E1_MS_PINS + SET_OUTPUT(E1_MS1_PIN); SET_OUTPUT(E1_MS2_PIN); + #if PIN_EXISTS(E1_MS3) + SET_OUTPUT(E1_MS3_PIN); + #endif + #endif + #if HAS_E2_MS_PINS + SET_OUTPUT(E2_MS1_PIN); SET_OUTPUT(E2_MS2_PIN); + #if PIN_EXISTS(E2_MS3) + SET_OUTPUT(E2_MS3_PIN); + #endif + #endif + #if HAS_E3_MS_PINS + SET_OUTPUT(E3_MS1_PIN); SET_OUTPUT(E3_MS2_PIN); + #if PIN_EXISTS(E3_MS3) + SET_OUTPUT(E3_MS3_PIN); + #endif + #endif + #if HAS_E4_MS_PINS + SET_OUTPUT(E4_MS1_PIN); SET_OUTPUT(E4_MS2_PIN); + #if PIN_EXISTS(E4_MS3) + SET_OUTPUT(E4_MS3_PIN); + #endif + #endif + #if HAS_E5_MS_PINS + SET_OUTPUT(E5_MS1_PIN); SET_OUTPUT(E5_MS2_PIN); + #if PIN_EXISTS(E5_MS3) + SET_OUTPUT(E5_MS3_PIN); + #endif + #endif + #if HAS_E6_MS_PINS + SET_OUTPUT(E6_MS1_PIN); SET_OUTPUT(E6_MS2_PIN); + #if PIN_EXISTS(E6_MS3) + SET_OUTPUT(E6_MS3_PIN); + #endif + #endif + #if HAS_E7_MS_PINS + SET_OUTPUT(E7_MS1_PIN); SET_OUTPUT(E7_MS2_PIN); + #if PIN_EXISTS(E7_MS3) + SET_OUTPUT(E7_MS3_PIN); + #endif + #endif + + static const uint8_t microstep_modes[] = MICROSTEP_MODES; + for (uint16_t i = 0; i < COUNT(microstep_modes); i++) + microstep_mode(i, microstep_modes[i]); + } + + void Stepper::microstep_ms(const uint8_t driver, const int8_t ms1, const int8_t ms2, const int8_t ms3) { + if (ms1 >= 0) switch (driver) { + #if HAS_X_MS_PINS || HAS_X2_MS_PINS + case X_AXIS: + #if HAS_X_MS_PINS + WRITE(X_MS1_PIN, ms1); + #endif + #if HAS_X2_MS_PINS + WRITE(X2_MS1_PIN, ms1); + #endif + break; + #endif + #if HAS_Y_MS_PINS || HAS_Y2_MS_PINS + case Y_AXIS: + #if HAS_Y_MS_PINS + WRITE(Y_MS1_PIN, ms1); + #endif + #if HAS_Y2_MS_PINS + WRITE(Y2_MS1_PIN, ms1); + #endif + break; + #endif + #if HAS_SOME_Z_MS_PINS + case Z_AXIS: + #if HAS_Z_MS_PINS + WRITE(Z_MS1_PIN, ms1); + #endif + #if HAS_Z2_MS_PINS + WRITE(Z2_MS1_PIN, ms1); + #endif + #if HAS_Z3_MS_PINS + WRITE(Z3_MS1_PIN, ms1); + #endif + #if HAS_Z4_MS_PINS + WRITE(Z4_MS1_PIN, ms1); + #endif + break; + #endif + #if HAS_I_MS_PINS + case I_AXIS: WRITE(I_MS1_PIN, ms1); break; + #endif + #if HAS_J_MS_PINS + case J_AXIS: WRITE(J_MS1_PIN, ms1); break; + #endif + #if HAS_K_MS_PINS + case K_AXIS: WRITE(K_MS1_PIN, ms1); break; + #endif + #if HAS_U_MS_PINS + case U_AXIS: WRITE(U_MS1_PIN, ms1); break; + #endif + #if HAS_V_MS_PINS + case V_AXIS: WRITE(V_MS1_PIN, ms1); break; + #endif + #if HAS_W_MS_PINS + case W_AXIS: WRITE(W_MS1_PIN, ms1); break; + #endif + #if HAS_E0_MS_PINS + case E_AXIS: WRITE(E0_MS1_PIN, ms1); break; + #endif + #if HAS_E1_MS_PINS + case (E_AXIS + 1): WRITE(E1_MS1_PIN, ms1); break; + #endif + #if HAS_E2_MS_PINS + case (E_AXIS + 2): WRITE(E2_MS1_PIN, ms1); break; + #endif + #if HAS_E3_MS_PINS + case (E_AXIS + 3): WRITE(E3_MS1_PIN, ms1); break; + #endif + #if HAS_E4_MS_PINS + case (E_AXIS + 4): WRITE(E4_MS1_PIN, ms1); break; + #endif + #if HAS_E5_MS_PINS + case (E_AXIS + 5): WRITE(E5_MS1_PIN, ms1); break; + #endif + #if HAS_E6_MS_PINS + case (E_AXIS + 6): WRITE(E6_MS1_PIN, ms1); break; + #endif + #if HAS_E7_MS_PINS + case (E_AXIS + 7): WRITE(E7_MS1_PIN, ms1); break; + #endif + } + if (ms2 >= 0) switch (driver) { + #if HAS_X_MS_PINS || HAS_X2_MS_PINS + case X_AXIS: + #if HAS_X_MS_PINS + WRITE(X_MS2_PIN, ms2); + #endif + #if HAS_X2_MS_PINS + WRITE(X2_MS2_PIN, ms2); + #endif + break; + #endif + #if HAS_Y_MS_PINS || HAS_Y2_MS_PINS + case Y_AXIS: + #if HAS_Y_MS_PINS + WRITE(Y_MS2_PIN, ms2); + #endif + #if HAS_Y2_MS_PINS + WRITE(Y2_MS2_PIN, ms2); + #endif + break; + #endif + #if HAS_SOME_Z_MS_PINS + case Z_AXIS: + #if HAS_Z_MS_PINS + WRITE(Z_MS2_PIN, ms2); + #endif + #if HAS_Z2_MS_PINS + WRITE(Z2_MS2_PIN, ms2); + #endif + #if HAS_Z3_MS_PINS + WRITE(Z3_MS2_PIN, ms2); + #endif + #if HAS_Z4_MS_PINS + WRITE(Z4_MS2_PIN, ms2); + #endif + break; + #endif + #if HAS_I_MS_PINS + case I_AXIS: WRITE(I_MS2_PIN, ms2); break; + #endif + #if HAS_J_MS_PINS + case J_AXIS: WRITE(J_MS2_PIN, ms2); break; + #endif + #if HAS_K_MS_PINS + case K_AXIS: WRITE(K_MS2_PIN, ms2); break; + #endif + #if HAS_U_MS_PINS + case U_AXIS: WRITE(U_MS2_PIN, ms2); break; + #endif + #if HAS_V_MS_PINS + case V_AXIS: WRITE(V_MS2_PIN, ms2); break; + #endif + #if HAS_W_MS_PINS + case W_AXIS: WRITE(W_MS2_PIN, ms2); break; + #endif + #if HAS_E0_MS_PINS + case E_AXIS: WRITE(E0_MS2_PIN, ms2); break; + #endif + #if HAS_E1_MS_PINS + case (E_AXIS + 1): WRITE(E1_MS2_PIN, ms2); break; + #endif + #if HAS_E2_MS_PINS + case (E_AXIS + 2): WRITE(E2_MS2_PIN, ms2); break; + #endif + #if HAS_E3_MS_PINS + case (E_AXIS + 3): WRITE(E3_MS2_PIN, ms2); break; + #endif + #if HAS_E4_MS_PINS + case (E_AXIS + 4): WRITE(E4_MS2_PIN, ms2); break; + #endif + #if HAS_E5_MS_PINS + case (E_AXIS + 5): WRITE(E5_MS2_PIN, ms2); break; + #endif + #if HAS_E6_MS_PINS + case (E_AXIS + 6): WRITE(E6_MS2_PIN, ms2); break; + #endif + #if HAS_E7_MS_PINS + case (E_AXIS + 7): WRITE(E7_MS2_PIN, ms2); break; + #endif + } + if (ms3 >= 0) switch (driver) { + #if HAS_X_MS_PINS || HAS_X2_MS_PINS + case X_AXIS: + #if HAS_X_MS_PINS && PIN_EXISTS(X_MS3) + WRITE(X_MS3_PIN, ms3); + #endif + #if HAS_X2_MS_PINS && PIN_EXISTS(X2_MS3) + WRITE(X2_MS3_PIN, ms3); + #endif + break; + #endif + #if HAS_Y_MS_PINS || HAS_Y2_MS_PINS + case Y_AXIS: + #if HAS_Y_MS_PINS && PIN_EXISTS(Y_MS3) + WRITE(Y_MS3_PIN, ms3); + #endif + #if HAS_Y2_MS_PINS && PIN_EXISTS(Y2_MS3) + WRITE(Y2_MS3_PIN, ms3); + #endif + break; + #endif + #if HAS_SOME_Z_MS_PINS + case Z_AXIS: + #if HAS_Z_MS_PINS && PIN_EXISTS(Z_MS3) + WRITE(Z_MS3_PIN, ms3); + #endif + #if HAS_Z2_MS_PINS && PIN_EXISTS(Z2_MS3) + WRITE(Z2_MS3_PIN, ms3); + #endif + #if HAS_Z3_MS_PINS && PIN_EXISTS(Z3_MS3) + WRITE(Z3_MS3_PIN, ms3); + #endif + #if HAS_Z4_MS_PINS && PIN_EXISTS(Z4_MS3) + WRITE(Z4_MS3_PIN, ms3); + #endif + break; + #endif + #if HAS_I_MS_PINS && PIN_EXISTS(I_MS3) + case I_AXIS: WRITE(I_MS3_PIN, ms3); break; + #endif + #if HAS_J_MS_PINS && PIN_EXISTS(J_MS3) + case J_AXIS: WRITE(J_MS3_PIN, ms3); break; + #endif + #if HAS_K_MS_PINS && PIN_EXISTS(K_MS3) + case K_AXIS: WRITE(K_MS3_PIN, ms3); break; + #endif + #if HAS_U_MS_PINS && PIN_EXISTS(U_MS3) + case U_AXIS: WRITE(U_MS3_PIN, ms3); break; + #endif + #if HAS_V_MS_PINS && PIN_EXISTS(V_MS3) + case V_AXIS: WRITE(V_MS3_PIN, ms3); break; + #endif + #if HAS_W_MS_PINS && PIN_EXISTS(W_MS3) + case W_AXIS: WRITE(W_MS3_PIN, ms3); break; + #endif + #if HAS_E0_MS_PINS && PIN_EXISTS(E0_MS3) + case E_AXIS: WRITE(E0_MS3_PIN, ms3); break; + #endif + #if HAS_E1_MS_PINS && PIN_EXISTS(E1_MS3) + case (E_AXIS + 1): WRITE(E1_MS3_PIN, ms3); break; + #endif + #if HAS_E2_MS_PINS && PIN_EXISTS(E2_MS3) + case (E_AXIS + 2): WRITE(E2_MS3_PIN, ms3); break; + #endif + #if HAS_E3_MS_PINS && PIN_EXISTS(E3_MS3) + case (E_AXIS + 3): WRITE(E3_MS3_PIN, ms3); break; + #endif + #if HAS_E4_MS_PINS && PIN_EXISTS(E4_MS3) + case (E_AXIS + 4): WRITE(E4_MS3_PIN, ms3); break; + #endif + #if HAS_E5_MS_PINS && PIN_EXISTS(E5_MS3) + case (E_AXIS + 5): WRITE(E5_MS3_PIN, ms3); break; + #endif + #if HAS_E6_MS_PINS && PIN_EXISTS(E6_MS3) + case (E_AXIS + 6): WRITE(E6_MS3_PIN, ms3); break; + #endif + #if HAS_E7_MS_PINS && PIN_EXISTS(E7_MS3) + case (E_AXIS + 7): WRITE(E7_MS3_PIN, ms3); break; + #endif + } + } + + // MS1 MS2 MS3 Stepper Driver Microstepping mode table + #ifndef MICROSTEP1 + #define MICROSTEP1 LOW,LOW,LOW + #endif + #if ENABLED(HEROIC_STEPPER_DRIVERS) + #ifndef MICROSTEP128 + #define MICROSTEP128 LOW,HIGH,LOW + #endif + #else + #ifndef MICROSTEP2 + #define MICROSTEP2 HIGH,LOW,LOW + #endif + #ifndef MICROSTEP4 + #define MICROSTEP4 LOW,HIGH,LOW + #endif + #endif + #ifndef MICROSTEP8 + #define MICROSTEP8 HIGH,HIGH,LOW + #endif + #ifndef MICROSTEP16 + #define MICROSTEP16 HIGH,HIGH,LOW + #endif + + void Stepper::microstep_mode(const uint8_t driver, const uint8_t stepping_mode) { + switch (stepping_mode) { + #ifdef MICROSTEP1 + case 1: microstep_ms(driver, MICROSTEP1); break; + #endif + #ifdef MICROSTEP2 + case 2: microstep_ms(driver, MICROSTEP2); break; + #endif + #ifdef MICROSTEP4 + case 4: microstep_ms(driver, MICROSTEP4); break; + #endif + #ifdef MICROSTEP8 + case 8: microstep_ms(driver, MICROSTEP8); break; + #endif + #ifdef MICROSTEP16 + case 16: microstep_ms(driver, MICROSTEP16); break; + #endif + #ifdef MICROSTEP32 + case 32: microstep_ms(driver, MICROSTEP32); break; + #endif + #ifdef MICROSTEP64 + case 64: microstep_ms(driver, MICROSTEP64); break; + #endif + #ifdef MICROSTEP128 + case 128: microstep_ms(driver, MICROSTEP128); break; + #endif + + default: SERIAL_ERROR_MSG("Microsteps unavailable"); break; + } + } + + void Stepper::microstep_readings() { + #define PIN_CHAR(P) SERIAL_CHAR('0' + READ(P##_PIN)) + #define MS_LINE(A) do{ SERIAL_ECHOPGM(" " STRINGIFY(A) ":"); PIN_CHAR(A##_MS1); PIN_CHAR(A##_MS2); }while(0) + SERIAL_ECHOPGM("MS1|2|3 Pins"); + #if HAS_X_MS_PINS + MS_LINE(X); + #if PIN_EXISTS(X_MS3) + PIN_CHAR(X_MS3); + #endif + #endif + #if HAS_Y_MS_PINS + MS_LINE(Y); + #if PIN_EXISTS(Y_MS3) + PIN_CHAR(Y_MS3); + #endif + #endif + #if HAS_Z_MS_PINS + MS_LINE(Z); + #if PIN_EXISTS(Z_MS3) + PIN_CHAR(Z_MS3); + #endif + #endif + #if HAS_I_MS_PINS + MS_LINE(I); + #if PIN_EXISTS(I_MS3) + PIN_CHAR(I_MS3); + #endif + #endif + #if HAS_J_MS_PINS + MS_LINE(J); + #if PIN_EXISTS(J_MS3) + PIN_CHAR(J_MS3); + #endif + #endif + #if HAS_K_MS_PINS + MS_LINE(K); + #if PIN_EXISTS(K_MS3) + PIN_CHAR(K_MS3); + #endif + #endif + #if HAS_U_MS_PINS + MS_LINE(U); + #if PIN_EXISTS(U_MS3) + PIN_CHAR(U_MS3); + #endif + #endif + #if HAS_V_MS_PINS + MS_LINE(V); + #if PIN_EXISTS(V_MS3) + PIN_CHAR(V_MS3); + #endif + #endif + #if HAS_W_MS_PINS + MS_LINE(W); + #if PIN_EXISTS(W_MS3) + PIN_CHAR(W_MS3); + #endif + #endif + #if HAS_E0_MS_PINS + MS_LINE(E0); + #if PIN_EXISTS(E0_MS3) + PIN_CHAR(E0_MS3); + #endif + #endif + #if HAS_E1_MS_PINS + MS_LINE(E1); + #if PIN_EXISTS(E1_MS3) + PIN_CHAR(E1_MS3); + #endif + #endif + #if HAS_E2_MS_PINS + MS_LINE(E2); + #if PIN_EXISTS(E2_MS3) + PIN_CHAR(E2_MS3); + #endif + #endif + #if HAS_E3_MS_PINS + MS_LINE(E3); + #if PIN_EXISTS(E3_MS3) + PIN_CHAR(E3_MS3); + #endif + #endif + #if HAS_E4_MS_PINS + MS_LINE(E4); + #if PIN_EXISTS(E4_MS3) + PIN_CHAR(E4_MS3); + #endif + #endif + #if HAS_E5_MS_PINS + MS_LINE(E5); + #if PIN_EXISTS(E5_MS3) + PIN_CHAR(E5_MS3); + #endif + #endif + #if HAS_E6_MS_PINS + MS_LINE(E6); + #if PIN_EXISTS(E6_MS3) + PIN_CHAR(E6_MS3); + #endif + #endif + #if HAS_E7_MS_PINS + MS_LINE(E7); + #if PIN_EXISTS(E7_MS3) + PIN_CHAR(E7_MS3); + #endif + #endif + SERIAL_EOL(); + } + +#endif // HAS_MICROSTEPS diff --git a/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h b/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h index 0f4db200a3..fb8a1e7c6d 100644 --- a/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h +++ b/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h @@ -102,10 +102,6 @@ #define E0_ENABLE_PIN 37 // PB22 // Microstepping mode pins -#define Z_MS1_PIN 52 // PB21 MODE0 MOTOR 1 -#define Z_MS2_PIN 52 // PB21 MODE1 -#define Z_MS3_PIN 65 // PB20 MODE2 - #define X_MS1_PIN 43 // PA20 MODE0 MOTOR 2 #define X_MS2_PIN 43 // PA20 MODE1 #define X_MS3_PIN 42 // PA19 MODE2 @@ -114,6 +110,10 @@ #define Y_MS2_PIN 77 // PA28 MODE1 #define Y_MS3_PIN 76 // PA27 MODE2 +#define Z_MS1_PIN 52 // PB21 MODE0 MOTOR 1 +#define Z_MS2_PIN 52 // PB21 MODE1 +#define Z_MS3_PIN 65 // PB20 MODE2 + #define E0_MS1_PIN 38 // PB11 MODE0 MOTOR 4 #define E0_MS2_PIN 38 // PB11 MODE1 #define E0_MS3_PIN 39 // PB10 MODE2 diff --git a/ini/features.ini b/ini/features.ini index 1cff1a61f4..e51ad0bda3 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -22,6 +22,7 @@ POSTMORTEM_DEBUGGING = build_src_filter=+ + + + + +HAS_STEPPER_CONTROL = build_src_filter=+ HAS_T(RINAMIC_CONFIG|MC_SPI) = build_src_filter=+ EDITABLE_HOMING_CURRENT = build_src_filter=+ SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/6f53c19a8a.zip From f6c891554574e00febec83208951fa52ad8af7b7 Mon Sep 17 00:00:00 2001 From: David Buezas Date: Sun, 20 Apr 2025 07:18:45 +0200 Subject: [PATCH 09/51] =?UTF-8?q?=E2=9C=A8=20SMOOTH=5FLIN=5FADVANCE=20(#27?= =?UTF-8?q?710)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 18 ++ Marlin/src/feature/bltouch.cpp | 2 +- Marlin/src/gcode/feature/advance/M900.cpp | 50 ++++- Marlin/src/inc/Conditionals-4-adv.h | 5 + Marlin/src/inc/SanityCheck.h | 18 +- Marlin/src/inc/Warnings.cpp | 9 + Marlin/src/lcd/language/language_en.h | 2 + Marlin/src/lcd/menu/menu_advanced.cpp | 28 ++- Marlin/src/lcd/menu/menu_tune.cpp | 12 ++ Marlin/src/module/planner.cpp | 63 ++++-- Marlin/src/module/planner.h | 37 +++- Marlin/src/module/settings.cpp | 44 +++- Marlin/src/module/stepper.cpp | 233 +++++++++++++++++++--- Marlin/src/module/stepper.h | 39 +++- buildroot/tests/LPC1768 | 28 ++- buildroot/tests/LPC1769 | 22 +- 16 files changed, 504 insertions(+), 106 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 73073762f1..9d291f6219 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2352,6 +2352,24 @@ //#define ADVANCE_K_EXTRA // Add a second linear advance constant, configurable with M900 L. //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. //#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz. + + //#define SMOOTH_LIN_ADVANCE // Remove limits on acceleration by gradual increase of nozzle pressure + #if ENABLED(SMOOTH_LIN_ADVANCE) + /** + * ADVANCE_TAU is also the time ahead that the smoother needs to look + * into the planner, so the planner needs to have enough blocks loaded. + * For k=0.04 at 10k acceleration and an "Orbiter 2" extruder it can be as low as 0.0075. + * Adjust by lowering the value until you observe the extruder skipping, then raise slightly. + * Higher k and higher XY acceleration may require larger ADVANCE_TAU to avoid skipping steps. + */ + #if ENABLED(DISTINCT_E_FACTORS) + #define ADVANCE_TAU { 0.01 } // (s) Smoothing time to reduce extruder acceleration, per extruder + #else + #define ADVANCE_TAU 0.01 // (s) Smoothing time to reduce extruder acceleration + #endif + #define SMOOTH_LIN_ADV_HZ 5000 // (Hz) How often to update extruder speed + #define INPUT_SHAPING_E_SYNC // Synchronize the extruder-shaped XY axes (to increase precision) + #endif #endif /** diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 2559547b85..5b498cd474 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -48,7 +48,7 @@ bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) { // The previous write should've already delayed to detect the alarm. if (cmd != current) { servo[Z_PROBE_SERVO_NR].move(cmd); - safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay + safe_delay(_MAX(ms, uint32_t(BLTOUCH_DELAY))); // BLTOUCH_DELAY is also the *minimum* delay } return triggered(); } diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index e8a16d952f..51a40f934e 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -26,6 +26,7 @@ #include "../../gcode.h" #include "../../../module/planner.h" +#include "../../../module/stepper.h" #if ENABLED(ADVANCE_K_EXTRA) float other_extruder_advance_K[DISTINCT_E]; @@ -62,6 +63,11 @@ void GcodeSuite::M900() { float &kref = planner.extruder_advance_K[E_INDEX_N(tool_index)], newK = kref; const float oldK = newK; + #if ENABLED(SMOOTH_LIN_ADVANCE) + const float oldU = stepper.get_advance_tau(E_INDEX_N(tool_index)); + float newU = oldU; + #endif + #if ENABLED(ADVANCE_K_EXTRA) float &lref = other_extruder_advance_K[E_INDEX_N(tool_index)]; @@ -105,9 +111,22 @@ void GcodeSuite::M900() { #endif - if (newK != oldK) { + #if ENABLED(SMOOTH_LIN_ADVANCE) + if (parser.seenval('U')) { + const float tau = parser.value_float(); + if (WITHIN(tau, 0.0f, 0.5f)) + newU = tau; + else + echo_value_oor('U'); + } + #endif + + if (newK != oldK || TERN0(SMOOTH_LIN_ADVANCE, newU != oldU)) { planner.synchronize(); - kref = newK; + if (newK != oldK) kref = newK; + #if ENABLED(SMOOTH_LIN_ADVANCE) + if (newU != oldU) stepper.set_advance_tau(newU); + #endif } if (!parser.seen_any()) { @@ -124,18 +143,27 @@ void GcodeSuite::M900() { } #endif - #else + #else // !ADVANCE_K_EXTRA SERIAL_ECHO_START(); #if DISTINCT_E < 2 - SERIAL_ECHOLNPGM("Advance K=", planner.extruder_advance_K[0]); + SERIAL_ECHOPGM("Advance K=", planner.extruder_advance_K[0]); + #if ENABLED(SMOOTH_LIN_ADVANCE) + SERIAL_ECHOPGM(" TAU=", stepper.get_advance_tau()); + #endif + SERIAL_EOL(); #else SERIAL_ECHOPGM("Advance K"); EXTRUDER_LOOP() SERIAL_ECHO(C(' '), C('0' + e), C(':'), planner.extruder_advance_K[e]); SERIAL_EOL(); + #if ENABLED(SMOOTH_LIN_ADVANCE) + SERIAL_ECHOPGM("Advance TAU"); + EXTRUDER_LOOP() SERIAL_ECHO(C(' '), C('0' + e), C(':'), stepper.get_advance_tau(e)); + SERIAL_EOL(); + #endif #endif - #endif + #endif // !ADVANCE_K_EXTRA } } @@ -146,11 +174,19 @@ void GcodeSuite::M900_report(const bool forReplay/*=true*/) { report_heading(forReplay, F(STR_LINEAR_ADVANCE)); #if DISTINCT_E < 2 report_echo_start(forReplay); - SERIAL_ECHOLNPGM(" M900 K", planner.extruder_advance_K[0]); + SERIAL_ECHOPGM(" M900 K", planner.extruder_advance_K[0]); + #if ENABLED(SMOOTH_LIN_ADVANCE) + SERIAL_ECHOPGM(" M900 U", stepper.get_advance_tau()); + #endif + SERIAL_EOL(); #else EXTRUDER_LOOP() { report_echo_start(forReplay); - SERIAL_ECHOLNPGM(" M900 T", e, " K", planner.extruder_advance_K[e]); + SERIAL_ECHOPGM(" M900 T", e, " K", planner.extruder_advance_K[e]); + #if ENABLED(SMOOTH_LIN_ADVANCE) + SERIAL_ECHOPGM(" U", stepper.get_advance_tau(e)); + #endif + SERIAL_EOL(); } #endif } diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index 109fca6b29..ca096c7661 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -231,6 +231,7 @@ #undef FWRETRACT #undef LCD_SHOW_E_TOTAL #undef LIN_ADVANCE + #undef SMOOTH_LIN_ADVANCE #undef MANUAL_E_MOVES_RELATIVE #undef PID_EXTRUSION_SCALING #undef SHOW_TEMP_ADC_VALUES @@ -339,6 +340,10 @@ #define HAS_LINEAR_E_JERK 1 #endif +#if ENABLED(LIN_ADVANCE) && DISABLED(SMOOTH_LIN_ADVANCE) + #define HAS_ROUGH_LIN_ADVANCE 1 +#endif + // Some displays can toggle Adaptive Step Smoothing. // The state is saved to EEPROM. // In future this may be added to a G-code such as M205 A. diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index cd3c1cd573..970847ecb5 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -847,7 +847,23 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #if ENABLED(DIRECT_STEPPING) #error "DIRECT_STEPPING is incompatible with LIN_ADVANCE. (Extrusion is controlled externally by the Step Daemon.)" #endif -#endif + + /** + * Smooth Linear Advance + */ + #if ENABLED(SMOOTH_LIN_ADVANCE) + #ifndef CPU_32_BIT + #error "SMOOTH_LIN_ADVANCE requires a 32-bit CPU." + #elif DISTINCT_E > 1 + #error "SMOOTH_LIN_ADVANCE is not compatible with multiple extruders." + #elif ENABLED(S_CURVE_ACCELERATION) + #error "SMOOTH_LIN_ADVANCE is not compatible with S_CURVE_ACCELERATION." + #elif ENABLED(INPUT_SHAPING_E_SYNC) && NONE(INPUT_SHAPING_X, INPUT_SHAPING_Y) + #error "INPUT_SHAPING_E_SYNC requires INPUT_SHAPING_X or INPUT_SHAPING_Y." + #endif + #endif + +#endif // LIN_ADVANCE /** * Nonlinear Extrusion requirements diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 119e2205ab..f11eedbe52 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -946,3 +946,12 @@ #if LCD_IS_SERIAL_HOST && defined(BOARD_LCD_SERIAL_PORT) && LCD_SERIAL_PORT != BOARD_LCD_SERIAL_PORT && DISABLED(NO_LCD_SERIAL_PORT_WARNING) #warning "LCD_SERIAL_PORT overrides the default (BOARD_LCD_SERIAL_PORT)." #endif + +/** + * Smooth Linear Advance with Mixing Extruder, S-Curve Acceleration + */ +#if ENABLED(SMOOTH_LIN_ADVANCE) + #if ENABLED(MIXING_EXTRUDER) + #warning "SMOOTH_LIN_ADVANCE with MIXING_EXTRUDER is untested. Use with caution." + #endif +#endif diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index d184c0358f..e0c1f53f77 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -492,7 +492,9 @@ namespace LanguageNarrow_en { LSTR MSG_MAX_BELT_LEN = _UxGT("Max Belt Len"); LSTR MSG_LINEAR_ADVANCE = _UxGT("Linear Advance"); LSTR MSG_ADVANCE_K = _UxGT("Advance K"); + LSTR MSG_ADVANCE_TAU = _UxGT("Advance Tau"); LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); + LSTR MSG_ADVANCE_TAU_E = _UxGT("Advance Tau *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Timeout (m)"); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 137439c6df..296312bb1f 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -122,7 +122,18 @@ void menu_backlash(); EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif - #endif + #if ENABLED(SMOOTH_LIN_ADVANCE) + #if DISTINCT_E < 2 + editable.decimal = stepper.get_advance_tau(); + EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal); }); + #else + EXTRUDER_LOOP() { + editable.decimal = stepper.get_advance_tau(e); + EDIT_ITEM_N(float54, e, MSG_ADVANCE_TAU_E, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal, MenuItemBase::itemIndex); }); + } + #endif + #endif + #endif // LIN_ADVANCE #if DISABLED(NO_VOLUMETRICS) EDIT_ITEM(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers); @@ -735,13 +746,26 @@ void menu_advanced_settings() { #if HAS_ADV_FILAMENT_MENU SUBMENU(MSG_FILAMENT, menu_advanced_filament); - #elif ENABLED(LIN_ADVANCE) + #endif + + #if ENABLED(LIN_ADVANCE) && DISABLED(HAS_ADV_FILAMENT_MENU) #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); #else EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif + #if ENABLED(SMOOTH_LIN_ADVANCE) + #if DISTINCT_E < 2 + editable.decimal = stepper.get_advance_tau(); + EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal); }); + #else + EXTRUDER_LOOP() { + editable.decimal = stepper.get_advance_tau(e); + EDIT_ITEM_N(float54, e, MSG_ADVANCE_TAU_E, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal, MenuItemBase::itemIndex); }); + } + #endif + #endif #endif // M540 S - Abort on endstop hit when SD printing diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 1f1571d986..51d877fc5c 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -31,6 +31,7 @@ #include "menu_item.h" #include "../../module/motion.h" #include "../../module/planner.h" +#include "../../module/stepper.h" #include "../../module/temperature.h" #include "../../MarlinCore.h" @@ -220,6 +221,17 @@ void menu_tune() { EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif + #if ENABLED(SMOOTH_LIN_ADVANCE) + #if DISTINCT_E < 2 + editable.decimal = stepper.get_advance_tau(); + EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal); }); + #else + EXTRUDER_LOOP() { + editable.decimal = stepper.get_advance_tau(e); + EDIT_ITEM_N(float54, e, MSG_ADVANCE_TAU_E, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal, MenuItemBase::itemIndex); }); + } + #endif + #endif #endif // diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 881e11f4c0..87cb4cd21b 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -775,6 +775,14 @@ block_t* Planner::get_current_block() { return nullptr; } +block_t* Planner::get_future_block(const uint8_t offset) { + const uint8_t nr_moves = movesplanned(); + if (nr_moves <= offset) return nullptr; + block_t * const block = &block_buffer[block_inc_mod(block_buffer_tail, offset)]; + if (block->flag.recalculate) return nullptr; + return block; +} + /** * Calculate trapezoid parameters, multiplying the entry- and exit-speeds * by the provided factors. If entry_factor is 0 don't change the initial_rate. @@ -840,13 +848,15 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t } } - #if ENABLED(S_CURVE_ACCELERATION) + #if ANY(S_CURVE_ACCELERATION, SMOOTH_LIN_ADVANCE) const float rate_factor = inverse_accel * (STEPPER_TIMER_RATE); // Jerk controlled speed requires to express speed versus time, NOT steps uint32_t acceleration_time = rate_factor * float(cruise_rate - initial_rate), - deceleration_time = rate_factor * float(cruise_rate - final_rate), + deceleration_time = rate_factor * float(cruise_rate - final_rate); + #endif + #if ENABLED(S_CURVE_ACCELERATION) // And to offload calculations from the ISR, we also calculate the inverse of those times here - acceleration_time_inverse = get_period_inverse(acceleration_time), + uint32_t acceleration_time_inverse = get_period_inverse(acceleration_time), deceleration_time_inverse = get_period_inverse(deceleration_time); #endif @@ -856,15 +866,20 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t block->initial_rate = initial_rate; block->final_rate = final_rate; - #if ENABLED(S_CURVE_ACCELERATION) + #if ANY(S_CURVE_ACCELERATION, SMOOTH_LIN_ADVANCE) block->acceleration_time = acceleration_time; block->deceleration_time = deceleration_time; - block->acceleration_time_inverse = acceleration_time_inverse; - block->deceleration_time_inverse = deceleration_time_inverse; block->cruise_rate = cruise_rate; #endif + #if ENABLED(S_CURVE_ACCELERATION) + block->acceleration_time_inverse = acceleration_time_inverse; + block->deceleration_time_inverse = deceleration_time_inverse; + #endif + #if ENABLED(SMOOTH_LIN_ADVANCE) + block->cruise_time = plateau_steps > 0 ? float(plateau_steps) * float(STEPPER_TIMER_RATE) / float(cruise_rate) : 0; + #endif - #if ENABLED(LIN_ADVANCE) + #if HAS_ROUGH_LIN_ADVANCE if (block->la_advance_rate) { const float comp = extruder_advance_K[E_INDEX_N(block->extruder)] * block->steps.e / block->step_event_count; block->max_adv_steps = cruise_rate * comp; @@ -2409,15 +2424,17 @@ bool Planner::_populate_block( if (e_D_ratio > 3.0f) use_advance_lead = false; else { - // Scale E acceleration so that it will be possible to jump to the advance speed. - const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[E_INDEX_N(extruder)] * e_D_ratio) * steps_per_mm; - if (accel > max_accel_steps_per_s2) { - accel = max_accel_steps_per_s2; - if (ENABLED(LA_DEBUG)) SERIAL_ECHOLNPGM("Acceleration limited."); - } + #if HAS_ROUGH_LIN_ADVANCE + // Scale E acceleration so that it will be possible to jump to the advance speed. + const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[E_INDEX_N(extruder)] * e_D_ratio) * steps_per_mm; + if (accel > max_accel_steps_per_s2) { + accel = max_accel_steps_per_s2; + if (TERN0(LA_DEBUG, DEBUGGING(INFO))) SERIAL_ECHOLNPGM("Acceleration limited."); + } + #endif } } - #endif + #endif // LIN_ADVANCE // Limit acceleration per axis if (block->step_event_count <= acceleration_long_cutoff) { @@ -2443,10 +2460,9 @@ bool Planner::_populate_block( block->acceleration_rate = uint32_t(accel * (float(1UL << 24) / (STEPPER_TIMER_RATE))); #endif - #if ENABLED(LIN_ADVANCE) + #if HAS_ROUGH_LIN_ADVANCE block->la_advance_rate = 0; block->la_scaling = 0; - if (use_advance_lead) { // The Bresenham algorithm will convert this step rate into extruder steps block->la_advance_rate = extruder_advance_K[E_INDEX_N(extruder)] * block->acceleration_steps_per_s2; @@ -2456,12 +2472,14 @@ bool Planner::_populate_block( for (uint32_t dividend = block->steps.e << 1; dividend <= (block->step_event_count >> 2); dividend <<= 1) block->la_scaling++; - #if ENABLED(LA_DEBUG) - if (block->la_advance_rate >> block->la_scaling > 10000) + // Output debugging if the rate gets very high + if (TERN0(LA_DEBUG, DEBUGGING(INFO)) && block->la_advance_rate >> block->la_scaling > 10000) SERIAL_ECHOLNPGM("eISR running at > 10kHz: ", block->la_advance_rate); - #endif } - #endif // LIN_ADVANCE + #elif ENABLED(SMOOTH_LIN_ADVANCE) + block->use_advance_lead = use_advance_lead; + block->e_step_ratio = (block->direction_bits.e ? 1 : -1) * float(block->steps.e) / block->step_event_count; + #endif // Formula for the average speed over a 1 step worth of distance if starting from zero and // accelerating at the current limit. Since we can only change the speed every step this is a @@ -2688,7 +2706,8 @@ bool Planner::_populate_block( } #endif - #if ENABLED(LIN_ADVANCE) + // In the SMOOTH_LIN_ADVANCE case, the extra jerk will be applied by the residual current la_step_rate. + #if HAS_ROUGH_LIN_ADVANCE // Advance affects E_AXIS speed and therefore jerk. Add a speed correction whenever // LA is turned OFF. No correction is applied when LA is turned ON (because it didn't // perform well; it takes more time/effort to push/melt filament than the reverse). @@ -2703,7 +2722,7 @@ bool Planner::_populate_block( // Prepare for next segment. previous_advance_rate = block->la_advance_rate; previous_e_mm_per_step = mm_per_step[E_AXIS_N(extruder)]; - #endif + #endif // HAS_ROUGH_LIN_ADVANCE xyze_float_t speed_diff = current_speed; float vmax_junction; diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index e8bacddd9f..a2f91edc81 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -43,6 +43,11 @@ #define JD_USE_LOOKUP_TABLE #endif +#if ENABLED(SMOOTH_LIN_ADVANCE) + #define SMOOTH_LIN_ADV_EXP_ORDER 5 // Closest to Gaussian smoothing between 3 and 7 + #define SMOOTH_LIN_ADV_INTERVAL (STEPPER_TIMER_RATE / SMOOTH_LIN_ADV_HZ) // Hz +#endif + #include "motion.h" #include "../gcode/queue.h" @@ -240,11 +245,17 @@ typedef struct PlannerBlock { uint32_t accelerate_before, // The index of the step event where cruising starts decelerate_start; // The index of the step event on which to start decelerating - #if ENABLED(S_CURVE_ACCELERATION) + #if ENABLED(SMOOTH_LIN_ADVANCE) + uint32_t cruise_time; // Cruise time in STEP timer counts + float e_step_ratio; + #endif + #if ANY(S_CURVE_ACCELERATION, SMOOTH_LIN_ADVANCE) uint32_t cruise_rate, // The actual cruise rate to use, between end of the acceleration phase and start of deceleration phase acceleration_time, // Acceleration time and deceleration time in STEP timer counts - deceleration_time, - acceleration_time_inverse, // Inverse of acceleration and deceleration periods, expressed as integer. Scale depends on CPU being used + deceleration_time; + #endif + #if ENABLED(S_CURVE_ACCELERATION) + uint32_t acceleration_time_inverse, // Inverse of acceleration and deceleration periods, expressed as integer. Scale depends on CPU being used deceleration_time_inverse; #else uint32_t acceleration_rate; // Acceleration rate in (2^24 steps)/timer_ticks*s @@ -254,10 +265,14 @@ typedef struct PlannerBlock { // Advance extrusion #if ENABLED(LIN_ADVANCE) - uint32_t la_advance_rate; // The rate at which steps are added whilst accelerating - uint8_t la_scaling; // Scale ISR frequency down and step frequency up by 2 ^ la_scaling - uint16_t max_adv_steps, // Max advance steps to get cruising speed pressure - final_adv_steps; // Advance steps for exit speed pressure + #if ENABLED(SMOOTH_LIN_ADVANCE) + bool use_advance_lead; + #else + uint32_t la_advance_rate; // The rate at which steps are added whilst accelerating + uint8_t la_scaling; // Scale ISR frequency down and step frequency up by 2 ^ la_scaling + uint16_t max_adv_steps, // Max advance steps to get cruising speed pressure + final_adv_steps; // Advance steps for exit speed pressure + #endif #endif uint32_t nominal_rate, // The nominal step rate for this block in step_events/sec @@ -1041,6 +1056,14 @@ class Planner { */ static block_t* get_current_block(); + /** + * Get a planned upcoming block from the buffer. + * Return nullptr if the buffer doesn't have the `current + offset` yet. + * + * WARNING: Called from Stepper ISR context! + */ + static block_t* get_future_block(const uint8_t offset); + /** * "Release" the current block so its slot can be reused. * Called when the current block is no longer needed. diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index a6714b3e6a..feb433041e 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -500,7 +500,12 @@ typedef struct SettingsDataStruct { // // LIN_ADVANCE // - float planner_extruder_advance_K[DISTINCT_E]; // M900 K planner.extruder_advance_K + #if ENABLED(LIN_ADVANCE) + float planner_extruder_advance_K[DISTINCT_E]; // M900 K planner.extruder_advance_K + #if ENABLED(SMOOTH_LIN_ADVANCE) + float stepper_extruder_advance_tau[DISTINCT_E]; // M900 U stepper.extruder_advance_tau + #endif + #endif // // HAS_MOTOR_CURRENT_PWM @@ -1554,13 +1559,13 @@ void MarlinSettings::postprocess() { // Linear Advance // { - _FIELD_TEST(planner_extruder_advance_K); - #if ENABLED(LIN_ADVANCE) + _FIELD_TEST(planner_extruder_advance_K); EEPROM_WRITE(planner.extruder_advance_K); - #else - dummyf = 0; - for (uint8_t q = DISTINCT_E; q--;) EEPROM_WRITE(dummyf); + #if ENABLED(SMOOTH_LIN_ADVANCE) + _FIELD_TEST(stepper_extruder_advance_tau); + EEPROM_WRITE(stepper.extruder_advance_tau); + #endif #endif } @@ -2633,15 +2638,27 @@ void MarlinSettings::postprocess() { // // Linear Advance // + #if ENABLED(LIN_ADVANCE) { float extruder_advance_K[DISTINCT_E]; _FIELD_TEST(planner_extruder_advance_K); EEPROM_READ(extruder_advance_K); - #if ENABLED(LIN_ADVANCE) - if (!validating) - COPY(planner.extruder_advance_K, extruder_advance_K); + if (!validating) + COPY(planner.extruder_advance_K, extruder_advance_K); + #if ENABLED(SMOOTH_LIN_ADVANCE) + _FIELD_TEST(stepper_extruder_advance_tau); + float tau[DISTINCT_E]; + EEPROM_READ(tau); + if (!validating) { + #if ENABLED(DISTINCT_E_FACTORS) + EXTRUDER_LOOP() stepper.set_advance_tau(tau[e], e); + #else + stepper.set_advance_tau(tau[0]); + #endif + } #endif } + #endif // // Motor Current PWM @@ -3742,6 +3759,15 @@ void MarlinSettings::reset() { #else planner.extruder_advance_K[0] = ADVANCE_K; #endif + #if ENABLED(SMOOTH_LIN_ADVANCE) + #if ENABLED(DISTINCT_E_FACTORS) + constexpr float linAdvanceTau[] = ADVANCE_TAU; + EXTRUDER_LOOP() + stepper.set_advance_tau(linAdvanceTau[_MAX(uint8_t(e), COUNT(linAdvanceTau) - 1)], e); + #else + stepper.set_advance_tau(ADVANCE_TAU); + #endif + #endif #endif // diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 1340cd9157..cc042181c6 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -256,10 +256,15 @@ uint32_t Stepper::advance_divisor = 0, #if ENABLED(LIN_ADVANCE) hal_timer_t Stepper::nextAdvanceISR = LA_ADV_NEVER, Stepper::la_interval = LA_ADV_NEVER; - int32_t Stepper::la_delta_error = 0, + #if HAS_ROUGH_LIN_ADVANCE + int32_t Stepper::la_delta_error = 0, Stepper::la_dividend = 0, Stepper::la_advance_steps = 0; - bool Stepper::la_active = false; + bool Stepper::la_active = false; + #else + uint32_t Stepper::curr_step_rate, + Stepper::curr_timer_tick = 0; + #endif #endif #if ENABLED(NONLINEAR_EXTRUSION) @@ -1521,6 +1526,10 @@ void Stepper::isr() { static hal_timer_t nextMainISR = 0; // Interval until the next main Stepper Pulse phase (0 = Now) + #if ENABLED(SMOOTH_LIN_ADVANCE) + static hal_timer_t smoothLinAdvISR = 0; + #endif + // Program timer compare for the maximum period, so it does NOT // flag an interrupt while this ISR is running - So changes from small // periods to big periods are respected and the timer does not reset to 0 @@ -1594,6 +1603,9 @@ void Stepper::isr() { // ^== Time critical. NOTHING besides pulse generation should be above here!!! if (!nextMainISR) nextMainISR = block_phase_isr(); // Manage acc/deceleration, get next block + #if ENABLED(SMOOTH_LIN_ADVANCE) + if (!smoothLinAdvISR) smoothLinAdvISR = smooth_lin_adv_isr(); // Manage la + #endif #if ENABLED(BABYSTEPPING) if (is_babystep) // Avoid ANY stepping too soon after baby-stepping @@ -1609,6 +1621,7 @@ void Stepper::isr() { TERN_(INPUT_SHAPING_Y, NOMORE(interval, ShapingQueue::peek_y())); // Time until next input shaping echo for Y TERN_(INPUT_SHAPING_Z, NOMORE(interval, ShapingQueue::peek_z())); // Time until next input shaping echo for Z TERN_(LIN_ADVANCE, NOMORE(interval, nextAdvanceISR)); // Come back early for Linear Advance? + TERN_(SMOOTH_LIN_ADVANCE, NOMORE(interval, smoothLinAdvISR)); // Come back early for Linear Advance rate update? TERN_(BABYSTEPPING, NOMORE(interval, nextBabystepISR)); // Come back early for Babystepping? // @@ -1621,6 +1634,7 @@ void Stepper::isr() { nextMainISR -= interval; TERN_(HAS_ZV_SHAPING, ShapingQueue::decrement_delays(interval)); TERN_(LIN_ADVANCE, if (nextAdvanceISR != LA_ADV_NEVER) nextAdvanceISR -= interval); + TERN_(SMOOTH_LIN_ADVANCE, if (smoothLinAdvISR != LA_ADV_NEVER) smoothLinAdvISR -= interval); TERN_(BABYSTEPPING, if (nextBabystepISR != BABYSTEP_NEVER) nextBabystepISR -= interval); } // standard motion control @@ -2000,15 +2014,18 @@ void Stepper::pulse_phase_isr() { #if ANY(HAS_E0_STEP, MIXING_EXTRUDER) PULSE_PREP(E); + #endif - #if ENABLED(LIN_ADVANCE) - if (la_active && step_needed.e) { - // don't actually step here, but do subtract movements steps - // from the linear advance step count - step_needed.e = false; - la_advance_steps--; - } - #endif + #if HAS_ROUGH_LIN_ADVANCE + if (la_active && step_needed.e) { + // don't actually step here, but do subtract movements steps + // from the linear advance step count + step_needed.e = false; + la_advance_steps--; + } + #elif ENABLED(SMOOTH_LIN_ADVANCE) + // Extruder steps are exclusively managed by the LA isr + step_needed.e = false; #endif #if HAS_ZV_SHAPING @@ -2458,7 +2475,7 @@ hal_timer_t Stepper::block_phase_isr() { calc_nonlinear_e(acc_step_rate << oversampling_factor); #endif - #if ENABLED(LIN_ADVANCE) + #if HAS_ROUGH_LIN_ADVANCE if (la_active) { const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0; la_interval = calc_timer_interval((acc_step_rate + la_step_rate) >> current_block->la_scaling); @@ -2487,6 +2504,7 @@ hal_timer_t Stepper::block_phase_isr() { else cutter.apply_power(0); } #endif + TERN_(SMOOTH_LIN_ADVANCE, curr_step_rate = acc_step_rate;) } // Are we in Deceleration phase ? else if (step_events_completed >= decelerate_start) { @@ -2523,7 +2541,7 @@ hal_timer_t Stepper::block_phase_isr() { calc_nonlinear_e(step_rate << oversampling_factor); #endif - #if ENABLED(LIN_ADVANCE) + #if HAS_ROUGH_LIN_ADVANCE if (la_active) { const uint32_t la_step_rate = la_advance_steps > current_block->final_adv_steps ? current_block->la_advance_rate : 0; if (la_step_rate != step_rate) { @@ -2561,7 +2579,7 @@ hal_timer_t Stepper::block_phase_isr() { } } #endif - + TERN_(SMOOTH_LIN_ADVANCE, curr_step_rate = step_rate;) } else { // Must be in cruise phase otherwise @@ -2571,13 +2589,14 @@ hal_timer_t Stepper::block_phase_isr() { ticks_nominal = calc_multistep_timer_interval(current_block->nominal_rate << oversampling_factor); // Prepare for deceleration IF_DISABLED(S_CURVE_ACCELERATION, acc_step_rate = current_block->nominal_rate); + TERN_(SMOOTH_LIN_ADVANCE, curr_step_rate = current_block->nominal_rate;) deceleration_time = ticks_nominal / 2; #if ENABLED(NONLINEAR_EXTRUSION) calc_nonlinear_e(current_block->nominal_rate << oversampling_factor); #endif - #if ENABLED(LIN_ADVANCE) + #if HAS_ROUGH_LIN_ADVANCE if (la_active) la_interval = calc_timer_interval(current_block->nominal_rate >> current_block->la_scaling); #endif @@ -2712,7 +2731,8 @@ hal_timer_t Stepper::block_phase_isr() { step_event_count = current_block->step_event_count << oversampling_factor; // Initialize Bresenham delta errors to 1/2 - delta_error = TERN_(LIN_ADVANCE, la_delta_error =) -int32_t(step_event_count); + delta_error = -int32_t(step_event_count); + TERN_(HAS_ROUGH_LIN_ADVANCE, la_delta_error = delta_error); // Calculate Bresenham dividends and divisors advance_dividend = (current_block->steps << 1).asLong(); @@ -2762,12 +2782,12 @@ hal_timer_t Stepper::block_phase_isr() { E_TERN_(stepper_extruder = current_block->extruder); // Initialize the trapezoid generator from the current block. - #if ENABLED(LIN_ADVANCE) - la_active = (current_block->la_advance_rate != 0); + #if HAS_ROUGH_LIN_ADVANCE #if DISABLED(MIXING_EXTRUDER) && E_STEPPERS > 1 // If the now active extruder wasn't in use during the last move, its pressure is most likely gone. if (stepper_extruder != last_moved_extruder) la_advance_steps = 0; #endif + la_active = (current_block->la_advance_rate != 0); if (la_active) { // Apply LA scaling and discount the effect of frequency scaling la_dividend = (advance_dividend.e << current_block->la_scaling) << oversampling_factor; @@ -2849,10 +2869,14 @@ hal_timer_t Stepper::block_phase_isr() { #endif #if ENABLED(LIN_ADVANCE) - if (la_active) { - const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0; - la_interval = calc_timer_interval((current_block->initial_rate + la_step_rate) >> current_block->la_scaling); - } + #if ENABLED(SMOOTH_LIN_ADVANCE) + curr_timer_tick = 0; + #else + if (la_active) { + const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0; + la_interval = calc_timer_interval((current_block->initial_rate + la_step_rate) >> current_block->la_scaling); + } + #endif #endif } } // !current_block @@ -2863,17 +2887,176 @@ hal_timer_t Stepper::block_phase_isr() { #if ENABLED(LIN_ADVANCE) + #if ENABLED(SMOOTH_LIN_ADVANCE) + + float Stepper::extruder_advance_tau[DISTINCT_E], + Stepper::extruder_advance_tau_ticks[DISTINCT_E], + Stepper::extruder_advance_alpha[DISTINCT_E]; + + void Stepper::set_la_interval(const int32_t rate) { + if (rate == 0) { + la_interval = LA_ADV_NEVER; + } + else { + const bool forward_e = rate > 0; + la_interval = calc_timer_interval(uint32_t(ABS(rate))); + if (forward_e != motor_direction(E_AXIS)) { + last_direction_bits.toggle(E_AXIS); + count_direction.e = -count_direction.e; + DIR_WAIT_BEFORE(); + E_APPLY_DIR(forward_e, false); + TERN_(FT_MOTION, last_set_direction = last_direction_bits); + DIR_WAIT_AFTER(); + } + } + } + + #if ENABLED(INPUT_SHAPING_E_SYNC) + + constexpr uint16_t IS_COMPENSATION_BUFFER_SIZE = uint16_t(float(SMOOTH_LIN_ADV_HZ) / float(SHAPING_MIN_FREQ) / 2.0f + 0.5f); + + typedef struct { + xy_float_t buffer[IS_COMPENSATION_BUFFER_SIZE]; + uint16_t index; + } DelayBuffer; + + DelayBuffer delayBuffer; + + void add_to_buffer(xy_float_t input) { + delayBuffer.buffer[delayBuffer.index++] = input; + if (delayBuffer.index == IS_COMPENSATION_BUFFER_SIZE) + delayBuffer.index = 0; + } + + xy_float_t lookback(shaping_time_t t /* in stepper timer ticks */) { + constexpr float ADV_TICKS_PER_STEPPER_TICKS = float(SMOOTH_LIN_ADV_HZ) / (STEPPER_TIMER_RATE); + uint32_t delay_steps = t * ADV_TICKS_PER_STEPPER_TICKS + 0.5f; // Convert time to steps + uint16_t past_i; + if (delay_steps>= IS_COMPENSATION_BUFFER_SIZE) { + // this means the buffer is too small. TODO: how to inform user? + past_i = delayBuffer.index; + } + else { + past_i = (delayBuffer.index + IS_COMPENSATION_BUFFER_SIZE - delay_steps) % IS_COMPENSATION_BUFFER_SIZE; + } + return delayBuffer.buffer[past_i]; + } + + #endif // INPUT_SHAPING_E_SYNC + + float lookahead(uint32_t t) { + for (uint8_t i = 0; block_t *block = Planner::get_future_block(i); i++) { + if (block->is_sync()) continue; + if (t <= block->acceleration_time) { + if (!block->use_advance_lead) return 0.0f; + uint32_t rate = STEP_MULTIPLY(t, block->acceleration_rate) + block->initial_rate; + NOMORE(rate, block->nominal_rate); + return rate * block->e_step_ratio; + } + t -= block->acceleration_time; + + if (t <= block->cruise_time) { + if (!block->use_advance_lead) return 0.0f; + return block->cruise_rate * block->e_step_ratio; + } + t -= block->cruise_time; + + if (t <= block->deceleration_time) { + if (!block->use_advance_lead) return 0.0f; + uint32_t rate = STEP_MULTIPLY(t, block->acceleration_rate); + if (rate < block->cruise_rate) { + rate = block->cruise_rate - rate; + NOLESS(rate, block->final_rate); + } + else + rate = block->final_rate; + return rate * block->e_step_ratio; + } + t -= block->deceleration_time; + } + return 0.0f; + } + + hal_timer_t Stepper::smooth_lin_adv_isr() { + float target_adv_steps = 0; + if (current_block) { + const uint32_t t = extruder_advance_tau_ticks[0] + curr_timer_tick; + target_adv_steps = lookahead(t) * Planner::extruder_advance_K[0]; + } + else { + curr_step_rate = 0; + } + static float last_target_adv_steps = 0; + constexpr float dt_inv = SMOOTH_LIN_ADV_HZ; + float la_step_rate = (target_adv_steps - last_target_adv_steps) * dt_inv; + last_target_adv_steps = target_adv_steps; + + static float smoothed_vals[SMOOTH_LIN_ADV_EXP_ORDER] = {0}; + for (uint8_t i = 0; i < SMOOTH_LIN_ADV_EXP_ORDER; i++) { + // Approximate gaussian smoothing via higher order exponential smoothing + la_step_rate = extruder_advance_alpha[0] * la_step_rate + (1 - extruder_advance_alpha[0]) * smoothed_vals[i]; + smoothed_vals[i] = la_step_rate; + } + const float planned_step_rate = current_block ? curr_step_rate * current_block->e_step_ratio : 0; + float total_step_rate = la_step_rate + planned_step_rate; + + #if ENABLED(INPUT_SHAPING_E_SYNC) + + xy_float_t pre_shaping_rate = xy_float_t({0, 0}), + first_pulse_rate = xy_float_t({0, 0}); + float unshaped_rate_e = total_step_rate; + if (current_block) { + const float xy_length = TERN0(INPUT_SHAPING_X, current_block->steps.x) + TERN0(INPUT_SHAPING_Y, current_block->steps.y); + if (xy_length > 0) { + unshaped_rate_e = 0; + pre_shaping_rate = xy_float_t({ + TERN0(INPUT_SHAPING_X, total_step_rate * current_block->steps.x / xy_length), + TERN0(INPUT_SHAPING_Y, total_step_rate * current_block->steps.y / xy_length) + }); + first_pulse_rate = xy_float_t({ + TERN0(INPUT_SHAPING_X, pre_shaping_rate.x * Stepper::shaping_x.factor1 / 128.0f), + TERN0(INPUT_SHAPING_Y, pre_shaping_rate.y * Stepper::shaping_y.factor1 / 128.0f) + }); + } + } + const xy_float_t second_pulse_rate = { + TERN0(INPUT_SHAPING_X, lookback(ShapingQueue::get_delay_x()).x * Stepper::shaping_x.factor2 / 128.0f), + TERN0(INPUT_SHAPING_Y, lookback(ShapingQueue::get_delay_y()).y * Stepper::shaping_y.factor2 / 128.0f) + }; + add_to_buffer(pre_shaping_rate); + + const float x = TERN0(INPUT_SHAPING_X, first_pulse_rate.x + second_pulse_rate.x), + y = TERN0(INPUT_SHAPING_Y, first_pulse_rate.y + second_pulse_rate.y); + + total_step_rate = unshaped_rate_e + x + y; + + #endif // INPUT_SHAPING_E_SYNC + + set_la_interval(total_step_rate); + + curr_timer_tick += SMOOTH_LIN_ADV_INTERVAL; + return SMOOTH_LIN_ADV_INTERVAL; + } + #endif // SMOOTH_LIN_ADVANCE + // Timer interrupt for E. LA_steps is set in the main routine void Stepper::advance_isr() { // Apply Bresenham algorithm so that linear advance can piggy back on // the acceleration and speed values calculated in block_phase_isr(). // This helps keep LA in sync with, for example, S_CURVE_ACCELERATION. - la_delta_error += la_dividend; - const bool e_step_needed = la_delta_error >= 0; + #if HAS_ROUGH_LIN_ADVANCE + la_delta_error += la_dividend; + const bool e_step_needed = la_delta_error >= 0; + #else + constexpr bool e_step_needed = true; + #endif + if (e_step_needed) { count_position.e += count_direction.e; - la_advance_steps += count_direction.e; - la_delta_error -= advance_divisor; + #if HAS_ROUGH_LIN_ADVANCE + la_advance_steps += count_direction.e; + la_delta_error -= advance_divisor; + #endif // Set the STEP pulse ON E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_next_stepper(), stepper_extruder), STEP_STATE_E); diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 306b2151b5..83ada9202e 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -241,18 +241,21 @@ constexpr ena_mask_t enable_overlap[] = { static bool dequeue_x() { SHAPING_QUEUE_DEQUEUE(x) } static bool empty_x() { return head_x == tail; } static uint16_t free_count_x() { return _free_count_x; } + static uint16_t get_delay_x() { return delay_x; } #endif #if ENABLED(INPUT_SHAPING_Y) static shaping_time_t peek_y() { return _peek_y; } static bool dequeue_y() { SHAPING_QUEUE_DEQUEUE(y) } static bool empty_y() { return head_y == tail; } static uint16_t free_count_y() { return _free_count_y; } + static uint16_t get_delay_y() { return delay_y; } #endif #if ENABLED(INPUT_SHAPING_Z) static shaping_time_t peek_z() { return _peek_z; } static bool dequeue_z() { SHAPING_QUEUE_DEQUEUE(z) } static bool empty_z() { return head_z == tail; } static uint16_t free_count_z() { return _free_count_z; } + static uint16_t get_delay_z() { return delay_z; } #endif static void purge() { const auto st = shaping_time_t(-1); @@ -292,6 +295,7 @@ constexpr ena_mask_t enable_overlap[] = { class Stepper { friend class Max7219; friend class FTMotion; + friend class MarlinSettings; friend void stepperTask(void *); public: @@ -348,6 +352,16 @@ class Stepper { static constexpr bool adaptive_step_smoothing_enabled = true; #endif + #if ENABLED(SMOOTH_LIN_ADVANCE) + static void set_advance_tau(const_float_t tau, const uint8_t e=E_INDEX_N(active_extruder)) { + extruder_advance_tau[e] = tau; + extruder_advance_tau_ticks[e] = tau * (STEPPER_TIMER_RATE); // i.e., <= STEPPER_TIMER_RATE / 2 + // α=1−exp(−dt/τ) + extruder_advance_alpha[e] = 1.0f - expf(-(SMOOTH_LIN_ADV_INTERVAL) * (SMOOTH_LIN_ADV_EXP_ORDER) / extruder_advance_tau_ticks[e]); + } + static float get_advance_tau(const uint8_t e=E_INDEX_N(active_extruder)) { return extruder_advance_tau[e]; } + #endif + private: static block_t* current_block; // A pointer to the block currently being traced @@ -434,11 +448,20 @@ class Stepper { #if ENABLED(LIN_ADVANCE) static constexpr hal_timer_t LA_ADV_NEVER = HAL_TIMER_TYPE_MAX; static hal_timer_t nextAdvanceISR, - la_interval; // Interval between ISR calls for LA - static int32_t la_delta_error, // Analogue of delta_error.e for E steps in LA ISR - la_dividend, // Analogue of advance_dividend.e for E steps in LA ISR - la_advance_steps; // Count of steps added to increase nozzle pressure - static bool la_active; // Whether linear advance is used on the present segment. + la_interval; // Interval between ISR calls for LA + #if ENABLED(SMOOTH_LIN_ADVANCE) + static uint32_t curr_timer_tick, // Current tick relative to block start + curr_step_rate; // Current motion step rate + static float extruder_advance_tau[DISTINCT_E], // Smoothing time; also the lookahead time of the smoother + extruder_advance_tau_ticks[DISTINCT_E], // Same as extruder_advance_tau but in in stepper timer ticks + extruder_advance_alpha[DISTINCT_E]; // The smoothing factor of each stage of the high-order exponential + // smoothing filter (calculated from tau) + #else + static int32_t la_delta_error, // Analogue of delta_error.e for E steps in LA ISR + la_dividend, // Analogue of advance_dividend.e for E steps in LA ISR + la_advance_steps; // Count of steps added to increase nozzle pressure + static bool la_active; // Whether linear advance is used on the present segment + #endif #endif #if ENABLED(NONLINEAR_EXTRUSION) @@ -504,6 +527,10 @@ class Stepper { #if ENABLED(LIN_ADVANCE) // The Linear advance ISR phase static void advance_isr(); + #if ENABLED(SMOOTH_LIN_ADVANCE) + static void set_la_interval(const int32_t rate); + static hal_timer_t smooth_lin_adv_isr(); + #endif #endif #if ENABLED(BABYSTEPPING) @@ -558,7 +585,7 @@ class Stepper { current_block = nullptr; axis_did_move.reset(); planner.release_current_block(); - TERN_(LIN_ADVANCE, la_interval = nextAdvanceISR = LA_ADV_NEVER); + TERN_(HAS_ROUGH_LIN_ADVANCE, la_interval = nextAdvanceISR = LA_ADV_NEVER); } // Quickly stop all steppers diff --git a/buildroot/tests/LPC1768 b/buildroot/tests/LPC1768 index 3a08af8ae8..cd911a9060 100755 --- a/buildroot/tests/LPC1768 +++ b/buildroot/tests/LPC1768 @@ -77,21 +77,19 @@ opt_set MOTHERBOARD BOARD_BTT_SKR_V1_4 SERIAL_PORT -1 \ Z_STEPPER_ALIGN_ITERATIONS 10 DEFAULT_STEPPER_TIMEOUT_SEC 0 \ SLOWDOWN_DIVISOR 16 SDCARD_CONNECTION ONBOARD BLOCK_BUFFER_SIZE 64 \ CHOPPER_TIMING CHOPPER_DEFAULT_24V MMU_SERIAL_PORT 0 -opt_enable PIDTEMPBED S_CURVE_ACCELERATION \ - USE_PROBE_FOR_Z_HOMING BLTOUCH FILAMENT_RUNOUT_SENSOR \ - AUTO_BED_LEVELING_BILINEAR RESTORE_LEVELING_AFTER_G28 \ - EXTRAPOLATE_BEYOND_GRID LCD_BED_LEVELING MESH_EDIT_MENU Z_SAFE_HOMING \ - EEPROM_SETTINGS EEPROM_AUTO_INIT NOZZLE_PARK_FEATURE SDSUPPORT \ - SPEAKER CR10_STOCKDISPLAY QUICK_HOME BLTOUCH_FORCE_SW_MODE \ - Z_STEPPER_AUTO_ALIGN INPUT_SHAPING_X INPUT_SHAPING_Y SHAPING_MENU \ - ADAPTIVE_STEP_SMOOTHING LCD_INFO_MENU STATUS_MESSAGE_SCROLLING \ - SET_PROGRESS_MANUALLY M73_REPORT SHOW_REMAINING_TIME \ - PRINT_PROGRESS_SHOW_DECIMALS AUTO_REPORT_SD_STATUS USE_BIG_EDIT_FONT \ - BABYSTEPPING BABYSTEP_WITHOUT_HOMING BABYSTEP_ALWAYS_AVAILABLE \ - DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_DISPLAY_TOTAL LIN_ADVANCE \ - BEZIER_CURVE_SUPPORT EMERGENCY_PARSER ADVANCED_PAUSE_FEATURE \ - TMC_DEBUG HOST_ACTION_COMMANDS HOST_PAUSE_M76 HOST_PROMPT_SUPPORT \ - HOST_STATUS_NOTIFICATIONS MMU_DEBUG +opt_enable PIDTEMPBED FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE \ + AUTO_BED_LEVELING_BILINEAR EXTRAPOLATE_BEYOND_GRID RESTORE_LEVELING_AFTER_G28 LCD_BED_LEVELING MESH_EDIT_MENU \ + BLTOUCH BLTOUCH_FORCE_SW_MODE USE_PROBE_FOR_Z_HOMING Z_SAFE_HOMING QUICK_HOME Z_STEPPER_AUTO_ALIGN \ + SDSUPPORT AUTO_REPORT_SD_STATUS \ + EEPROM_SETTINGS EEPROM_AUTO_INIT \ + CR10_STOCKDISPLAY USE_BIG_EDIT_FONT SPEAKER LCD_INFO_MENU STATUS_MESSAGE_SCROLLING \ + INPUT_SHAPING_X INPUT_SHAPING_Y SHAPING_MENU \ + BEZIER_CURVE_SUPPORT \ + LIN_ADVANCE SMOOTH_LIN_ADVANCE INPUT_SHAPING_E_SYNC \ + TMC_DEBUG ADAPTIVE_STEP_SMOOTHING \ + SET_PROGRESS_MANUALLY M73_REPORT SHOW_REMAINING_TIME PRINT_PROGRESS_SHOW_DECIMALS \ + BABYSTEPPING BABYSTEP_WITHOUT_HOMING BABYSTEP_ALWAYS_AVAILABLE DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_DISPLAY_TOTAL \ + EMERGENCY_PARSER HOST_ACTION_COMMANDS HOST_PAUSE_M76 HOST_PROMPT_SUPPORT HOST_STATUS_NOTIFICATIONS MMU_DEBUG opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN FILAMENT_LOAD_UNLOAD_GCODES \ PARK_HEAD_ON_PAUSE exec_test $1 $2 "BigTreeTech SKR 1.4 | MMU2" "$3" diff --git a/buildroot/tests/LPC1769 b/buildroot/tests/LPC1769 index f29bbb5656..5356d3e186 100755 --- a/buildroot/tests/LPC1769 +++ b/buildroot/tests/LPC1769 @@ -81,20 +81,20 @@ opt_set MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO SERIAL_PORT -1 \ SLOWDOWN_DIVISOR 16 SDCARD_CONNECTION ONBOARD BLOCK_BUFFER_SIZE 64 \ CHOPPER_TIMING CHOPPER_DEFAULT_24V MMU_SERIAL_PORT 0 \ Z_MIN_ENDSTOP_HIT_STATE HIGH -opt_enable PIDTEMPBED S_CURVE_ACCELERATION \ - USE_PROBE_FOR_Z_HOMING BLTOUCH FILAMENT_RUNOUT_SENSOR \ - AUTO_BED_LEVELING_BILINEAR RESTORE_LEVELING_AFTER_G28 \ - EXTRAPOLATE_BEYOND_GRID LCD_BED_LEVELING MESH_EDIT_MENU Z_SAFE_HOMING \ - EEPROM_SETTINGS EEPROM_AUTO_INIT NOZZLE_PARK_FEATURE SDSUPPORT \ - SPEAKER CR10_STOCKDISPLAY QUICK_HOME BLTOUCH_FORCE_SW_MODE \ - Z_STEPPER_AUTO_ALIGN INPUT_SHAPING_X INPUT_SHAPING_Y SHAPING_MENU \ - ADAPTIVE_STEP_SMOOTHING LCD_INFO_MENU STATUS_MESSAGE_SCROLLING \ +opt_enable PIDTEMPBED \ + FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE \ + BLTOUCH BLTOUCH_FORCE_SW_MODE USE_PROBE_FOR_Z_HOMING Z_SAFE_HOMING QUICK_HOME Z_STEPPER_AUTO_ALIGN \ + AUTO_BED_LEVELING_BILINEAR EXTRAPOLATE_BEYOND_GRID RESTORE_LEVELING_AFTER_G28 LCD_BED_LEVELING MESH_EDIT_MENU \ + EEPROM_SETTINGS EEPROM_AUTO_INIT \ + SDSUPPORT CR10_STOCKDISPLAY SPEAKER LCD_INFO_MENU STATUS_MESSAGE_SCROLLING \ + INPUT_SHAPING_X INPUT_SHAPING_Y SHAPING_MENU \ + BEZIER_CURVE_SUPPORT LIN_ADVANCE \ + TMC_DEBUG S_CURVE_ACCELERATION ADAPTIVE_STEP_SMOOTHING \ SET_PROGRESS_MANUALLY M73_REPORT SHOW_REMAINING_TIME \ PRINT_PROGRESS_SHOW_DECIMALS AUTO_REPORT_SD_STATUS USE_BIG_EDIT_FONT \ BABYSTEPPING BABYSTEP_WITHOUT_HOMING BABYSTEP_ALWAYS_AVAILABLE \ - DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_DISPLAY_TOTAL LIN_ADVANCE \ - BEZIER_CURVE_SUPPORT EMERGENCY_PARSER ADVANCED_PAUSE_FEATURE \ - TMC_DEBUG HOST_ACTION_COMMANDS HOST_PAUSE_M76 HOST_PROMPT_SUPPORT HOST_STATUS_NOTIFICATIONS \ + DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_DISPLAY_TOTAL \ + EMERGENCY_PARSER HOST_ACTION_COMMANDS HOST_PAUSE_M76 HOST_PROMPT_SUPPORT HOST_STATUS_NOTIFICATIONS \ MMU3_SPOOL_JOIN_CONSUMES_ALL_FILAMENT MMU_MENUS MMU_DEBUG opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN FILAMENT_LOAD_UNLOAD_GCODES PARK_HEAD_ON_PAUSE exec_test $1 $2 "BigTreeTech SKR 1.4 Turbo | MMU3" "$3" From 4b32be9df074df23ee084869af8a3ed3bd07c9f5 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sun, 20 Apr 2025 09:04:48 -0700 Subject: [PATCH 10/51] =?UTF-8?q?=F0=9F=94=A7=20Malyan=20M300=20/=20Monopr?= =?UTF-8?q?ice=20Mini=20alternate=20orientation=20(#27808)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f0/pins_MALYAN_M300.h | 44 ++++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h index 5bc8c5f74b..0a524e4952 100644 --- a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h +++ b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h @@ -46,9 +46,15 @@ // // Limit Switches // -#define X_STOP_PIN PC13 -#define Y_STOP_PIN PC14 -#define Z_STOP_PIN PC15 +#if ENABLED(M300_ROTATE_TOWERS) + #define X_STOP_PIN PC14 + #define Y_STOP_PIN PC15 + #define Z_STOP_PIN PC13 +#else + #define X_STOP_PIN PC13 + #define Y_STOP_PIN PC14 + #define Z_STOP_PIN PC15 +#endif #ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN PB7 @@ -57,17 +63,31 @@ // // Steppers // -#define X_STEP_PIN PB14 -#define X_DIR_PIN PB13 -#define X_ENABLE_PIN PB10 +#if ENABLED(M300_ROTATE_TOWERS) + #define X_STEP_PIN PB12 + #define X_DIR_PIN PB11 + #define X_ENABLE_PIN PB10 -#define Y_STEP_PIN PB12 -#define Y_DIR_PIN PB11 -#define Y_ENABLE_PIN PB10 + #define Y_STEP_PIN PB2 + #define Y_DIR_PIN PB1 + #define Y_ENABLE_PIN PB10 -#define Z_STEP_PIN PB2 -#define Z_DIR_PIN PB1 -#define Z_ENABLE_PIN PB10 + #define Z_STEP_PIN PB14 + #define Z_DIR_PIN PB13 + #define Z_ENABLE_PIN PB10 +#else + #define X_STEP_PIN PB14 + #define X_DIR_PIN PB13 + #define X_ENABLE_PIN PB10 + + #define Y_STEP_PIN PB12 + #define Y_DIR_PIN PB11 + #define Y_ENABLE_PIN PB10 + + #define Z_STEP_PIN PB2 + #define Z_DIR_PIN PB1 + #define Z_ENABLE_PIN PB10 +#endif #define E0_STEP_PIN PA7 #define E0_DIR_PIN PA6 From d3687d933ca029626865d8465ef5ea728a262296 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 20 Apr 2025 11:27:15 -0500 Subject: [PATCH 11/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20stepper/control.cpp=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals-5-post.h | 2 +- Marlin/src/module/settings.cpp | 2 +- Marlin/src/module/stepper.cpp | 12 ---- Marlin/src/module/stepper/control.cpp | 87 +++++++++++++++------------ 4 files changed, 51 insertions(+), 52 deletions(-) diff --git a/Marlin/src/inc/Conditionals-5-post.h b/Marlin/src/inc/Conditionals-5-post.h index 920031dcdb..fd06285bca 100644 --- a/Marlin/src/inc/Conditionals-5-post.h +++ b/Marlin/src/inc/Conditionals-5-post.h @@ -3012,7 +3012,7 @@ #undef MICROSTEP_MODES #endif -#if MB(PRINTRBOARD_G2) || ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MICROSTEPS) +#if ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MICROSTEPS) #define HAS_STEPPER_CONTROL 1 #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index feb433041e..8c99c54323 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -508,7 +508,7 @@ typedef struct SettingsDataStruct { #endif // - // HAS_MOTOR_CURRENT_PWM + // Stepper Motors Current // #ifndef MOTOR_CURRENT_COUNT #if HAS_MOTOR_CURRENT_PWM diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index cc042181c6..1d02620e6f 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -120,10 +120,6 @@ Stepper stepper; // Singleton #include "../feature/dac/dac_dac084s085.h" #endif -#if HAS_MOTOR_CURRENT_SPI - #include -#endif - #if ENABLED(MIXING_EXTRUDER) #include "../feature/mixing.h" #endif @@ -158,14 +154,6 @@ Stepper stepper; // Singleton bool Stepper::separate_multi_axis = false; #endif -#if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM - bool Stepper::initialized; // = false - uint32_t Stepper::motor_current_setting[MOTOR_CURRENT_COUNT]; // Initialized by settings.load - #if HAS_MOTOR_CURRENT_SPI - constexpr uint32_t Stepper::digipot_count[]; - #endif -#endif - stepper_flags_t Stepper::axis_enabled; // {0} // private: diff --git a/Marlin/src/module/stepper/control.cpp b/Marlin/src/module/stepper/control.cpp index 0d523c8ed5..4d4b6b351f 100644 --- a/Marlin/src/module/stepper/control.cpp +++ b/Marlin/src/module/stepper/control.cpp @@ -30,14 +30,24 @@ #if MB(PRINTRBOARD_G2) #include HAL_PATH(../.., fastio/G2_PWM.h) +#elif HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + #define HAS_NON_G2_MOTOR_CURRENT 1 +#endif + +#if HAS_MOTOR_CURRENT_PWM || HAS_NON_G2_MOTOR_CURRENT + bool Stepper::initialized; // = false + uint32_t Stepper::motor_current_setting[MOTOR_CURRENT_COUNT]; // Initialized by settings.load #endif /** - * Software-controlled Stepper Motor Current + * SPI-controlled Stepper Motor Current */ #if HAS_MOTOR_CURRENT_SPI + #include + constexpr uint32_t Stepper::digipot_count[]; + // From Arduino DigitalPotControl example void Stepper::set_digipot_value_spi(const int16_t address, const int16_t value) { WRITE(DIGIPOTSS_PIN, LOW); // Take the SS pin low to select the chip @@ -47,8 +57,36 @@ //delay(10); } + #if HAS_NON_G2_MOTOR_CURRENT + + void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { + if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1)) + motor_current_setting[driver] = current; // update motor_current_setting + + if (!initialized) return; + + //SERIAL_ECHOLNPGM("Digipotss current ", current); + + const uint8_t digipot_ch[] = DIGIPOT_CHANNELS; + set_digipot_value_spi(digipot_ch[driver], current); + } + + void Stepper::digipot_init() { + SPI.begin(); + SET_OUTPUT(DIGIPOTSS_PIN); + + for (uint8_t i = 0; i < COUNT(motor_current_setting); ++i) + set_digipot_current(i, motor_current_setting[i]); + } + + #endif // HAS_NON_G2_MOTOR_CURRENT + #endif // HAS_MOTOR_CURRENT_SPI +/** + * PWM-controlled Stepper Motor Current + */ + #if HAS_MOTOR_CURRENT_PWM void Stepper::refresh_motor_power() { @@ -70,28 +108,13 @@ } } -#endif // HAS_MOTOR_CURRENT_PWM + #if HAS_NON_G2_MOTOR_CURRENT -/** - * PWM-controlled Stepper Motor Current - */ + void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { + if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1)) + motor_current_setting[driver] = current; // update motor_current_setting -#if !MB(PRINTRBOARD_G2) && (HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM) - - void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { - if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1)) - motor_current_setting[driver] = current; // update motor_current_setting - - if (!initialized) return; - - #if HAS_MOTOR_CURRENT_SPI - - //SERIAL_ECHOLNPGM("Digipotss current ", current); - - const uint8_t digipot_ch[] = DIGIPOT_CHANNELS; - set_digipot_value_spi(digipot_ch[driver], current); - - #elif HAS_MOTOR_CURRENT_PWM + if (!initialized) return; #define _WRITE_CURRENT_PWM(P) hal.set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) switch (driver) { @@ -141,21 +164,9 @@ #endif break; } - #endif - } - - void Stepper::digipot_init() { - - #if HAS_MOTOR_CURRENT_SPI - - SPI.begin(); - SET_OUTPUT(DIGIPOTSS_PIN); - - for (uint8_t i = 0; i < COUNT(motor_current_setting); ++i) - set_digipot_current(i, motor_current_setting[i]); - - #elif HAS_MOTOR_CURRENT_PWM + } + void Stepper::digipot_init() { #ifdef __SAM3X8E__ #define _RESET_CURRENT_PWM_FREQ(P) NOOP #else @@ -204,11 +215,11 @@ #endif refresh_motor_power(); + } - #endif - } + #endif // HAS_NON_G2_MOTOR_CURRENT -#endif +#endif // HAS_MOTOR_CURRENT_PWM /** * Software-controlled Microstepping with digital pins From b23f86f83f6ff5f2e8fcedc4203ca081cbc58596 Mon Sep 17 00:00:00 2001 From: B Date: Sun, 20 Apr 2025 10:12:02 -0700 Subject: [PATCH 12/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20GD32?= =?UTF-8?q?=20fast=20write=20non-bool=20(#27806)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/GD32_MFL/fastio.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/GD32_MFL/fastio.h b/Marlin/src/HAL/GD32_MFL/fastio.h index 8185be73a4..35bd2b1ef7 100644 --- a/Marlin/src/HAL/GD32_MFL/fastio.h +++ b/Marlin/src/HAL/GD32_MFL/fastio.h @@ -27,9 +27,12 @@ #include #include -static inline void fast_write_pin_wrapper(pin_size_t IO, bool V) { - if (V) gpio::fast_set_pin(getPortFromPin(IO), getPinInPort(IO)); - else gpio::fast_clear_pin(getPortFromPin(IO), getPinInPort(IO)); +template +static inline void fast_write_pin_wrapper(pin_size_t IO, T V) { + auto port = getPortFromPin(IO); + auto pin = getPinInPort(IO); + if (static_cast(V)) gpio::fast_set_pin(port, pin); + else gpio::fast_clear_pin(port, pin); } static inline bool fast_read_pin_wrapper(pin_size_t IO) { From d434729da6ea38295fed76a23603767439b22e06 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 20 Apr 2025 19:25:12 -0500 Subject: [PATCH 13/51] =?UTF-8?q?=F0=9F=90=9B=F0=9F=94=A7=20Move=20extra?= =?UTF-8?q?=20volume=20flags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals-2-LCD.h | 6 ------ Marlin/src/inc/Conditionals-4-adv.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/src/inc/Conditionals-2-LCD.h b/Marlin/src/inc/Conditionals-2-LCD.h index 633cd2beb6..2bf663b6f0 100644 --- a/Marlin/src/inc/Conditionals-2-LCD.h +++ b/Marlin/src/inc/Conditionals-2-LCD.h @@ -36,12 +36,6 @@ #if ENABLED(SDSUPPORT) #define HAS_MEDIA 1 #endif -#if ENABLED(MULTI_VOLUME) - #define HAS_MULTI_VOLUME 1 -#endif -#if ENABLED(USB_FLASH_DRIVE_SUPPORT) - #define HAS_USB_FLASH_DRIVE 1 -#endif // // Serial Port Info diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index ca096c7661..3b01077931 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -1246,8 +1246,14 @@ #define HOMING_BUMP_MM { 0, 0, 0 } #endif -#if HAS_USB_FLASH_DRIVE && NONE(USE_OTG_USB_HOST, USE_UHS3_USB) - #define USE_UHS2_USB +#if ENABLED(MULTI_VOLUME) + #define HAS_MULTI_VOLUME 1 +#endif +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #define HAS_USB_FLASH_DRIVE 1 + #if NONE(USE_OTG_USB_HOST, USE_UHS3_USB) + #define USE_UHS2_USB + #endif #endif /** From 1e009c2aa5f3ca5c7d5671f28dec333b9a2f3686 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 21 Apr 2025 00:32:59 +0000 Subject: [PATCH 14/51] [cron] Bump distribution date (2025-04-21) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 85663d4899..50361ebc03 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 "2025-04-20" +//#define STRING_DISTRIBUTION_DATE "2025-04-21" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index f46988c11b..2462ecd50c 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 "2025-04-20" + #define STRING_DISTRIBUTION_DATE "2025-04-21" #endif /** From 24928f93bac5694daf00827316419cd224781fb0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 21 Apr 2025 19:59:41 -0500 Subject: [PATCH 15/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20FastI?= =?UTF-8?q?O=20AT90USB=20pins=2046-47?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h | 12 ++++++------ Marlin/src/HAL/AVR/pinsDebug.h | 8 ++++---- Marlin/src/gcode/config/M43.cpp | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h b/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h index 2119d168ab..a9af519ff3 100644 --- a/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h +++ b/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h @@ -363,8 +363,11 @@ #define AIO7_PWM 0 #define AIO7_DDR DDRF -//-- Begin not supported by Teensyduino -//-- don't use Arduino functions on these pins pinMode/digitalWrite/etc +//-- 46-47 are not supported by Teensyduino +//-- Don't use Arduino functions (pinMode, digitalWrite, etc.) on these pins +#define PIN_E2 46 +#define PIN_E3 47 + #define DIO46_PIN PINE2 #define DIO46_RPORT PINE #define DIO46_WPORT PORTE @@ -377,10 +380,7 @@ #define DIO47_PWM 0 #define DIO47_DDR DDRE -#define TEENSY_E2 46 -#define TEENSY_E3 47 - -//-- end not supported by Teensyduino +//-- #undef PA0 #define PA0_PIN PINA0 diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index e9bc09a4bf..c833964a29 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -377,16 +377,16 @@ void printPinPort(const pin_t pin) { // print port number uint8_t x; SERIAL_ECHOPGM(" Port: "); #if AVR_AT90USB1286_FAMILY - x = (pin == 46 || pin == 47) ? 'E' : digitalPinToPort_DEBUG(pin) + 64; + x = (pin == PIN_E2 || pin == PIN_E3) ? 'E' : 'A' + digitalPinToPort_DEBUG(pin) - 1; #else - x = digitalPinToPort_DEBUG(pin) + 64; + x = 'A' + digitalPinToPort_DEBUG(pin) - 1; #endif SERIAL_CHAR(x); #if AVR_AT90USB1286_FAMILY - if (pin == 46) + if (pin == PIN_E2) x = '2'; - else if (pin == 47) + else if (pin == PIN_E3) x = '3'; else { uint8_t temp = digitalPinToBitMask_DEBUG(pin); diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 893607792a..a515acb241 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -79,20 +79,20 @@ inline void toggle_pins() { #endif ); #if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO - if (pin == TEENSY_E2) { - SET_OUTPUT(TEENSY_E2); + if (pin == PIN_E2) { + SET_OUTPUT(PIN_E2); for (int16_t j = 0; j < repeat; j++) { - WRITE(TEENSY_E2, LOW); safe_delay(wait); - WRITE(TEENSY_E2, HIGH); safe_delay(wait); - WRITE(TEENSY_E2, LOW); safe_delay(wait); + WRITE(PIN_E2, LOW); safe_delay(wait); + WRITE(PIN_E2, HIGH); safe_delay(wait); + WRITE(PIN_E2, LOW); safe_delay(wait); } } - else if (pin == TEENSY_E3) { - SET_OUTPUT(TEENSY_E3); + else if (pin == PIN_E3) { + SET_OUTPUT(PIN_E3); for (int16_t j = 0; j < repeat; j++) { - WRITE(TEENSY_E3, LOW); safe_delay(wait); - WRITE(TEENSY_E3, HIGH); safe_delay(wait); - WRITE(TEENSY_E3, LOW); safe_delay(wait); + WRITE(PIN_E3, LOW); safe_delay(wait); + WRITE(PIN_E3, HIGH); safe_delay(wait); + WRITE(PIN_E3, LOW); safe_delay(wait); } } else From db3c5dd877fb41e2cd03ca3ff02c50e4f2bfcbbd Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 22 Apr 2025 06:09:47 +0000 Subject: [PATCH 16/51] [cron] Bump distribution date (2025-04-22) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 50361ebc03..59bbef9fda 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 "2025-04-21" +//#define STRING_DISTRIBUTION_DATE "2025-04-22" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 2462ecd50c..82956a1451 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 "2025-04-21" + #define STRING_DISTRIBUTION_DATE "2025-04-22" #endif /** From 9a901941aa118e88dcbbf3177e7d54495f34d909 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Tue, 22 Apr 2025 13:01:14 -0400 Subject: [PATCH 17/51] =?UTF-8?q?=F0=9F=90=9B=20Watchdog=20Reset=20PIO=20o?= =?UTF-8?q?n=20DUE=20to=20prevent=20hang=20(#27803)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/HAL/DUE/HAL.cpp | 23 ++++++++------ Marlin/src/pins/pins.h | 30 +++++++++---------- .../PlatformIO/boards/marlin_archim.json | 2 +- ini/due.ini | 10 ++----- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp index d1db9148c4..9b3cf1a516 100644 --- a/Marlin/src/HAL/DUE/HAL.cpp +++ b/Marlin/src/HAL/DUE/HAL.cpp @@ -102,6 +102,10 @@ void watchdogSetup() { #if ENABLED(USE_WATCHDOG) + #ifndef WATCHDOG_PIO_RESET + #define WATCHDOG_PIO_RESET + #endif + // 4 seconds timeout uint32_t timeout = TERN(WATCHDOG_DURATION_8S, 8000, 4000); @@ -115,15 +119,16 @@ void watchdogSetup() { timeout = 0xFFF; // We want to enable the watchdog with the specified timeout - uint32_t value = - WDT_MR_WDV(timeout) | // With the specified timeout - WDT_MR_WDD(timeout) | // and no invalid write window - #if !(SAMV70 || SAMV71 || SAME70 || SAMS70) - WDT_MR_WDRPROC | // WDT fault resets processor only - We want - // to keep PIO controller state - #endif - WDT_MR_WDDBGHLT | // WDT stops in debug state. - WDT_MR_WDIDLEHLT; // WDT stops in idle state. + uint32_t value = (0 + | WDT_MR_WDV(timeout) // With the specified timeout + | WDT_MR_WDD(timeout) // and no invalid write window + #if NONE(WATCHDOG_PIO_RESET, SAMV70, SAMV71, SAME70, SAMS70) + | WDT_MR_WDRPROC // WDT fault resets processor only with this flag. + // Omit to also reset the PIO controller. + #endif + | WDT_MR_WDDBGHLT // WDT stops in debug state. + | WDT_MR_WDIDLEHLT // WDT stops in idle state. + ); #if ENABLED(WATCHDOG_RESET_MANUAL) // We enable the watchdog timer, but only for the interrupt. diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index dcb8415de8..8c974cce48 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -516,33 +516,33 @@ // #elif MB(DUE3DOM) - #include "sam/pins_DUE3DOM.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_DUE3DOM.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(DUE3DOM_MINI) - #include "sam/pins_DUE3DOM_MINI.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_DUE3DOM_MINI.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(RADDS) - #include "sam/pins_RADDS.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_RADDS.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(RAMPS_FD_V1) - #include "sam/pins_RAMPS_FD_V1.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_RAMPS_FD_V1.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(RAMPS_FD_V2) - #include "sam/pins_RAMPS_FD_V2.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_RAMPS_FD_V2.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(RAMPS_SMART_EFB, RAMPS_SMART_EEB, RAMPS_SMART_EFF, RAMPS_SMART_EEF, RAMPS_SMART_SF) - #include "sam/pins_RAMPS_SMART.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_RAMPS_SMART.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(RAMPS_DUO_EFB, RAMPS_DUO_EEB, RAMPS_DUO_EFF, RAMPS_DUO_EEF, RAMPS_DUO_SF) - #include "sam/pins_RAMPS_DUO.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_RAMPS_DUO.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(RAMPS4DUE_EFB, RAMPS4DUE_EEB, RAMPS4DUE_EFF, RAMPS4DUE_EEF, RAMPS4DUE_SF) - #include "sam/pins_RAMPS4DUE.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_RAMPS4DUE.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(RURAMPS4D_11) - #include "sam/pins_RURAMPS4D_11.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_RURAMPS4D_11.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(RURAMPS4D_13) - #include "sam/pins_RURAMPS4D_13.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug + #include "sam/pins_RURAMPS4D_13.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(ULTRATRONICS_PRO) - #include "sam/pins_ULTRATRONICS_PRO.h" // SAM3X8E env:DUE env:DUE_debug + #include "sam/pins_ULTRATRONICS_PRO.h" // SAM3X8E env:DUE #elif MB(ARCHIM1) - #include "sam/pins_ARCHIM1.h" // SAM3X8E env:DUE_archim env:DUE_archim_debug + #include "sam/pins_ARCHIM1.h" // SAM3X8E env:DUE_archim #elif MB(ARCHIM2) - #include "sam/pins_ARCHIM2.h" // SAM3X8E env:DUE_archim env:DUE_archim_debug + #include "sam/pins_ARCHIM2.h" // SAM3X8E env:DUE_archim #elif MB(ALLIGATOR) - #include "sam/pins_ALLIGATOR_R2.h" // SAM3X8E env:DUE env:DUE_debug + #include "sam/pins_ALLIGATOR_R2.h" // SAM3X8E env:DUE #elif MB(CNCONTROLS_15D) #include "sam/pins_CNCONTROLS_15D.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(KRATOS32) @@ -555,7 +555,7 @@ #elif MB(PRINTRBOARD_G2) #include "sam/pins_PRINTRBOARD_G2.h" // SAM3X8C env:DUE_USB #elif MB(ADSK) - #include "sam/pins_ADSK.h" // SAM3X8C env:DUE env:DUE_debug + #include "sam/pins_ADSK.h" // SAM3X8C env:DUE // // STM32 ARM Cortex-M0+ diff --git a/buildroot/share/PlatformIO/boards/marlin_archim.json b/buildroot/share/PlatformIO/boards/marlin_archim.json index 6d78c1f195..ee2ebd62ad 100644 --- a/buildroot/share/PlatformIO/boards/marlin_archim.json +++ b/buildroot/share/PlatformIO/boards/marlin_archim.json @@ -2,7 +2,7 @@ "build": { "core": "arduino", "cpu": "cortex-m3", - "extra_flags": "-D__SAM3X8E__ -DARDUINO_ARCH_SAM -DARDUINO_SAM_DUE", + "extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_SAM_ARCHIM", "f_cpu": "84000000L", "hwids": [ [ diff --git a/ini/due.ini b/ini/due.ini index c1e2375d7c..7e4017e257 100644 --- a/ini/due.ini +++ b/ini/due.ini @@ -19,6 +19,7 @@ platform = atmelsam board = due build_src_filter = ${common.default_src_filter} + + +build_flags = -DWATCHDOG_PIO_RESET [env:DUE_USB] extends = env:DUE @@ -27,14 +28,9 @@ board = dueUSB # # Archim SAM # -[common_DUE_archim] +[env:DUE_archim] extends = env:DUE board = marlin_archim -build_flags = ${common.build_flags} - -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSBCON board_build.variants_dir = buildroot/share/PlatformIO/variants/ extra_scripts = ${common.extra_scripts} - Marlin/src/HAL/DUE/upload_extra_script.py - -[env:DUE_archim] -extends = common_DUE_archim + Marlin/src/HAL/DUE/upload_extra_script.py From 28a1355f293d568e6f1ca70a0b63153bb1d5664b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Apr 2025 15:12:13 -0500 Subject: [PATCH 18/51] =?UTF-8?q?=F0=9F=8C=90=20Fix=20extra=20MSG=5FATTACH?= =?UTF-8?q?=5FUSB=5FMEDIA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_ru.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index 991fd638ef..42e1656a8b 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -437,7 +437,7 @@ namespace LanguageNarrow_ru { LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Выгрузить всё"); #if HAS_MULTI_VOLUME LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Установить SD карту"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Установить флешка"); + LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Монтировать USB"); // Установить флешка #else LSTR MSG_ATTACH_MEDIA = _UxGT("Установить SD карту"); #endif @@ -766,7 +766,6 @@ namespace LanguageNarrow_ru { LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Вытирание при откате"); LSTR MSG_PARK_FAILED = _UxGT("Не удалось запарковать"); LSTR MSG_FILAMENTUNLOAD = _UxGT("Выгрузить филамент"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Монтировать USB"); LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("Высокая скорость"); LSTR MSG_MANUAL_PENUP = _UxGT("Поднять перо"); LSTR MSG_MANUAL_PENDOWN = _UxGT("Опустить перо"); From 4b419eefd2b35bd08df928481053ca45a3bf992d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Apr 2025 17:41:59 -0500 Subject: [PATCH 19/51] =?UTF-8?q?=F0=9F=94=A5=20DEFAULT=5FVOLUME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 9d291f6219..b1ad8d9629 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1960,7 +1960,6 @@ #if ENABLED(MULTI_VOLUME) #define VOLUME_SD_ONBOARD #define VOLUME_USB_FLASH_DRIVE - #define DEFAULT_VOLUME SV_SD_ONBOARD #define DEFAULT_SHARED_VOLUME SV_USB_FLASH_DRIVE #endif From 21dadce958f993b1e33e94a7e160f2926ecd2177 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 23 Apr 2025 00:30:30 +0000 Subject: [PATCH 20/51] [cron] Bump distribution date (2025-04-23) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 59bbef9fda..e9c1d9ba1b 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 "2025-04-22" +//#define STRING_DISTRIBUTION_DATE "2025-04-23" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 82956a1451..d06c53dd5e 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 "2025-04-22" + #define STRING_DISTRIBUTION_DATE "2025-04-23" #endif /** From efd875766a7e443e2078d70c44c05b3947316c3b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Apr 2025 19:10:27 -0500 Subject: [PATCH 21/51] =?UTF-8?q?=F0=9F=9A=B8=20"Inverted"=20text=20on=20G?= =?UTF-8?q?LCD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/tft/themes/theme_ANET_BLACK.h | 1 + Marlin/src/lcd/tft/themes/theme_BLUE_MARLIN.h | 5 ++++- Marlin/src/lcd/tft/themes/theme_default.h | 3 +++ Marlin/src/lcd/tft/ui_common.cpp | 8 +++++--- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/tft/themes/theme_ANET_BLACK.h b/Marlin/src/lcd/tft/themes/theme_ANET_BLACK.h index d6a7bab671..67db585435 100644 --- a/Marlin/src/lcd/tft/themes/theme_ANET_BLACK.h +++ b/Marlin/src/lcd/tft/themes/theme_ANET_BLACK.h @@ -47,6 +47,7 @@ #define COLOR_SD_DISABLED COLOR_CONTROL_DISABLED #define COLOR_MENU_TEXT COLOR_WHITE #define COLOR_MENU_STATIC_TEXT COLOR_WHITE +#define COLOR_MENU_INVERT_TEXT COLOR_YELLOW #define COLOR_MENU_BACK_TEXT COLOR_YELLOW #define COLOR_MENU_EDIT_TEXT COLOR_LIME2 #define COLOR_MENU_VALUE_FONT COLOR_ORANGE2 diff --git a/Marlin/src/lcd/tft/themes/theme_BLUE_MARLIN.h b/Marlin/src/lcd/tft/themes/theme_BLUE_MARLIN.h index 7414a7f250..bbc3b6671f 100644 --- a/Marlin/src/lcd/tft/themes/theme_BLUE_MARLIN.h +++ b/Marlin/src/lcd/tft/themes/theme_BLUE_MARLIN.h @@ -106,9 +106,12 @@ #ifndef COLOR_MENU_TEXT #define COLOR_MENU_TEXT COLOR_YELLOW #endif -#ifndef COLOR_MENU_TEXT +#ifndef COLOR_MENU_STATIC_TEXT #define COLOR_MENU_STATIC_TEXT COLOR_SILVER #endif +#ifndef COLOR_MENU_INVERT_TEXT + #define COLOR_MENU_INVERT_TEXT COLOR_WHITE +#endif #ifndef COLOR_MENU_BACK_TEXT #define COLOR_MENU_BACK_TEXT COLOR_CYAN #endif diff --git a/Marlin/src/lcd/tft/themes/theme_default.h b/Marlin/src/lcd/tft/themes/theme_default.h index 17790c7557..6b7e789216 100644 --- a/Marlin/src/lcd/tft/themes/theme_default.h +++ b/Marlin/src/lcd/tft/themes/theme_default.h @@ -107,6 +107,9 @@ #ifndef COLOR_MENU_STATIC_TEXT #define COLOR_MENU_STATIC_TEXT COLOR_SILVER #endif +#ifndef COLOR_MENU_INVERT_TEXT + #define COLOR_MENU_INVERT_TEXT COLOR_WHITE +#endif #ifndef COLOR_MENU_BACK_TEXT #define COLOR_MENU_BACK_TEXT COLOR_WHITE #endif diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index 6d59e0ce8b..b16b3e80a0 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -390,10 +390,12 @@ void MenuItem_static::draw(const uint8_t row, FSTR_P const ftpl, const uint8_t s else tft_string.set(); + const uint16_t color = (style & SS_INVERT) ? COLOR_MENU_INVERT_TEXT : COLOR_MENU_STATIC_TEXT; + const bool center = bool(style & SS_CENTER), full = bool(style & SS_FULL); if (!full || !vstr) { if (vstr) tft_string.add(vstr); - tft.add_text(center ? tft_string.center(TFT_WIDTH) : 0, MENU_TEXT_Y, COLOR_MENU_STATIC_TEXT, tft_string); + tft.add_text(center ? tft_string.center(TFT_WIDTH) : 0, MENU_TEXT_Y, color, tft_string); return; } @@ -401,12 +403,12 @@ void MenuItem_static::draw(const uint8_t row, FSTR_P const ftpl, const uint8_t s if (*vstr == ':') { tft_string.add(':'); vstr++; } // Left-justified label - tft.add_text(0, MENU_TEXT_Y, COLOR_MENU_STATIC_TEXT, tft_string); + tft.add_text(0, MENU_TEXT_Y, color, tft_string); // Right-justified value, after spaces while (*vstr == ' ') vstr++; tft_string.set(vstr); - tft.add_text(TFT_WIDTH - 1 - tft_string.width(), MENU_TEXT_Y, COLOR_MENU_STATIC_TEXT, tft_string); + tft.add_text(TFT_WIDTH - 1 - tft_string.width(), MENU_TEXT_Y, color, tft_string); } #if HAS_MEDIA From 3696cc351313dce38213630435c3e45753391223 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Apr 2025 19:11:30 -0500 Subject: [PATCH 22/51] =?UTF-8?q?=F0=9F=9A=B8=20Clear=20alert=20on=20menu?= =?UTF-8?q?=20click?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 96e6f6d073..6e22dfa23e 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -203,6 +203,15 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co } #endif + // + // Clear alerts when exiting the Status Screen to the Main Menu + // + + if (currentScreen == status_screen && screen == menu_main) { + reset_alert_level(); + reset_status(); + } + // // Go to the new screen // From 7ee745b2da37b04cbd30ca01538acc37021efe09 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Apr 2025 12:57:30 -0500 Subject: [PATCH 23/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20TFT?= =?UTF-8?q?=20GLCD=20"panel=5Fdetected"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 96 ++++++++++----------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 6a80044a34..6766820cfd 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -135,7 +135,7 @@ static unsigned char framebuffer[FBSIZE]; static unsigned char *fb; static uint8_t cour_line; static uint8_t picBits, ledBits, hotBits; -static uint8_t PanelDetected = 0; +static bool panel_detected = false; // Different platforms use different SPI methods #if ANY(__AVR__, TARGET_LPC1768, __STM32F1__, ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__) @@ -169,13 +169,13 @@ void TFTGLCD::clear_buffer() { // Clear panel's screen void TFTGLCD::clr_screen() { - if (!PanelDetected) return; + if (!panel_detected) return; #if ENABLED(TFTGLCD_PANEL_SPI) WRITE(TFTGLCD_CS, LOW); SPI_SEND_ONE(CLR_SCREEN); WRITE(TFTGLCD_CS, HIGH); #else - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); //set I2C device address + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); //set I2C device address Wire.write(CLR_SCREEN); Wire.endTransmission(); //transmit data #endif @@ -199,7 +199,7 @@ void TFTGLCD::print(const char *line) { // For menu void TFTGLCD::print_line() { - if (!PanelDetected) return; + if (!panel_detected) return; #if ENABLED(TFTGLCD_PANEL_SPI) WRITE(TFTGLCD_CS, LOW); SPI_SEND_ONE(LCD_PUT); @@ -207,7 +207,7 @@ void TFTGLCD::print_line() { SPI_SEND_SOME(framebuffer, LCD_WIDTH, cour_line * LCD_WIDTH); WRITE(TFTGLCD_CS, HIGH); #else - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); //set I2C device address + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); //set I2C device address Wire.write(LCD_PUT); Wire.write(cour_line); Wire.write(&framebuffer[cour_line * LCD_WIDTH], LCD_WIDTH); //transfer 1 line to txBuffer @@ -217,7 +217,7 @@ void TFTGLCD::print_line() { } void TFTGLCD::print_screen() { - if (!PanelDetected) return; + if (!panel_detected) return; framebuffer[FBSIZE - 2] = picBits & PIC_MASK; framebuffer[FBSIZE - 1] = ledBits; #if ENABLED(TFTGLCD_PANEL_SPI) @@ -229,18 +229,18 @@ void TFTGLCD::print_screen() { #else uint8_t r; // Send framebuffer to panel by line - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); // First line Wire.write(LCD_WRITE); Wire.write(&framebuffer[0], LCD_WIDTH); Wire.endTransmission(); for (r = 1; r < (LCD_HEIGHT - 1); r++) { - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); Wire.write(&framebuffer[r * LCD_WIDTH], LCD_WIDTH); Wire.endTransmission(); } // Last line - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); Wire.write(&framebuffer[r * LCD_WIDTH], LCD_WIDTH); Wire.write(&framebuffer[FBSIZE - 2], 2); Wire.endTransmission(); @@ -248,14 +248,14 @@ void TFTGLCD::print_screen() { } void TFTGLCD::setContrast(uint16_t contrast) { - if (!PanelDetected) return; + if (!panel_detected) return; #if ENABLED(TFTGLCD_PANEL_SPI) WRITE(TFTGLCD_CS, LOW); SPI_SEND_ONE(CONTRAST); SPI_SEND_ONE((uint8_t)contrast); WRITE(TFTGLCD_CS, HIGH); #else - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); Wire.write(CONTRAST); Wire.write((uint8_t)contrast); Wire.endTransmission(); @@ -266,7 +266,7 @@ extern volatile int8_t encoderDiff; // Read buttons and encoder states uint8_t MarlinUI::read_slow_buttons() { - if (!PanelDetected) return 0; + if (!panel_detected) return 0; #if ENABLED(TFTGLCD_PANEL_SPI) uint8_t b = 0; WRITE(TFTGLCD_CS, LOW); @@ -283,13 +283,13 @@ uint8_t MarlinUI::read_slow_buttons() { WRITE(TFTGLCD_CS, HIGH); return b; #else - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); Wire.write(READ_ENCODER); Wire.endTransmission(); #ifdef __AVR__ - Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, 2, 0, 0, 1); + Wire.requestFrom(uint8_t(LCD_I2C_ADDRESS), 2, 0, 0, 1); #elif defined(STM32F1) - Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, (uint8_t)2); + Wire.requestFrom(uint8_t(LCD_I2C_ADDRESS), uint8_t(2)); #elif ANY(STM32F4xx, TARGET_LPC1768) Wire.requestFrom(LCD_I2C_ADDRESS, 2); #endif @@ -300,7 +300,7 @@ uint8_t MarlinUI::read_slow_buttons() { // Duration in ms, freq in Hz void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) { - if (!PanelDetected) return; + if (!panel_detected) return; if (!sound_on) return; #if ENABLED(TFTGLCD_PANEL_SPI) WRITE(TFTGLCD_CS, LOW); @@ -309,20 +309,19 @@ void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) { SPI_SEND_TWO(freq); WRITE(TFTGLCD_CS, HIGH); #else - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); Wire.write(BUZZER); - Wire.write((uint8_t)(duration >> 8)); - Wire.write((uint8_t)duration); - Wire.write((uint8_t)(freq >> 8)); - Wire.write((uint8_t)freq); + Wire.write(uint8_t(duration >> 8)); + Wire.write(uint8_t(duration)); + Wire.write(uint8_t(freq >> 8)); + Wire.write(uint8_t(freq)); Wire.endTransmission(); #endif } void MarlinUI::init_lcd() { - uint8_t t; lcd.clear_buffer(); - t = 0; + uint8_t t = 0; #if ENABLED(TFTGLCD_PANEL_SPI) // SPI speed must be less 10MHz SET_OUTPUT(TFTGLCD_CS); @@ -335,43 +334,40 @@ void MarlinUI::init_lcd() { #ifdef TARGET_LPC1768 Wire.begin(); //init twi/I2C #else - Wire.begin((uint8_t)LCD_I2C_ADDRESS); //init twi/I2C + Wire.begin(uint8_t(LCD_I2C_ADDRESS)); //init twi/I2C #endif - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); - Wire.write((uint8_t)GET_LCD_ROW); // put command to buffer + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); + Wire.write(uint8_t(GET_LCD_ROW)); // put command to buffer Wire.endTransmission(); // send buffer #ifdef __AVR__ - Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, 1, 0, 0, 1); + Wire.requestFrom(uint8_t(LCD_I2C_ADDRESS), 1, 0, 0, 1); #elif ANY(STM32F1, STM32F4xx, TARGET_LPC1768) Wire.requestFrom(LCD_I2C_ADDRESS, 1); #endif t = (uint8_t)Wire.read(); #endif - if (t == LCD_HEIGHT) { - PanelDetected = 1; + panel_detected = (t == LCD_HEIGHT); + + if (panel_detected) { #if ENABLED(TFTGLCD_PANEL_SPI) SPI_SEND_ONE(INIT_SCREEN); SPI_SEND_ONE(Marlin); WRITE(TFTGLCD_CS, HIGH); #else - Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS); - Wire.write((uint8_t)INIT_SCREEN); + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); + Wire.write(uint8_t(INIT_SCREEN)); Wire.write(Marlin); Wire.endTransmission(); #endif } - else - PanelDetected = 0; safe_delay(100); } -bool MarlinUI::detected() { - return PanelDetected; -} +bool MarlinUI::detected() { return panel_detected; } void MarlinUI::clear_lcd() { - if (!PanelDetected) return; + if (!panel_detected) return; lcd.clr_screen(); lcd.clear_buffer(); } @@ -395,7 +391,7 @@ static void center_text(FSTR_P const fstart, const uint8_t y) { #if ENABLED(SHOW_BOOTSCREEN) void MarlinUI::show_bootscreen() { - if (!PanelDetected) return; + if (!panel_detected) return; // // Show the Marlin logo, splash line1, and splash line 2 // @@ -418,7 +414,7 @@ static void center_text(FSTR_P const fstart, const uint8_t y) { #endif // SHOW_BOOTSCREEN void MarlinUI::draw_kill_screen() { - if (!PanelDetected) return; + if (!panel_detected) return; lcd.clear_buffer(); lcd_moveto(0, 3); lcd.write(COLOR_ERROR); lcd_moveto((LCD_WIDTH - status_message.glyphs()) / 2 + 1, 3); @@ -655,7 +651,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if ENABLED(LCD_PROGRESS_BAR) void MarlinUI::draw_progress_bar(const uint8_t percent) { - if (!PanelDetected) return; + if (!panel_detected) return; if (fb == &framebuffer[0] + LCD_WIDTH * 2) { // For status screen lcd.write('%'); lcd.write(percent); } @@ -672,7 +668,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #endif // LCD_PROGRESS_BAR void MarlinUI::draw_status_message(const bool blink) { - if (!PanelDetected) return; + if (!panel_detected) return; lcd_moveto(0, 3); #if ALL(FILAMENT_LCD_DISPLAY, HAS_MEDIA) @@ -812,7 +808,7 @@ Equal to 24x10 text LCD */ void MarlinUI::draw_status_screen() { - if (!PanelDetected) return; + if (!panel_detected) return; const bool blink = get_blink(); @@ -959,7 +955,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(ADVANCED_PAUSE_FEATURE) void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) { - if (!PanelDetected) return; + if (!panel_detected) return; lcd_moveto((LCD_WIDTH - 14) / 2, row + 1); lcd.write(LCD_STR_THERMOMETER[0]); lcd_put_u8str(F(" E")); lcd.write('1' + extruder); lcd.write(' '); lcd.print(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.write('/'); @@ -971,7 +967,7 @@ void MarlinUI::draw_status_screen() { // Draw a static item with no left-right margin required. Centered by default. void MenuItem_static::draw(const uint8_t row, FSTR_P const ftpl, const uint8_t style/*=SS_DEFAULT*/, const char *vstr/*=nullptr*/) { - if (!PanelDetected) return; + if (!panel_detected) return; lcd_moveto(0, row); uint8_t n = LCD_WIDTH; @@ -1019,7 +1015,7 @@ void MarlinUI::draw_status_screen() { // Draw a generic menu item with pre_char (if selected) and post_char void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char pre_char, const char post_char) { - if (!PanelDetected) return; + if (!panel_detected) return; lcd_moveto(0, row); lcd.write(sel ? pre_char : ' '); uint8_t n = LCD_WIDTH - 2; @@ -1031,7 +1027,7 @@ void MarlinUI::draw_status_screen() { // Draw a menu item with a (potentially) editable value void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) { - if (!PanelDetected) return; + if (!panel_detected) return; const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)) : 0; lcd_moveto(0, row); lcd.write(sel ? LCD_STR_ARROW_RIGHT[0] : ' '); @@ -1048,7 +1044,7 @@ void MarlinUI::draw_status_screen() { // Low-level draw_edit_screen can be used to draw an edit screen from anyplace // This line moves to the last line of the screen for UBL plot screen on the panel side void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const value/*=nullptr*/) { - if (!PanelDetected) return; + if (!panel_detected) return; ui.encoder_direction_normal(); const uint8_t y = TERN0(AUTO_BED_LEVELING_UBL, ui.external_control) ? LCD_HEIGHT - 1 : MIDDLE_Y; lcd_moveto(0, y); @@ -1066,7 +1062,7 @@ void MarlinUI::draw_status_screen() { // The Select Screen presents a prompt and two "buttons" void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const fpre, const char * const string, FSTR_P const fsuf) { - if (!PanelDetected) return; + if (!panel_detected) return; ui.draw_select_screen_prompt(fpre, string, fsuf); lcd.write(COLOR_EDIT); if (no) { @@ -1083,7 +1079,7 @@ void MarlinUI::draw_status_screen() { #if HAS_MEDIA void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { - if (!PanelDetected) return; + if (!panel_detected) return; lcd_moveto(0, row); lcd.write(sel ? LCD_STR_ARROW_RIGHT[0] : ' '); uint8_t n = LCD_WIDTH - 2; @@ -1116,7 +1112,7 @@ void MarlinUI::draw_status_screen() { * |____________________| */ void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) { - if (!PanelDetected) return; + if (!panel_detected) return; #define _LCD_W_POS 12 From 3df75188f3b4bdff9463bbf16eebfae84c2b8733 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Apr 2025 12:57:53 -0500 Subject: [PATCH 24/51] =?UTF-8?q?=F0=9F=9A=B8=20Fix=20TFT=20GLCD=20"Select?= =?UTF-8?q?=20from=20Media"=20glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.cpp | 2 +- Marlin/src/lcd/menu/menu.h | 1 + Marlin/src/lcd/menu/menu_media.cpp | 45 +++++++++++++++++------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 384bf65211..7f78d21bf3 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1114,7 +1114,7 @@ void MarlinUI::init() { #if MARLINUI_SCROLL_NAME // If scrolling of long file names is enabled and we are in the sd card menu, // cause a refresh to occur until all the text has scrolled into view. - if (currentScreen == menu_media && filename_scroll_max && !lcd_status_update_delay--) { + if (currentScreen == menu_media_filelist && filename_scroll_max && !lcd_status_update_delay--) { lcd_status_update_delay = ++filename_scroll_pos >= filename_scroll_max ? 12 : 4; // Long delay at end and start if (filename_scroll_pos > filename_scroll_max) filename_scroll_pos = 0; refresh(LCDVIEW_REDRAW_NOW); diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 92a2d506f5..80a84af1ba 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -211,6 +211,7 @@ void menu_main(); void menu_move(); #if HAS_MEDIA + void menu_media_filelist(); void menu_media(); #endif diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index fe00bf3710..8633551672 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -45,7 +45,7 @@ void lcd_sd_updir() { void MarlinUI::reselect_last_file() { if (sd_encoder_position == 0xFFFF) return; - goto_screen(menu_media, sd_encoder_position, sd_top_line, sd_items); + goto_screen(menu_media_filelist, sd_encoder_position, sd_top_line, sd_items); sd_encoder_position = 0xFFFF; defer_status_screen(); } @@ -101,6 +101,29 @@ class MenuItem_sdfolder : public MenuItem_sdbase { } }; +#if HAS_MULTI_VOLUME + void menu_media_select() { + START_MENU(); + BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN_MENU) : GET_TEXT_F(MSG_BACK)); + #if ENABLED(VOLUME_SD_ONBOARD) + ACTION_ITEM(MSG_SD_CARD, []{ card.changeMedia(&card.media_driver_sdcard); card.mount(); ui.goto_screen(menu_media_filelist); }); + #endif + #if ENABLED(VOLUME_USB_FLASH_DRIVE) + ACTION_ITEM(MSG_USB_DISK, []{ card.changeMedia(&card.media_driver_usbFlash); card.mount(); ui.goto_screen(menu_media_filelist); }); + #endif + END_MENU(); + } +#endif + +/** + * "Select From Media" menu item. Depending on single or multiple drives: + * - menu_media_filelist - List files on the current media + * - menu_media_select - Select one of the attached drives, then go to the file list + */ +void menu_media() { + ui.goto_screen(TERN(HAS_MULTI_VOLUME, menu_media_select, menu_media_filelist)); +} + void menu_media_filelist() { ui.encoder_direction_menus(); @@ -113,7 +136,7 @@ void menu_media_filelist() { START_MENU(); #if HAS_MULTI_VOLUME - ACTION_ITEM(MSG_BACK, []{ ui.goto_screen(menu_media); }); + ACTION_ITEM(MSG_BACK, []{ ui.goto_screen(menu_media_select); }); #else BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN_MENU) : GET_TEXT_F(MSG_BACK)); #endif @@ -141,22 +164,4 @@ void menu_media_filelist() { END_MENU(); } -#if HAS_MULTI_VOLUME - void menu_media_select() { - START_MENU(); - BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN_MENU) : GET_TEXT_F(MSG_BACK)); - #if ENABLED(VOLUME_SD_ONBOARD) - ACTION_ITEM(MSG_SD_CARD, []{ card.changeMedia(&card.media_driver_sdcard); card.mount(); ui.goto_screen(menu_media_filelist); }); - #endif - #if ENABLED(VOLUME_USB_FLASH_DRIVE) - ACTION_ITEM(MSG_USB_DISK, []{ card.changeMedia(&card.media_driver_usbFlash); card.mount(); ui.goto_screen(menu_media_filelist); }); - #endif - END_MENU(); - } -#endif - -void menu_media() { - TERN(HAS_MULTI_VOLUME, menu_media_select, menu_media_filelist)(); -} - #endif // HAS_MARLINUI_MENU && HAS_MEDIA From ef9cec9e40ec055e811dbc83ee3991e59a58cecb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Apr 2025 13:43:15 -0500 Subject: [PATCH 25/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20FastI?= =?UTF-8?q?O=20AT90USB=20pins=2046-47=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also lang --- Marlin/src/pins/pinsDebug.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index 94da51ccc2..f897343ffc 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -191,14 +191,14 @@ inline void printPinStateExt(const pin_t pin, const bool ignore, const bool exte auto alt_pin_echo = [](const pin_t &pin) { #if AVR_AT90USB1286_FAMILY // Use FastIO for pins Teensy doesn't expose - if (pin == 46) { - printPinIOState(IS_OUTPUT(46)); - printPinState(READ(46)); + if (pin == PIN_E2) { + printPinIOState(IS_OUTPUT(PIN_E2)); + printPinState(READ(PIN_E2)); return false; } - else if (pin == 47) { - printPinIOState(IS_OUTPUT(47)); - printPinState(READ(47)); + else if (pin == PIN_E3) { + printPinIOState(IS_OUTPUT(PIN_E3)); + printPinState(READ(PIN_E3)); return false; } #endif From e3a28afd5100c3bcd430db992e8a446ef4f40956 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Apr 2025 15:08:57 -0500 Subject: [PATCH 26/51] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20AboutScreen::onTouch?= =?UTF-8?q?End=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp index 065f89adef..eac6e646e6 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp @@ -92,16 +92,17 @@ void AboutScreen::onRedraw(draw_mode_t) { } bool AboutScreen::onTouchEnd(uint8_t tag) { - switch(tag) { + switch (tag) { default: return false; #if ALL(PRINTCOUNTER, FTDI_STATISTICS_SCREEN) case 1: GOTO_SCREEN(StatisticsScreen); break; #endif - case 2: GOTO_PREVIOUS(); return true; + case 2: GOTO_PREVIOUS(); break; #if ALL(TOUCH_UI_DEVELOPER_MENU, FTDI_DEVELOPER_MENU) case 3: GOTO_SCREEN(DeveloperMenu); break; #endif } + return true; } #endif // EXTENSIBLE_UI From 1e6326e85f9846e0db7c5cd23b39d86f97165af4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Apr 2025 11:22:20 -0500 Subject: [PATCH 27/51] =?UTF-8?q?=F0=9F=8C=90=20Language=20for=20SD=20/=20?= =?UTF-8?q?USB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_an.h | 13 ++-- Marlin/src/lcd/language/language_bg.h | 13 ++-- Marlin/src/lcd/language/language_ca.h | 13 ++-- Marlin/src/lcd/language/language_cz.h | 12 ++-- Marlin/src/lcd/language/language_da.h | 2 + Marlin/src/lcd/language/language_de.h | 13 ++-- Marlin/src/lcd/language/language_el.h | 13 ++-- Marlin/src/lcd/language/language_el_gr.h | 13 ++-- Marlin/src/lcd/language/language_en.h | 73 +++++++++++++++------- Marlin/src/lcd/language/language_es.h | 21 ++++--- Marlin/src/lcd/language/language_eu.h | 13 ++-- Marlin/src/lcd/language/language_fi.h | 2 +- Marlin/src/lcd/language/language_fr.h | 13 ++-- Marlin/src/lcd/language/language_fr_na.h | 13 ++-- Marlin/src/lcd/language/language_gl.h | 21 ++++--- Marlin/src/lcd/language/language_hr.h | 13 ++-- Marlin/src/lcd/language/language_hu.h | 13 ++-- Marlin/src/lcd/language/language_it.h | 21 ++++--- Marlin/src/lcd/language/language_jp_kana.h | 13 ++-- Marlin/src/lcd/language/language_ko_KR.h | 2 +- Marlin/src/lcd/language/language_nl.h | 13 ++-- Marlin/src/lcd/language/language_pl.h | 13 ++-- Marlin/src/lcd/language/language_pt.h | 11 ++-- Marlin/src/lcd/language/language_pt_br.h | 13 ++-- Marlin/src/lcd/language/language_ro.h | 13 ++-- Marlin/src/lcd/language/language_ru.h | 13 ++-- Marlin/src/lcd/language/language_sk.h | 13 ++-- Marlin/src/lcd/language/language_sv.h | 13 ++-- Marlin/src/lcd/language/language_tr.h | 13 ++-- Marlin/src/lcd/language/language_uk.h | 13 ++-- Marlin/src/lcd/language/language_vi.h | 36 +++++------ Marlin/src/lcd/language/language_zh_CN.h | 13 ++-- Marlin/src/lcd/language/language_zh_TW.h | 13 ++-- Marlin/src/lcd/menu/menu_main.cpp | 8 +-- 34 files changed, 260 insertions(+), 248 deletions(-) diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 095a3440aa..c5230db098 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -42,7 +42,6 @@ namespace LanguageNarrow_an { LSTR MSG_MEDIA_REMOVED = _UxGT("Tarcheta sacada"); LSTR MSG_LCD_ENDSTOPS = _UxGT("Endstops"); // Max length 8 characters LSTR MSG_MAIN_MENU = _UxGT("Menu prencipal"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Inicio automatico"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Amortar motors"); LSTR MSG_HOMING = _UxGT("Orichen"); LSTR MSG_AUTO_HOME = _UxGT("Levar a l'orichen"); @@ -155,13 +154,13 @@ namespace LanguageNarrow_an { LSTR MSG_AUTORETRACT = _UxGT("Retraccion auto."); LSTR MSG_FILAMENTCHANGE = _UxGT("Cambear filamento"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Cambear filamento *"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Encetan. SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Encetan. USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Encetan. SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Encetan. media"); + LSTR MSG_ATTACH_SD = _UxGT("Encetan. SD"); + LSTR MSG_ATTACH_USB = _UxGT("Encetan. USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Cambiar tarcheta"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Inicio automatico"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z fuera"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reset BLTouch"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Desfase X"); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 4eef867826..4f278c4bcf 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -40,7 +40,6 @@ namespace LanguageNarrow_bg { LSTR MSG_MEDIA_INSERTED = _UxGT("Картата е поставена"); LSTR MSG_MEDIA_REMOVED = _UxGT("Картата е извадена"); LSTR MSG_MAIN_MENU = _UxGT("Меню"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Автостарт"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Изкл. двигатели"); LSTR MSG_AUTO_HOME = _UxGT("Паркиране"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Задай Начало"); @@ -139,13 +138,13 @@ namespace LanguageNarrow_bg { LSTR MSG_AUTORETRACT = _UxGT("Автоoткат"); LSTR MSG_FILAMENTCHANGE = _UxGT("Смяна нишка"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Смяна нишка *"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Иниц. SD-Карта"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Иниц. USB-Карта"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Иниц. SD-Карта"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Иниц. SD-Карта"); + LSTR MSG_ATTACH_SD = _UxGT("Иниц. SD-Карта"); + LSTR MSG_ATTACH_USB = _UxGT("Иниц. USB-Карта"); LSTR MSG_CHANGE_MEDIA = _UxGT("Смяна SD-Карта"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Автостарт"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z-сондата е извадена"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("X Отстояние"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Y Отстояние"); diff --git a/Marlin/src/lcd/language/language_ca.h b/Marlin/src/lcd/language/language_ca.h index fa74f255aa..be12c69df4 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -38,7 +38,6 @@ namespace LanguageNarrow_ca { LSTR MSG_MEDIA_REMOVED = _UxGT("Targeta extreta."); LSTR MSG_LCD_ENDSTOPS = _UxGT("Endstops"); LSTR MSG_MAIN_MENU = _UxGT("Menú principal"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Inici automatic"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Desactiva motors"); LSTR MSG_DEBUG_MENU = _UxGT("Menu de depuracio"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barra progres"); @@ -145,13 +144,13 @@ namespace LanguageNarrow_ca { LSTR MSG_AUTORETRACT = _UxGT("Auto retraccio"); LSTR MSG_FILAMENTCHANGE = _UxGT("Canvia filament"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Canvia filament *"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Inicialitza SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Inicialitza USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Inicialitza SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Inicialitza SD"); + LSTR MSG_ATTACH_SD = _UxGT("Inicialitza SD"); + LSTR MSG_ATTACH_USB = _UxGT("Inicialitza USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Canvia SD"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Inici automatic"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z fora"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reinicia BLTouch"); LSTR MSG_HOME_FIRST = _UxGT("Home %s primer"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index 9a01466227..ac23bc8daf 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -57,7 +57,6 @@ namespace LanguageNarrow_cz { LSTR MSG_MAIN_MENU = _UxGT("Hlavní nabídka"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Další nastavení"); LSTR MSG_CONFIGURATION = _UxGT("Konfigurace"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Uvolnit motory"); LSTR MSG_DEBUG_MENU = _UxGT("Nabídka ladění"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test uk. průběhu"); @@ -359,14 +358,13 @@ namespace LanguageNarrow_cz { LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Vysunout filament *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Vysunout vše"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Načíst SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Načíst USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Načíst SD"); - #endif + LSTR MSG_ATTACH_MEDIA = _UxGT("Načíst médium"); + LSTR MSG_ATTACH_SD = _UxGT("Načíst SD"); + LSTR MSG_ATTACH_USB = _UxGT("Načíst USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Vyměnit médium"); LSTR MSG_RELEASE_MEDIA = _UxGT("Vysunout médium"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Autostart"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z mimo podl"); LSTR MSG_SKEW_FACTOR = _UxGT("Faktor zkosení"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index 35083aa01f..0a286d1751 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -133,7 +133,9 @@ namespace LanguageNarrow_da { LSTR MSG_AUTORETRACT = _UxGT("Auto-Retract"); LSTR MSG_FILAMENTCHANGE = _UxGT("Skift filament"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Skift filament *"); + LSTR MSG_CHANGE_MEDIA = _UxGT("Skift SD kort"); + LSTR MSG_ZPROBE_OUT = _UxGT("Probe udenfor plade"); LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Selv-Test"); LSTR MSG_HOME_FIRST = _UxGT("Home %s først"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 23730d321a..e681317fb8 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -55,7 +55,6 @@ namespace LanguageNarrow_de { LSTR MSG_MAIN_MENU = _UxGT("Hauptmenü"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Erw. Einstellungen"); LSTR MSG_CONFIGURATION = _UxGT("Konfiguration"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Motoren deaktivieren"); // M84 :: Max length 19 characters LSTR MSG_DEBUG_MENU = _UxGT("Debug-Menü"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Statusbalken-Test"); @@ -493,14 +492,14 @@ namespace LanguageNarrow_de { LSTR MSG_FILAMENTUNLOAD = _UxGT("Filament entladen"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Filament entladen *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Alles entladen"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("SD initial."); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("USB initial."); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("SD initial."); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("SD initial."); + LSTR MSG_ATTACH_SD = _UxGT("SD initial."); + LSTR MSG_ATTACH_USB = _UxGT("USB initial."); LSTR MSG_CHANGE_MEDIA = _UxGT("Medium getauscht"); // SD-card changed by user. For machines with no autocarddetect. Both send "M21" LSTR MSG_RELEASE_MEDIA = _UxGT("Medium freigeben"); // if Marlin gets confused - M22 + LSTR MSG_RUN_AUTOFILES = _UxGT("Autostart"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z-Sonde außerhalb"); LSTR MSG_SKEW_FACTOR = _UxGT("Korrekturfaktor"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 85de0f0751..0d3d355cb0 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -52,7 +52,6 @@ namespace LanguageNarrow_el { LSTR MSG_MEDIA_USB_FAILED = _UxGT("Αποτυχία εκκίνησης USB"); LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Αποτυχία αρχικοποίησης SD"); LSTR MSG_MAIN_MENU = _UxGT("Αρχική Οθόνη"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Αυτόματη εκκίνηση"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Απενεργοποίηση μοτέρ"); LSTR MSG_AUTO_HOME = _UxGT("Αυτόμ. επαναφορά XYZ"); LSTR MSG_AUTO_HOME_X = _UxGT("Επαναφορά X"); @@ -180,13 +179,13 @@ namespace LanguageNarrow_el { LSTR MSG_AUTORETRACT = _UxGT("Αυτόματη ανάσυρση"); LSTR MSG_FILAMENTCHANGE = _UxGT("Αλλαγή νήματος"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Αλλαγή νήματος *"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Προετοιμασία SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Προετοιμασία USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Προετοιμασία SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Προετοιμασία SD"); + LSTR MSG_ATTACH_SD = _UxGT("Προετοιμασία SD"); + LSTR MSG_ATTACH_USB = _UxGT("Προετοιμασία USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Αλλαγή κάρτας SD"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Αυτόματη εκκίνηση"); + LSTR MSG_ZPROBE_OUT = _UxGT("Διερεύνηση Z εκτός Επ.Εκτύπωσης"); // SHORTEN LSTR MSG_YX_UNHOMED = _UxGT("Επαναφορά Χ/Υ πρώτα"); LSTR MSG_XYZ_UNHOMED = _UxGT("Επαναφορά ΧΥZ πρώτα"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index 65b2da5ee3..3e2cb0ec07 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -41,7 +41,6 @@ namespace LanguageNarrow_el_gr { LSTR MSG_MEDIA_REMOVED = _UxGT("Αφαίρεση κάρτας"); LSTR MSG_LCD_ENDSTOPS = _UxGT("Endstops"); // Max length 8 characters LSTR MSG_MAIN_MENU = _UxGT("Βασική Οθόνη"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Αυτόματη εκκίνηση"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Απενεργοποίηση βηματιστή"); LSTR MSG_AUTO_HOME = _UxGT("Αυτομ. επαναφορά στο αρχικό σημείο"); LSTR MSG_AUTO_HOME_X = _UxGT("Αρχικό σημείο X"); @@ -170,13 +169,13 @@ namespace LanguageNarrow_el_gr { LSTR MSG_AUTORETRACT = _UxGT("Αυτόματη ανάσυρση"); LSTR MSG_FILAMENTCHANGE = _UxGT("Αλλαγή νήματος"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Αλλαγή νήματος *"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Προετοιμασία SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Προετοιμασία USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Προετοιμασία SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Προετοιμασία SD"); + LSTR MSG_ATTACH_SD = _UxGT("Προετοιμασία SD"); + LSTR MSG_ATTACH_USB = _UxGT("Προετοιμασία USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Αλλαγή κάρτας SD"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Αυτόματη εκκίνηση"); + LSTR MSG_ZPROBE_OUT = _UxGT("Διερεύνηση Z εκτός κλίνης"); LSTR MSG_YX_UNHOMED = _UxGT("Επαναφορά Χ/Υ πριν από Z"); LSTR MSG_XYZ_UNHOMED = _UxGT("Επαναφορά ΧΥZ πρώτα"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index e0c1f53f77..d23e638a78 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -42,7 +42,13 @@ #endif #undef en -#define MEDIA_TYPE_EN "Media" +#if HAS_SDCARD && !HAS_USB_FLASH_DRIVE + #define MEDIA_TYPE_EN "SD Card" +#elif HAS_USB_FLASH_DRIVE + #define MEDIA_TYPE_EN "USB Drive" +#else + #define MEDIA_TYPE_EN "Media" +#endif #ifndef PREHEAT_1_LABEL #define PREHEAT_1_LABEL "" @@ -76,23 +82,32 @@ namespace LanguageNarrow_en { LSTR MSG_LOW = _UxGT("LOW"); LSTR MSG_BACK = _UxGT("Back"); LSTR MSG_ERROR = _UxGT("Error"); + LSTR MSG_MEDIA_ABORTING = _UxGT("Aborting..."); LSTR MSG_MEDIA_INSERTED = MEDIA_TYPE_EN _UxGT(" Inserted"); + LSTR MSG_MEDIA_INSERTED_SD = _UxGT("SD Card Inserted"); + LSTR MSG_MEDIA_INSERTED_USB = _UxGT("USB Drive Inserted"); LSTR MSG_MEDIA_REMOVED = MEDIA_TYPE_EN _UxGT(" Removed"); + LSTR MSG_MEDIA_REMOVED_SD = _UxGT("SD Card Removed"); + LSTR MSG_MEDIA_REMOVED_USB = _UxGT("USB Drive Removed"); LSTR MSG_MEDIA_WAITING = _UxGT("Waiting for ") MEDIA_TYPE_EN; + LSTR MSG_MEDIA_WAITING_SD = _UxGT("Waiting for SD Card"); + LSTR MSG_MEDIA_WAITING_USB = _UxGT("Waiting for USB Drive"); LSTR MSG_MEDIA_INIT_FAIL = MEDIA_TYPE_EN _UxGT(" Init Fail"); + LSTR MSG_MEDIA_INIT_FAIL_SD = _UxGT("SD Card Init Fail"); + LSTR MSG_MEDIA_INIT_FAIL_USB = _UxGT("USB Drive Init Fail"); LSTR MSG_MEDIA_READ_ERROR = MEDIA_TYPE_EN _UxGT(" read error"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB device removed"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("USB start failed"); LSTR MSG_MEDIA_SORT = _UxGT("Sort ") MEDIA_TYPE_EN; LSTR MSG_MEDIA_UPDATE = MEDIA_TYPE_EN _UxGT(" Update"); + LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Subcall Overflow"); LSTR MSG_LCD_ENDSTOPS = _UxGT("Endstops"); // Max length 8 characters LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Soft Endstops"); LSTR MSG_MAIN_MENU = _UxGT("Main Menu"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Advanced Settings"); LSTR MSG_CONFIGURATION = _UxGT("Configuration"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Run Auto Files"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Disable Steppers"); LSTR MSG_DEBUG_MENU = _UxGT("Debug Menu"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Progress Bar Test"); @@ -613,14 +628,20 @@ namespace LanguageNarrow_en { LSTR MSG_FILAMENTUNLOAD = _UxGT("Unload Filament"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Unload * Filament"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Unload All"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Attach SD Card"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Attach USB Drive"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Attach ") MEDIA_TYPE_EN; - #endif - LSTR MSG_CHANGE_MEDIA = _UxGT("Change ") MEDIA_TYPE_EN; + + LSTR MSG_ATTACH_MEDIA = _UxGT("Attach ") MEDIA_TYPE_EN; + LSTR MSG_ATTACH_SD = _UxGT("Attach SD Card"); + LSTR MSG_ATTACH_USB = _UxGT("Attach USB Drive"); LSTR MSG_RELEASE_MEDIA = _UxGT("Release ") MEDIA_TYPE_EN; + LSTR MSG_RELEASE_SD = _UxGT("Release SD Card"); + LSTR MSG_RELEASE_USB = _UxGT("Release USB Drive"); + LSTR MSG_CHANGE_MEDIA = _UxGT("Refresh ") MEDIA_TYPE_EN; + LSTR MSG_CHANGE_SD = _UxGT("Select SD Card"); + LSTR MSG_CHANGE_USB = _UxGT("Select USB Drive"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Run Autofiles"); + LSTR MSG_RUN_AUTOFILES_SD = _UxGT("Run SD Autofiles"); + LSTR MSG_RUN_AUTOFILES_USB = _UxGT("Run USB Autofiles"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z Probe Past Bed"); LSTR MSG_SKEW_FACTOR = _UxGT("Skew Factor"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); @@ -665,6 +686,7 @@ namespace LanguageNarrow_en { LSTR MSG_BABYSTEP_N = _UxGT("Babystep @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop Abort"); + LSTR MSG_ERR_HEATING_FAILED = _UxGT("Heating Failed"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: REDUNDANT TEMP"); LSTR MSG_ERR_THERMAL_RUNAWAY = _UxGT("THERMAL RUNAWAY"); @@ -686,6 +708,7 @@ namespace LanguageNarrow_en { LSTR MSG_CHAMBER_HEATING = _UxGT("Chamber Heating..."); LSTR MSG_CHAMBER_COOLING = _UxGT("Chamber Cooling..."); LSTR MSG_LASER_COOLING = _UxGT("Laser Cooling..."); + LSTR MSG_DELTA_CALIBRATE = _UxGT("Delta Calibration"); LSTR MSG_DELTA_CALIBRATION_IN_PROGRESS = _UxGT("Delta Calibration in progress"); LSTR MSG_DELTA_CALIBRATE_X = _UxGT("Calibrate X"); @@ -697,14 +720,9 @@ namespace LanguageNarrow_en { LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diag Rod"); LSTR MSG_DELTA_HEIGHT = _UxGT("Height"); LSTR MSG_DELTA_RADIUS = _UxGT("Radius"); + LSTR MSG_INFO_MENU = _UxGT("About Printer"); LSTR MSG_INFO_PRINTER_MENU = _UxGT("Printer Info"); - LSTR MSG_3POINT_LEVELING = _UxGT("3-Point Leveling"); - LSTR MSG_LINEAR_LEVELING = _UxGT("Linear Leveling"); - LSTR MSG_BILINEAR_LEVELING = _UxGT("Bilinear Leveling"); - LSTR MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling"); - LSTR MSG_MESH_LEVELING = _UxGT("Mesh Leveling"); - LSTR MSG_MESH_DONE = _UxGT("Mesh probing done"); LSTR MSG_INFO_PRINTER_STATS_MENU = _UxGT("Printer Stats"); LSTR MSG_INFO_STATS_MENU = _UxGT("Stats"); LSTR MSG_RESET_STATS = _UxGT("Reset Print Stats?"); @@ -715,6 +733,22 @@ namespace LanguageNarrow_en { LSTR MSG_INFO_PROTOCOL = _UxGT("Protocol"); LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: OFF"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: ON"); + LSTR MSG_INFO_PRINT_COUNT = _UxGT("Prints"); + LSTR MSG_INFO_PRINT_TIME = _UxGT("Total"); + LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Longest"); + LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extruded"); + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completed"); + LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); + LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); + LSTR MSG_INFO_PSU = _UxGT("PSU"); + + LSTR MSG_3POINT_LEVELING = _UxGT("3-Point Leveling"); + LSTR MSG_LINEAR_LEVELING = _UxGT("Linear Leveling"); + LSTR MSG_BILINEAR_LEVELING = _UxGT("Bilinear Leveling"); + LSTR MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling"); + LSTR MSG_MESH_LEVELING = _UxGT("Mesh Leveling"); + LSTR MSG_MESH_DONE = _UxGT("Mesh probing done"); + LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); LSTR MSG_BED_IDLE_TIMEOUT = _UxGT("Bed Idle Timeout"); LSTR MSG_HOTEND_IDLE_DISABLE = _UxGT("Disable Timeout"); @@ -726,15 +760,6 @@ namespace LanguageNarrow_en { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Light Brightness"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("INCORRECT PRINTER"); - LSTR MSG_INFO_PRINT_COUNT = _UxGT("Prints"); - LSTR MSG_INFO_PRINT_TIME = _UxGT("Total"); - LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Longest"); - LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extruded"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completed"); - LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); - LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); - LSTR MSG_INFO_PSU = _UxGT("PSU"); - LSTR MSG_DRIVE_STRENGTH = _UxGT("Drive Strength"); LSTR MSG_DAC_PERCENT_N = _UxGT("@ Driver %"); LSTR MSG_ERROR_TMC = _UxGT("TMC CONNECTION ERROR"); diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 058b550f67..d1e4babf2b 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -28,7 +28,13 @@ * See also https://marlinfw.org/docs/development/lcd_language.html */ -#define MEDIA_TYPE_ES "SD/FD" +#if HAS_SDCARD && !HAS_USB_FLASH_DRIVE + #define MEDIA_TYPE_ES "SD" +#elif HAS_USB_FLASH_DRIVE + #define MEDIA_TYPE_ES "USB" +#else + #define MEDIA_TYPE_ES "SD/FD" +#endif namespace LanguageNarrow_es { using namespace Language_en; // Inherit undefined strings from English @@ -54,7 +60,6 @@ namespace LanguageNarrow_es { LSTR MSG_MAIN_MENU = _UxGT("Menú principal"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Ajustes avanzados"); LSTR MSG_CONFIGURATION = _UxGT("Configuración"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Inicio automático"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Apagar motores"); LSTR MSG_DEBUG_MENU = _UxGT("Menú depuración"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Prob. barra progreso"); @@ -368,14 +373,14 @@ namespace LanguageNarrow_es { LSTR MSG_FILAMENTUNLOAD = _UxGT("Descargar filamento"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Descargar fil. *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Descargar todo"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Iniciar SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Iniciar USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar ") MEDIA_TYPE_ES; - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar ") MEDIA_TYPE_ES; + LSTR MSG_ATTACH_SD = _UxGT("Iniciar SD"); + LSTR MSG_ATTACH_USB = _UxGT("Iniciar USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Cambiar ") MEDIA_TYPE_ES; LSTR MSG_RELEASE_MEDIA = _UxGT("Lanzar ") MEDIA_TYPE_ES; + LSTR MSG_RUN_AUTOFILES = _UxGT("Inicio automático"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z fuera cama"); LSTR MSG_SKEW_FACTOR = _UxGT("Factor de desviación"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index 561de0b8e6..52612a8081 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -42,7 +42,6 @@ namespace LanguageNarrow_eu { LSTR MSG_MEDIA_INSERTED = _UxGT("Txartela sartuta"); LSTR MSG_MEDIA_REMOVED = _UxGT("Txartela kenduta"); LSTR MSG_MAIN_MENU = _UxGT("Menu nagusia"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Auto hasiera"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Itzali motoreak"); LSTR MSG_DEBUG_MENU = _UxGT("Arazketa Menua"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Prog. Barra Proba"); @@ -219,13 +218,13 @@ namespace LanguageNarrow_eu { LSTR MSG_FILAMENTUNLOAD = _UxGT("Harizpia deskargatu"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Harizpia deskargatu *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Erabat deskargatu"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Hasieratu SD-a"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Hasieratu USB-a"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Hasieratu SD-a"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Hasieratu SD-a"); + LSTR MSG_ATTACH_SD = _UxGT("Hasieratu SD-a"); + LSTR MSG_ATTACH_USB = _UxGT("Hasieratu USB-a"); LSTR MSG_CHANGE_MEDIA = _UxGT("Aldatu txartela"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Auto hasiera"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z zunda kanpora"); LSTR MSG_SKEW_FACTOR = _UxGT("Okertze faktorea"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_fi.h b/Marlin/src/lcd/language/language_fi.h index 7b3f0f6082..d70c67208c 100644 --- a/Marlin/src/lcd/language/language_fi.h +++ b/Marlin/src/lcd/language/language_fi.h @@ -40,7 +40,7 @@ namespace LanguageNarrow_fi { LSTR MSG_MEDIA_INSERTED = _UxGT("Kortti asetettu"); LSTR MSG_MEDIA_REMOVED = _UxGT("Kortti poistettu"); LSTR MSG_MAIN_MENU = _UxGT("Palaa"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Automaatti"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Automaatti"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Vapauta moottorit"); LSTR MSG_AUTO_HOME = _UxGT("Aja referenssiin"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 13bee9fbb8..6d9fd3b4f4 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -52,7 +52,6 @@ namespace LanguageNarrow_fr { LSTR MSG_MAIN_MENU = _UxGT("Menu principal"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Config. avancée"); LSTR MSG_CONFIGURATION = _UxGT("Configuration"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Exéc. auto.gcode"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Arrêter moteurs"); LSTR MSG_DEBUG_MENU = _UxGT("Menu debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barre progress."); @@ -392,14 +391,14 @@ namespace LanguageNarrow_fr { LSTR MSG_FILAMENTUNLOAD = _UxGT("Retrait filament"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Retrait filament *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Retirer tout"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Charger le SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Charger le USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Charger le SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Charger le SD"); + LSTR MSG_ATTACH_SD = _UxGT("Charger le SD"); + LSTR MSG_ATTACH_USB = _UxGT("Charger le USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Actualiser média"); LSTR MSG_RELEASE_MEDIA = _UxGT("Retirer le média"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Exéc. auto.gcode"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonde Z hors lit"); LSTR MSG_SKEW_FACTOR = _UxGT("Facteur écart"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_fr_na.h b/Marlin/src/lcd/language/language_fr_na.h index a3da3082de..07f2b86499 100644 --- a/Marlin/src/lcd/language/language_fr_na.h +++ b/Marlin/src/lcd/language/language_fr_na.h @@ -52,7 +52,6 @@ namespace LanguageNarrow_fr_na { LSTR MSG_MAIN_MENU = _UxGT("Menu principal"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Config. avancee"); LSTR MSG_CONFIGURATION = _UxGT("Configuration"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Exec. auto.gcode"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Arreter moteurs"); LSTR MSG_DEBUG_MENU = _UxGT("Menu debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barre progress."); @@ -392,14 +391,14 @@ namespace LanguageNarrow_fr_na { LSTR MSG_FILAMENTUNLOAD = _UxGT("Retrait filament"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Retrait filament *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Retirer tout"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Charger le SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Charger le USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Charger le SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Charger le SD"); + LSTR MSG_ATTACH_SD = _UxGT("Charger le SD"); + LSTR MSG_ATTACH_USB = _UxGT("Charger le USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Actualiser media"); LSTR MSG_RELEASE_MEDIA = _UxGT("Retirer le media"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Exec. auto.gcode"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonde Z hors lit"); LSTR MSG_SKEW_FACTOR = _UxGT("Facteur ecart"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 3287ae2676..6dd699f1bd 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -30,7 +30,13 @@ #define DISPLAY_CHARSET_ISO10646_1 -#define MEDIA_TYPE_GL "SD/FD" +#if HAS_SDCARD && !HAS_USB_FLASH_DRIVE + #define MEDIA_TYPE_GL "SD" +#elif HAS_USB_FLASH_DRIVE + #define MEDIA_TYPE_GL "FD" +#else + #define MEDIA_TYPE_GL "SD/FD" +#endif namespace LanguageNarrow_gl { using namespace Language_en; // Inherit undefined strings from English @@ -55,7 +61,6 @@ namespace LanguageNarrow_gl { LSTR MSG_MAIN_MENU = _UxGT("Menú principal"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Axustes avanzados"); LSTR MSG_CONFIGURATION = _UxGT("Configuración"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Autoarranque"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Apagar motores"); LSTR MSG_DEBUG_MENU = _UxGT("Menú depuración"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barra progreso"); @@ -383,14 +388,14 @@ namespace LanguageNarrow_gl { LSTR MSG_FILAMENTUNLOAD = _UxGT("Descargar Filamento"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Descargar Filamento *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Descargar Todo"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Iniciar SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Iniciar USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar ") MEDIA_TYPE_GL; - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar ") MEDIA_TYPE_GL; + LSTR MSG_ATTACH_SD = _UxGT("Iniciar SD"); + LSTR MSG_ATTACH_USB = _UxGT("Iniciar USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Cambiar ") MEDIA_TYPE_GL; LSTR MSG_RELEASE_MEDIA = _UxGT("Lanzar ") MEDIA_TYPE_GL; + LSTR MSG_RUN_AUTOFILES = _UxGT("Autoarranque"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonda-Z fóra Cama"); LSTR MSG_SKEW_FACTOR = _UxGT("Factor de Desviación"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index 5f60b000e3..a75dcff846 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -41,7 +41,6 @@ namespace LanguageNarrow_hr { LSTR MSG_MEDIA_REMOVED = _UxGT("SD kartica uklonjena"); LSTR MSG_LCD_ENDSTOPS = _UxGT("Endstops"); // Max length 8 characters LSTR MSG_MAIN_MENU = _UxGT("Main"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Auto pokretanje"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Ugasi steppere"); LSTR MSG_AUTO_HOME = _UxGT("Automatski homing"); LSTR MSG_AUTO_HOME_X = _UxGT("Home-aj X"); @@ -117,13 +116,13 @@ namespace LanguageNarrow_hr { LSTR MSG_STOPPED = _UxGT("ZAUSTAVLJEN. "); LSTR MSG_FILAMENTCHANGE = _UxGT("Promijeni filament"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Promijeni filament *"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Init. SD karticu"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Init. USB pogon"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Init. SD karticu"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Init. SD karticu"); + LSTR MSG_ATTACH_SD = _UxGT("Init. SD karticu"); + LSTR MSG_ATTACH_USB = _UxGT("Init. USB pogon"); LSTR MSG_CHANGE_MEDIA = _UxGT("Promijeni SD karticu"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Auto pokretanje"); + LSTR MSG_ERR_HEATING_FAILED = _UxGT("Grijanje neuspješno"); LSTR MSG_HEATING = _UxGT("Grijanje..."); LSTR MSG_BED_HEATING = _UxGT("Grijanje Bed-a..."); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index a626aa2209..3159b79827 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -57,7 +57,6 @@ namespace LanguageNarrow_hu { LSTR MSG_MAIN_MENU = _UxGT(""); LSTR MSG_ADVANCED_SETTINGS = _UxGT("További beállítások"); LSTR MSG_CONFIGURATION = _UxGT("Konfiguráció"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Fájl auto. futtatás"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Motorok kikapcsolása"); LSTR MSG_DEBUG_MENU = _UxGT("Hiba Menü"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Haladás sáv teszt"); @@ -431,14 +430,14 @@ namespace LanguageNarrow_hu { LSTR MSG_FILAMENTUNLOAD = _UxGT("Szál eltávolítás"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Szál eltávolítás *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Mindet eltávolít"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Tároló SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Tároló USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Tároló SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Tároló SD"); + LSTR MSG_ATTACH_SD = _UxGT("Tároló SD"); + LSTR MSG_ATTACH_USB = _UxGT("Tároló USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Tároló csere"); LSTR MSG_RELEASE_MEDIA = _UxGT("Tároló Kiadása"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Fájl auto. futtatás"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z szonda tálcán kivül"); LSTR MSG_SKEW_FACTOR = _UxGT("Ferdeség faktor"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index c1b5366332..424bcd8367 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -38,7 +38,13 @@ #define DISPLAY_CHARSET_ISO10646_1 -#define MEDIA_TYPE_IT "Media" +#if HAS_SDCARD && !HAS_USB_FLASH_DRIVE + #define MEDIA_TYPE_IT "SD" +#elif HAS_USB_FLASH_DRIVE + #define MEDIA_TYPE_IT "USB" +#else + #define MEDIA_TYPE_IT "Media" +#endif namespace LanguageNarrow_it { using namespace Language_en; // Inherit undefined strings from English @@ -69,7 +75,6 @@ namespace LanguageNarrow_it { LSTR MSG_MAIN_MENU = _UxGT("Menu principale"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Impostaz. avanzate"); LSTR MSG_CONFIGURATION = _UxGT("Configurazione"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Esegui files auto"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Disabilita motori"); LSTR MSG_DEBUG_MENU = _UxGT("Menu di debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barra avanzam."); @@ -581,14 +586,14 @@ namespace LanguageNarrow_it { LSTR MSG_FILAMENTUNLOAD = _UxGT("Rimuovi filamento"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Rimuovi filam. *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Rimuovi tutto"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Collega scheda SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Collega penna USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Collega ") MEDIA_TYPE_IT; - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Collega ") MEDIA_TYPE_IT; + LSTR MSG_ATTACH_SD = _UxGT("Collega scheda SD"); + LSTR MSG_ATTACH_USB = _UxGT("Collega penna USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Cambia ") MEDIA_TYPE_IT; LSTR MSG_RELEASE_MEDIA = _UxGT("Rilascia ") MEDIA_TYPE_IT; + LSTR MSG_RUN_AUTOFILES = _UxGT("Esegui files auto"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z probe fuori piatto"); LSTR MSG_SKEW_FACTOR = _UxGT("Fattore distorsione"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index ae88b1d968..37c9aa043e 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -47,7 +47,6 @@ namespace LanguageNarrow_jp_kana { LSTR MSG_RELEASE_MEDIA = _UxGT("メディアノトリダシ"); LSTR MSG_LCD_ENDSTOPS = _UxGT("エンドストップ"); // "Endstops" // Max length 8 characters LSTR MSG_MAIN_MENU = _UxGT("メイン"); // "Main" - LSTR MSG_RUN_AUTO_FILES = _UxGT("ジドウカイシ"); // "Autostart" LSTR MSG_DISABLE_STEPPERS = _UxGT("モーターデンゲン オフ"); // "Disable steppers" LSTR MSG_DEBUG_MENU = _UxGT("デバッグメニュー"); // "Debug Menu" LSTR MSG_PROGRESS_BAR_TEST = _UxGT("プログレスバー テスト"); // "Progress Bar Test" @@ -168,13 +167,13 @@ namespace LanguageNarrow_jp_kana { LSTR MSG_CONTROL_RETRACT_RECOVERF = _UxGT("ホショウソクド mm/s"); // "Unretract V" LSTR MSG_AUTORETRACT = _UxGT("ジドウヒキコミ"); // "Auto-Retract" LSTR MSG_FILAMENTCHANGE = _UxGT("フィラメントコウカン"); // "Change filament" - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("SDカードをマウントする"); // "Attach SD Card" - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("USBメモリをマウントする"); // "Attach USB Drive" - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("SDカードをマウントする"); // "Attach SD Card" - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("SDカードをマウントする"); // "Attach SD Card" + LSTR MSG_ATTACH_SD = _UxGT("SDカードをマウントする"); // "Attach SD Card" + LSTR MSG_ATTACH_USB = _UxGT("USBメモリをマウントする"); // "Attach USB Drive" LSTR MSG_CHANGE_MEDIA = _UxGT("メディアコウカン"); // "Change SD card" + LSTR MSG_RUN_AUTOFILES = _UxGT("ジドウカイシ"); // "Autostart" + LSTR MSG_ZPROBE_OUT = _UxGT("Zプローブ ベッドガイ"); // "Z probe out. bed" LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch ジコシンダン"); // "BLTouch Self-Test" LSTR MSG_BLTOUCH_RESET = _UxGT("BLTouch リセット"); // "Reset BLTouch" diff --git a/Marlin/src/lcd/language/language_ko_KR.h b/Marlin/src/lcd/language/language_ko_KR.h index d5410cadf5..4ecaab5394 100644 --- a/Marlin/src/lcd/language/language_ko_KR.h +++ b/Marlin/src/lcd/language/language_ko_KR.h @@ -42,7 +42,7 @@ namespace LanguageNarrow_ko_KR { LSTR MSG_MAIN_MENU = _UxGT("뒤로"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("고급 설정"); LSTR MSG_CONFIGURATION = _UxGT("설정"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("자동 시작"); + LSTR MSG_RUN_AUTOFILES = _UxGT("자동 시작"); LSTR MSG_DISABLE_STEPPERS = _UxGT("모터 정지"); LSTR MSG_DEBUG_MENU = _UxGT("디버깅 메뉴"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("프로그레스바 테스트"); diff --git a/Marlin/src/lcd/language/language_nl.h b/Marlin/src/lcd/language/language_nl.h index e99417a2dc..bb4c7e00b2 100644 --- a/Marlin/src/lcd/language/language_nl.h +++ b/Marlin/src/lcd/language/language_nl.h @@ -43,7 +43,6 @@ namespace LanguageNarrow_nl { LSTR MSG_MEDIA_REMOVED = _UxGT("Kaart verwijderd"); LSTR MSG_LCD_ENDSTOPS = _UxGT("Endstops"); // Max length 8 characters LSTR MSG_MAIN_MENU = _UxGT("Hoofdmenu"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Motoren uit"); LSTR MSG_DEBUG_MENU = _UxGT("Debug Menu"); // accepted English terms LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Vooruitgang Test"); @@ -146,13 +145,13 @@ namespace LanguageNarrow_nl { LSTR MSG_AUTORETRACT = _UxGT("Auto-Retract"); LSTR MSG_FILAMENTCHANGE = _UxGT("Verv. Filament"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Verv. Filament *"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Init. SD kaart"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Init. USB stick"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Init. SD kaart"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Init. SD kaart"); + LSTR MSG_ATTACH_SD = _UxGT("Init. SD kaart"); + LSTR MSG_ATTACH_USB = _UxGT("Init. USB stick"); LSTR MSG_CHANGE_MEDIA = _UxGT("Verv. SD Kaart"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Autostart"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z probe uit. bed"); LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Zelf-Test"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reset BLTouch"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 07573bb2d8..7c7297d184 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -61,7 +61,6 @@ namespace LanguageNarrow_pl { LSTR MSG_MAIN_MENU = _UxGT("Menu główne"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Ustawienie zaawansowane"); LSTR MSG_CONFIGURATION = _UxGT("Konfiguracja"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Wyłącz silniki"); LSTR MSG_DEBUG_MENU = _UxGT("Menu Debugowania"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Testowy pasek postępu"); @@ -358,14 +357,14 @@ namespace LanguageNarrow_pl { LSTR MSG_FILAMENTUNLOAD = _UxGT("Wysuń Filament"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Wysuń Filament *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Wysuń wszystkie"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Inicjal. karty SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Inicjal. dysk flash"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Inicjal. karty SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Inicjal. karty SD"); + LSTR MSG_ATTACH_SD = _UxGT("Inicjal. karty SD"); + LSTR MSG_ATTACH_USB = _UxGT("Inicjal. dysk flash"); LSTR MSG_CHANGE_MEDIA = _UxGT("Zmiana karty SD"); LSTR MSG_RELEASE_MEDIA = _UxGT("Zwolnienie karty"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Autostart"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z za stołem"); LSTR MSG_SKEW_FACTOR = _UxGT("Współczynik skrzywienia"); LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Self-Test"); diff --git a/Marlin/src/lcd/language/language_pt.h b/Marlin/src/lcd/language/language_pt.h index 62799fc9a5..229211b4f2 100644 --- a/Marlin/src/lcd/language/language_pt.h +++ b/Marlin/src/lcd/language/language_pt.h @@ -142,13 +142,12 @@ namespace LanguageNarrow_pt { LSTR MSG_AUTORETRACT = _UxGT(" Auto-Retract"); LSTR MSG_FILAMENTCHANGE = _UxGT("Trocar filamento"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Trocar filamento *"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Inici. cartão SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Inici. flash USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Inici. cartão SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Inici. cartão SD"); + LSTR MSG_ATTACH_SD = _UxGT("Inici. cartão SD"); + LSTR MSG_ATTACH_USB = _UxGT("Inici. flash USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Trocar cartão SD"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sensor fora/base"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Desvio X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Desvio Y"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index 8d5a608d00..80a8d95bdb 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -50,7 +50,6 @@ namespace LanguageNarrow_pt_br { LSTR MSG_MAIN_MENU = _UxGT("Menu principal"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Config. Avançada"); LSTR MSG_CONFIGURATION = _UxGT("Configuração"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Início automático"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Desabilit. motores"); LSTR MSG_DEBUG_MENU = _UxGT("Menu Debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Testar Barra Progres"); @@ -321,14 +320,14 @@ namespace LanguageNarrow_pt_br { LSTR MSG_FILAMENTUNLOAD = _UxGT("Descarreg. Filamento"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Descarreg. Filamento *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Descarregar Todos"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Iniciar cartão SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Iniciar flash USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar cartão SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Iniciar cartão SD"); + LSTR MSG_ATTACH_SD = _UxGT("Iniciar cartão SD"); + LSTR MSG_ATTACH_USB = _UxGT("Iniciar flash USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Trocar SD"); LSTR MSG_RELEASE_MEDIA = _UxGT("Liberar SD"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Início automático"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonda fora da mesa"); LSTR MSG_SKEW_FACTOR = _UxGT("Fator de Cisalho"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index 0b263a4ea6..7337862909 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -52,7 +52,6 @@ namespace LanguageNarrow_ro { LSTR MSG_MAIN_MENU = _UxGT("Principal"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Setari Avansate"); LSTR MSG_CONFIGURATION = _UxGT("Configurare"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Dezactivare Motoare"); LSTR MSG_DEBUG_MENU = _UxGT("Meniu Debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test Bara Progres"); @@ -388,14 +387,14 @@ namespace LanguageNarrow_ro { LSTR MSG_FILAMENTUNLOAD = _UxGT("Scoatere Filament"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Scoatere Filament *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Scoate Tot"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Atasare card SD"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Atasare FD USB"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Atasare card SD"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Atasare card SD"); + LSTR MSG_ATTACH_SD = _UxGT("Atasare card SD"); + LSTR MSG_ATTACH_USB = _UxGT("Atasare FD USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Inlocuire Media"); LSTR MSG_RELEASE_MEDIA = _UxGT("Eliberare Media"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Autostart"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z Probe Past Bed"); LSTR MSG_SKEW_FACTOR = _UxGT("Skew Factor"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index 42e1656a8b..40b3a03d3d 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -53,7 +53,6 @@ namespace LanguageNarrow_ru { LSTR MSG_LCD_ENDSTOPS = _UxGT("Концевик"); // Max length 8 characters LSTR MSG_MAIN_MENU = _UxGT("Главное меню"); LSTR MSG_CONFIGURATION = _UxGT("Конфигурация"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Автостарт"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Выключить двигатели"); LSTR MSG_DEBUG_MENU = _UxGT("Меню отладки"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Тест индикатора"); @@ -435,14 +434,14 @@ namespace LanguageNarrow_ru { LSTR MSG_FILAMENTLOAD_E = _UxGT("Подать филамент *"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Убрать филамент *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Выгрузить всё"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Установить SD карту"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Монтировать USB"); // Установить флешка - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Установить SD карту"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Установить SD карту"); + LSTR MSG_ATTACH_SD = _UxGT("Установить SD карту"); + LSTR MSG_ATTACH_USB = _UxGT("Монтировать USB"); // Установить флешка LSTR MSG_CHANGE_MEDIA = _UxGT("Сменить SD карту"); LSTR MSG_RELEASE_MEDIA = _UxGT("Освободить SD карту"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Автостарт"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z-зонд вне стола"); LSTR MSG_SKEW_FACTOR = _UxGT("Фактор перекоса"); LSTR MSG_BLTOUCH = _UxGT("Z-зонд BLTouch"); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index 782f42f118..7a8c228d84 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -68,7 +68,6 @@ namespace LanguageNarrow_sk { LSTR MSG_MAIN_MENU = _UxGT("Hlavná ponuka"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Pokročilé nastav."); LSTR MSG_CONFIGURATION = _UxGT("Konfigurácia"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Auto-štart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Uvolniť motory"); LSTR MSG_DEBUG_MENU = _UxGT("Ponuka ladenia"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test uk. priebehu"); @@ -533,14 +532,14 @@ namespace LanguageNarrow_sk { LSTR MSG_FILAMENTUNLOAD = _UxGT("Vysunúť filament"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Vysunúť filament *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Vysunúť všetko"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Načítať SD kartu"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Načítať USB disk"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Načítať SD kartu"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Načítať SD kartu"); + LSTR MSG_ATTACH_SD = _UxGT("Načítať SD kartu"); + LSTR MSG_ATTACH_USB = _UxGT("Načítať USB disk"); LSTR MSG_CHANGE_MEDIA = _UxGT("Vymeniť kartu"); LSTR MSG_RELEASE_MEDIA = _UxGT("Odpojiť kartu"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Auto-štart"); + LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z mimo podl."); LSTR MSG_SKEW_FACTOR = _UxGT("Faktor skosenia"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index 356a253b6e..e2e408391c 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -54,7 +54,6 @@ namespace LanguageNarrow_sv { LSTR MSG_MAIN_MENU = _UxGT("Huvud"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Advancerade inställningar"); LSTR MSG_CONFIGURATION = _UxGT("Konfiguration"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostarta Filer"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Inaktivera Stegare"); LSTR MSG_DEBUG_MENU = _UxGT("Debug Meny"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Framstegsindikator Test"); @@ -417,14 +416,14 @@ namespace LanguageNarrow_sv { LSTR MSG_FILAMENTUNLOAD = _UxGT("Lossa Tråd"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Lossa *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Lossa All"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Bifoga SD-kort"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Bifoga USB-minne"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Bifoga SD-kort"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Bifoga SD-kort"); + LSTR MSG_ATTACH_SD = _UxGT("Bifoga SD-kort"); + LSTR MSG_ATTACH_USB = _UxGT("Bifoga USB-minne"); LSTR MSG_CHANGE_MEDIA = _UxGT("Byt Media"); LSTR MSG_RELEASE_MEDIA = _UxGT("Släpp Media"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Autostarta Filer"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z Sond Utanför Bädd"); LSTR MSG_SKEW_FACTOR = _UxGT("Skev Faktor"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index 947f094fa6..36fe4188fa 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -68,7 +68,6 @@ namespace LanguageNarrow_tr { LSTR MSG_MAIN_MENU = _UxGT("Ana"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Gelişmiş Ayarlar"); LSTR MSG_CONFIGURATION = _UxGT("Yapılandırma"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Oto. Başlat"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Motorları Durdur"); LSTR MSG_DEBUG_MENU = _UxGT("Hata Ayıklama"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Durum Çubuğu Testi"); @@ -550,14 +549,14 @@ namespace LanguageNarrow_tr { LSTR MSG_FILAMENTUNLOAD = _UxGT("Filaman Çıkart"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Filaman Çıkart *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Tümünü Çıkart"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("SD Kartı takın"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("USB Sürücüyü takın"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Medyayı Ekle"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Medyayı Ekle"); + LSTR MSG_ATTACH_SD = _UxGT("SD Kartı takın"); + LSTR MSG_ATTACH_USB = _UxGT("USB Sürücüyü takın"); LSTR MSG_CHANGE_MEDIA = _UxGT("Medyayı Değiştir"); LSTR MSG_RELEASE_MEDIA = _UxGT("Medyayı Çıkart"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Oto. Başlat"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z Prob Tablayı Geçti"); LSTR MSG_SKEW_FACTOR = _UxGT("Çarpıklık Faktörü"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index c061b9ad02..4d323d6ba7 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -54,7 +54,6 @@ namespace LanguageNarrow_uk { LSTR MSG_MAIN_MENU = _UxGT("Основне меню"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Інші налаштування"); LSTR MSG_CONFIGURATION = _UxGT("Конфігурація"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("Автостарт"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Вимкнути двигуни"); LSTR MSG_DEBUG_MENU = _UxGT("Меню Debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Тест лінії прогр."); @@ -445,14 +444,14 @@ namespace LanguageNarrow_uk { LSTR MSG_FILAMENTUNLOAD = _UxGT("Видалити пруток"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Видалити пруток *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Видалити все"); - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Вставити SD-картку"); - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Вставити USB флешка"); - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Вставити SD-картку"); - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Вставити SD-картку"); + LSTR MSG_ATTACH_SD = _UxGT("Вставити SD-картку"); + LSTR MSG_ATTACH_USB = _UxGT("Вставити USB флешка"); LSTR MSG_CHANGE_MEDIA = _UxGT("Заміна SD-картки"); LSTR MSG_RELEASE_MEDIA = _UxGT("Видаліть SD-картку"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Автостарт"); + LSTR MSG_ZPROBE_OUT = _UxGT("Z-Зонд поза столом"); LSTR MSG_SKEW_FACTOR = _UxGT("Фактор нахилу"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index fb158e306b..f7f5545bcb 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -47,7 +47,6 @@ namespace LanguageNarrow_vi { LSTR MSG_MAIN_MENU = _UxGT("Chính"); // Main LSTR MSG_ADVANCED_SETTINGS = _UxGT("Thiết lập cấp cao"); // Advanced Settings LSTR MSG_CONFIGURATION = _UxGT("Cấu hình"); // Configuration - LSTR MSG_RUN_AUTO_FILES = _UxGT("Khởi chạy tự động"); // Autostart LSTR MSG_DISABLE_STEPPERS = _UxGT("Tắt động cơ bước"); // Disable steppers LSTR MSG_DEBUG_MENU = _UxGT("Menu gỡ lỗi"); // Debug Menu LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Kiểm tra tiến độ"); // Progress bar test @@ -309,14 +308,14 @@ namespace LanguageNarrow_vi { LSTR MSG_FILAMENTUNLOAD = _UxGT("Dỡ dây nhựa"); // Unload filament LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Dỡ dây nhựa *"); // Unload filament LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Dỡ tất cả"); // Unload All - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("Khởi tạo thẻ SD"); // Attach SD Card - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Khởi tạo thanh USB"); // Attach USB Drive - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("Khởi tạo phương tiện"); // Attach media - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("Khởi tạo phương tiện"); // Attach media + LSTR MSG_ATTACH_SD = _UxGT("Khởi tạo thẻ SD"); // Attach SD Card + LSTR MSG_ATTACH_USB = _UxGT("Khởi tạo thanh USB"); // Attach USB Drive LSTR MSG_CHANGE_MEDIA = _UxGT("Thay phương tiện"); // Change midea LSTR MSG_RELEASE_MEDIA = _UxGT("Phát hành phương tiện"); + LSTR MSG_RUN_AUTOFILES = _UxGT("Khởi chạy tự động"); // Autostart + LSTR MSG_ZPROBE_OUT = _UxGT("Đầu Dò Z qua bàn"); // Z Probe past bed LSTR MSG_SKEW_FACTOR = _UxGT("Hệ số nghiêng"); // Skew Factor LSTR MSG_BLTOUCH = _UxGT("BLTOUCH"); // BLTouch @@ -373,19 +372,11 @@ namespace LanguageNarrow_vi { LSTR MSG_INFO_PROTOCOL = _UxGT("Giao Thức"); // Protocol LSTR MSG_CASE_LIGHT = _UxGT("Đèn Khuông"); // Case light LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Độ Sáng"); // Light Brightness - #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 - LSTR MSG_INFO_PRINT_COUNT = _UxGT("Số In"); // Print Count - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Đã hoàn thành"); - LSTR MSG_INFO_PRINT_TIME = _UxGT("Tổng số thời gian in"); // Total print time - LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Thời gian việc lâu nhất"); // Longest job time - LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Tổng số đùn"); // Extruded total - #else - LSTR MSG_INFO_PRINT_COUNT = _UxGT("In"); // Prints - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Đã hoàn thành"); // Completed - LSTR MSG_INFO_PRINT_TIME = _UxGT("Tổng số"); // Total - LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Dài nhất"); // Longest - LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Đã ép đùn"); - #endif + LSTR MSG_INFO_PRINT_COUNT = _UxGT("In"); // Prints + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Đã hoàn thành"); // Completed + LSTR MSG_INFO_PRINT_TIME = _UxGT("Tổng số"); // Total + LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Dài nhất"); // Longest + LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Đã ép đùn"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Nhiệt độ tối thiểu"); // Min Temp LSTR MSG_INFO_MAX_TEMP = _UxGT("Nhiệt độ tối đa"); // Max temp LSTR MSG_INFO_PSU = _UxGT("Bộ nguồn"); // PSU @@ -446,6 +437,11 @@ namespace LanguageNarrow_vi { namespace LanguageWide_vi { using namespace LanguageNarrow_vi; #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_INFO_PRINT_COUNT = _UxGT("Số In"); // Print Count + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Đã hoàn thành"); + LSTR MSG_INFO_PRINT_TIME = _UxGT("Tổng số thời gian in"); // Total print time + LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Thời gian việc lâu nhất"); // Longest job time + LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Tổng số đùn"); // Extruded total #endif } diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index 680ff8c9b0..01f9f53d0c 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -54,7 +54,6 @@ namespace LanguageNarrow_zh_CN { LSTR MSG_MAIN_MENU = _UxGT("主菜单"); // "Main" LSTR MSG_ADVANCED_SETTINGS = _UxGT("高级设置"); LSTR MSG_CONFIGURATION = _UxGT("配置"); - LSTR MSG_RUN_AUTO_FILES = _UxGT("自动开始"); // "Autostart" LSTR MSG_DISABLE_STEPPERS = _UxGT("关闭步进电机"); // "Disable steppers" LSTR MSG_DEBUG_MENU = _UxGT("调试菜单"); // "Debug Menu" LSTR MSG_PROGRESS_BAR_TEST = _UxGT("进度条测试"); // "Progress Bar Test" @@ -398,14 +397,14 @@ namespace LanguageNarrow_zh_CN { LSTR MSG_FILAMENTUNLOAD = _UxGT("卸载丝料"); // "Unload filament" LSTR MSG_FILAMENTUNLOAD_E = _UxGT("卸载丝料 *"); // "Unload filament" LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("卸载全部"); // "Unload All" - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("挂载存储卡"); // "Attach SD Card" - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("挂载U盘"); // "Attach USB Drive" - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("挂载存储卡"); // "Attach SD Card" - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("挂载存储卡"); // "Attach SD Card" + LSTR MSG_ATTACH_SD = _UxGT("挂载存储卡"); // "Attach SD Card" + LSTR MSG_ATTACH_USB = _UxGT("挂载U盘"); // "Attach USB Drive" LSTR MSG_CHANGE_MEDIA = _UxGT("更换存储卡"); // "Change SD card" LSTR MSG_RELEASE_MEDIA = _UxGT("释放存储卡"); + LSTR MSG_RUN_AUTOFILES = _UxGT("自动开始"); // "Autostart" + LSTR MSG_ZPROBE_OUT = _UxGT("Z探针在热床之外"); // "Z probe out. bed" Z probe is not within the physical limits LSTR MSG_SKEW_FACTOR = _UxGT("偏斜因数"); // "Skew Factor" LSTR MSG_BLTOUCH = _UxGT("BLTouch"); // "BLTouch" diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 63e386a06f..7321252de7 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -49,7 +49,6 @@ namespace LanguageNarrow_zh_TW { LSTR MSG_MAIN_MENU = _UxGT("主選單"); // "Main" LSTR MSG_ADVANCED_SETTINGS = _UxGT("進階設置"); // "Advanced Settings" LSTR MSG_CONFIGURATION = _UxGT("設置"); //Configuration - LSTR MSG_RUN_AUTO_FILES = _UxGT("自動開始"); // "Autostart" LSTR MSG_DISABLE_STEPPERS = _UxGT("關閉步進馬達"); // "Disable steppers" LSTR MSG_DEBUG_MENU = _UxGT("除錯選單"); // "Debug Menu" LSTR MSG_PROGRESS_BAR_TEST = _UxGT("進度條測試"); // "Progress Bar Test" @@ -350,14 +349,14 @@ namespace LanguageNarrow_zh_TW { LSTR MSG_FILAMENTUNLOAD = _UxGT("卸載絲料"); // "Unload filament" LSTR MSG_FILAMENTUNLOAD_E = _UxGT("卸載絲料 *"); // "Unload filament" LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("卸載全部"); // "Unload All" - #if HAS_MULTI_VOLUME - LSTR MSG_ATTACH_SD_MEDIA = _UxGT("挂载記憶卡"); // "Attach SD Card" - LSTR MSG_ATTACH_USB_MEDIA = _UxGT("挂载隨身碟"); // "Attach USB Drive" - #else - LSTR MSG_ATTACH_MEDIA = _UxGT("連接記憶卡"); // "Attach Media" - #endif + + LSTR MSG_ATTACH_MEDIA = _UxGT("連接記憶卡"); // "Attach Media" + LSTR MSG_ATTACH_SD = _UxGT("挂载記憶卡"); // "Attach SD Card" + LSTR MSG_ATTACH_USB = _UxGT("挂载隨身碟"); // "Attach USB Drive" LSTR MSG_CHANGE_MEDIA = _UxGT("更換記憶卡"); // "Change SD card" LSTR MSG_RELEASE_MEDIA = _UxGT("釋放媒體"); // "Release Media" + LSTR MSG_RUN_AUTOFILES = _UxGT("自動開始"); // "Autostart" + LSTR MSG_ZPROBE_OUT = _UxGT("Z探針在熱床之外"); // "Z probe out. bed" Z probe is not within the physical limits LSTR MSG_SKEW_FACTOR = _UxGT("偏斜因數"); // "Skew Factor" diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 9509c72cc5..7e2d458e41 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -253,13 +253,13 @@ void menu_main() { if (card_detected) { if (!card_open) { #if ENABLED(MENU_ADDAUTOSTART) - ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files + ACTION_ITEM(MSG_RUN_AUTOFILES, card.autofile_begin); // Run Auto Files #endif #if HAS_SD_DETECT GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21" TERN_(HAS_MULTI_VOLUME, "S"))); // M21 Change Media #if HAS_MULTI_VOLUME - GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + GCODES_ITEM(MSG_ATTACH_USB, F("M21U")); // M21 Attach USB Media #endif #else // - or - ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media @@ -279,8 +279,8 @@ void menu_main() { ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" #else #if HAS_MULTI_VOLUME - GCODES_ITEM(MSG_ATTACH_SD_MEDIA, F("M21S")); // M21S Attach SD Card - GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21U Attach USB Media + GCODES_ITEM(MSG_ATTACH_SD, F("M21S")); // M21S Attach SD Card + GCODES_ITEM(MSG_ATTACH_USB, F("M21U")); // M21U Attach USB Media #else GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media #endif From 62f2b8fc176887071e9a07152420f28fe54fceef Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 24 Apr 2025 00:30:48 +0000 Subject: [PATCH 28/51] [cron] Bump distribution date (2025-04-24) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index e9c1d9ba1b..e8a64a95f0 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 "2025-04-23" +//#define STRING_DISTRIBUTION_DATE "2025-04-24" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index d06c53dd5e..8a91fbdb71 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 "2025-04-23" + #define STRING_DISTRIBUTION_DATE "2025-04-24" #endif /** From d16667838fdbdf793840ee5ac8b977746af6055d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Apr 2025 18:37:03 -0500 Subject: [PATCH 29/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Clari?= =?UTF-8?q?fy=20some=20SD=20/=20FD=20build=20flags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/sd/M21_M22.cpp | 4 +- Marlin/src/inc/Conditionals-4-adv.h | 11 +- Marlin/src/inc/Conditionals-5-post.h | 2 + Marlin/src/inc/SanityCheck.h | 2 +- .../lcd/extui/mks_ui/draw_media_select.cpp | 4 +- .../extui/mks_ui/tft_lvgl_configuration.cpp | 15 +- Marlin/src/lcd/marlinui.cpp | 2 +- Marlin/src/lcd/menu/menu.h | 2 +- Marlin/src/lcd/menu/menu_media.cpp | 18 +-- Marlin/src/sd/cardreader.cpp | 24 ++-- Marlin/src/sd/cardreader.h | 112 ++++++++++----- .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 130 +++++++++--------- 12 files changed, 190 insertions(+), 136 deletions(-) diff --git a/Marlin/src/gcode/sd/M21_M22.cpp b/Marlin/src/gcode/sd/M21_M22.cpp index f561229b17..672dc80f00 100644 --- a/Marlin/src/gcode/sd/M21_M22.cpp +++ b/Marlin/src/gcode/sd/M21_M22.cpp @@ -38,9 +38,9 @@ void GcodeSuite::M21() { #if HAS_MULTI_VOLUME const int8_t vol = parser.intval('P', -1); if (vol == 0 || parser.seen_test('S')) // "S" for SD Card - card.changeMedia(&card.media_driver_sdcard); + card.selectMediaSDCard(); else if (vol == 1 || parser.seen_test('U')) // "U" for USB - card.changeMedia(&card.media_driver_usbFlash); + card.selectMediaFlashDrive(); #endif card.mount(); } diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index 3b01077931..a9427c3605 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -1248,10 +1248,17 @@ #if ENABLED(MULTI_VOLUME) #define HAS_MULTI_VOLUME 1 + #define SV_SD_ONBOARD 101 + #define SV_USB_FLASH_DRIVE 102 + #define _VOLUME_ID(N) _CAT(SV_, N) + #define SHARED_VOLUME_IS(N) (DEFAULT_SHARED_VOLUME == _VOLUME_ID(N)) +#else + #define SHARED_VOLUME_IS(...) 0 #endif -#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + +#if ANY(USB_FLASH_DRIVE_SUPPORT, VOLUME_USB_FLASH_DRIVE) #define HAS_USB_FLASH_DRIVE 1 - #if NONE(USE_OTG_USB_HOST, USE_UHS3_USB) + #if NONE(USE_OTG_USB_HOST, USE_UHS2_USB, USE_UHS3_USB) #define USE_UHS2_USB #endif #endif diff --git a/Marlin/src/inc/Conditionals-5-post.h b/Marlin/src/inc/Conditionals-5-post.h index fd06285bca..ae9074ec89 100644 --- a/Marlin/src/inc/Conditionals-5-post.h +++ b/Marlin/src/inc/Conditionals-5-post.h @@ -550,7 +550,9 @@ #endif #endif + // Tests indicating a single or multi-volume SD Card #if !HAS_USB_FLASH_DRIVE || ALL(HAS_MULTI_VOLUME, VOLUME_SD_ONBOARD) + #define HAS_SDCARD 1 #if ENABLED(ONBOARD_SDIO) #define NEED_SD2CARD_SDIO 1 #else diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 970847ecb5..3182d93e92 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3943,7 +3943,7 @@ static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive." #if HAS_USB_FLASH_DRIVE && DISABLED(USE_OTG_USB_HOST) && !PINS_EXIST(USB_CS, USB_INTR) #error "USB_CS_PIN and USB_INTR_PIN (or USE_OTG_USB_HOST) are required for USB_FLASH_DRIVE_SUPPORT." -#elif ENABLED(USE_OTG_USB_HOST) && !defined(HAS_OTG_USB_HOST_SUPPORT) +#elif ENABLED(USE_OTG_USB_HOST) && DISABLED(HAS_OTG_USB_HOST_SUPPORT) #error "The current board does not support USE_OTG_USB_HOST." #endif diff --git a/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp b/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp index 25a9238705..a327f2f33e 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp @@ -46,8 +46,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; lv_clear_media_select(); switch (obj->mks_obj_id) { - case ID_T_USB_DISK: card.changeMedia(&card.media_driver_usbFlash); break; - case ID_T_SD_DISK: card.changeMedia(&card.media_driver_sdcard); break; + case ID_T_USB_DISK: card.selectMediaFlashDrive(); break; + case ID_T_SD_DISK: card.selectMediaSDCard(); break; case ID_T_RETURN: TERN_(MKS_TEST, current_disp_ui = 1); lv_draw_ready_print(); diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp index 7a56cf371f..e138449181 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -135,18 +135,19 @@ void tft_lvgl_init() { hal.watchdog_refresh(); // LVGL init takes time #if HAS_USB_FLASH_DRIVE - uint16_t usb_flash_loop = 1000; #if HAS_MULTI_VOLUME && !HAS_SD_HOST_DRIVE if (IS_SD_INSERTED()) - card.changeMedia(&card.media_driver_sdcard); + card.selectMediaSDCard(); else - card.changeMedia(&card.media_driver_usbFlash); + card.selectMediaFlashDrive(); #endif - do { - card.media_driver_usbFlash.idle(); + // Wait up to two seconds for USB Drive to mount + for (uint16_t usb_flash_loop = 500; --usb_flash_loop;) { hal.watchdog_refresh(); - delay(2); - } while (!card.media_driver_usbFlash.isInserted() && usb_flash_loop--); + card.media_driver_usbFlash.idle(); + delay(4); + if (card.media_driver_usbFlash.isInserted()) break; + } card.mount(); #elif HAS_LOGO_IN_FLASH delay(1000); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 7f78d21bf3..1726c67930 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1114,7 +1114,7 @@ void MarlinUI::init() { #if MARLINUI_SCROLL_NAME // If scrolling of long file names is enabled and we are in the sd card menu, // cause a refresh to occur until all the text has scrolled into view. - if (currentScreen == menu_media_filelist && filename_scroll_max && !lcd_status_update_delay--) { + if (currentScreen == menu_file_selector && filename_scroll_max && !lcd_status_update_delay--) { lcd_status_update_delay = ++filename_scroll_pos >= filename_scroll_max ? 12 : 4; // Long delay at end and start if (filename_scroll_pos > filename_scroll_max) filename_scroll_pos = 0; refresh(LCDVIEW_REDRAW_NOW); diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 80a84af1ba..b7861655e2 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -211,7 +211,7 @@ void menu_main(); void menu_move(); #if HAS_MEDIA - void menu_media_filelist(); + void menu_file_selector(); void menu_media(); #endif diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index 8633551672..8747685fe5 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -45,7 +45,7 @@ void lcd_sd_updir() { void MarlinUI::reselect_last_file() { if (sd_encoder_position == 0xFFFF) return; - goto_screen(menu_media_filelist, sd_encoder_position, sd_top_line, sd_items); + goto_screen(menu_file_selector, sd_encoder_position, sd_top_line, sd_items); sd_encoder_position = 0xFFFF; defer_status_screen(); } @@ -105,11 +105,11 @@ class MenuItem_sdfolder : public MenuItem_sdbase { void menu_media_select() { START_MENU(); BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN_MENU) : GET_TEXT_F(MSG_BACK)); - #if ENABLED(VOLUME_SD_ONBOARD) - ACTION_ITEM(MSG_SD_CARD, []{ card.changeMedia(&card.media_driver_sdcard); card.mount(); ui.goto_screen(menu_media_filelist); }); + #if HAS_SDCARD + ACTION_ITEM(MSG_SD_CARD, []{ card.selectMediaSDCard(); card.mount(); ui.goto_screen(menu_file_selector); }); #endif - #if ENABLED(VOLUME_USB_FLASH_DRIVE) - ACTION_ITEM(MSG_USB_DISK, []{ card.changeMedia(&card.media_driver_usbFlash); card.mount(); ui.goto_screen(menu_media_filelist); }); + #if HAS_USB_FLASH_DRIVE + ACTION_ITEM(MSG_USB_DISK, []{ card.selectMediaFlashDrive(); card.mount(); ui.goto_screen(menu_file_selector); }); #endif END_MENU(); } @@ -117,14 +117,14 @@ class MenuItem_sdfolder : public MenuItem_sdbase { /** * "Select From Media" menu item. Depending on single or multiple drives: - * - menu_media_filelist - List files on the current media - * - menu_media_select - Select one of the attached drives, then go to the file list + * - menu_file_selector - List files on the current media + * - menu_media_select - Select one of the attached drives, then go to the file list */ void menu_media() { - ui.goto_screen(TERN(HAS_MULTI_VOLUME, menu_media_select, menu_media_filelist)); + ui.goto_screen(TERN(HAS_MULTI_VOLUME, menu_media_select, menu_file_selector)); } -void menu_media_filelist() { +void menu_file_selector() { ui.encoder_direction_menus(); #if HAS_MARLINUI_U8GLIB diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 647e071c72..cd20f921db 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -28,6 +28,10 @@ #if HAS_MEDIA +#if HAS_MULTI_VOLUME && !SHARED_VOLUME_IS(SD_ONBOARD) && !SHARED_VOLUME_IS(USB_FLASH_DRIVE) + #error "DEFAULT_SHARED_VOLUME must be either SV_SD_ONBOARD or SV_USB_FLASH_DRIVE." +#endif + //#define DEBUG_CARDREADER #include "cardreader.h" @@ -132,12 +136,12 @@ int16_t CardReader::nrItems = -1; #endif // SDCARD_SORT_ALPHA -#if HAS_USB_FLASH_DRIVE - DiskIODriver_USBFlash CardReader::media_driver_usbFlash; +#if HAS_SDCARD + CardReader::sdcard_driver_t CardReader::media_driver_sdcard; #endif -#if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI - CardReader::sdcard_driver_t CardReader::media_driver_sdcard; +#if HAS_USB_FLASH_DRIVE + DiskIODriver_USBFlash CardReader::media_driver_usbFlash; #endif DiskIODriver* CardReader::driver = nullptr; @@ -153,13 +157,11 @@ MediaFile CardReader::file; uint32_t CardReader::filesize, CardReader::sdpos; CardReader::CardReader() { - changeMedia(& - #if HAS_USB_FLASH_DRIVE && !SHARED_VOLUME_IS(SD_ONBOARD) - media_driver_usbFlash - #else - media_driver_sdcard - #endif - ); + #if HAS_USB_FLASH_DRIVE && !SHARED_VOLUME_IS(SD_ONBOARD) + selectMediaFlashDrive(); + #else + selectMediaSDCard(); + #endif #if ENABLED(SDCARD_SORT_ALPHA) sort_count = 0; diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index eeead4e490..7dfe7e344f 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -60,18 +60,6 @@ extern const char M23_STR[], M24_STR[]; #include "Sd2Card.h" #endif -#if HAS_MULTI_VOLUME - #define SV_SD_ONBOARD 1 - #define SV_USB_FLASH_DRIVE 2 - #define _VOLUME_ID(N) _CAT(SV_, N) - #define SHARED_VOLUME_IS(N) (DEFAULT_SHARED_VOLUME == _VOLUME_ID(N)) - #if !SHARED_VOLUME_IS(SD_ONBOARD) && !SHARED_VOLUME_IS(USB_FLASH_DRIVE) - #error "DEFAULT_SHARED_VOLUME must be either SD_ONBOARD or USB_FLASH_DRIVE." - #endif -#else - #define SHARED_VOLUME_IS(...) 0 -#endif - typedef struct { bool saving:1, // Receiving a G-code file or logging commands during a print logging:1, // Log enqueued commands to the open file. See GCodeQueue::advance() @@ -114,15 +102,76 @@ public: CardReader(); + /** + * Media Selection - Only one drive may be active at a time, + * so switching drives (currently) returns to the root folder. + * TODO: Save the last-used path for each device and cd on mount. + */ static void changeMedia(DiskIODriver *_driver) { driver = _driver; } - static MediaFile getroot() { return root; } + static DiskIODriver* diskIODriver() { return driver; } + #if HAS_SDCARD + typedef TERN(NEED_SD2CARD_SDIO, DiskIODriver_SDIO, DiskIODriver_SPI_SD) sdcard_driver_t; + static sdcard_driver_t media_driver_sdcard; + #endif + + #if HAS_USB_FLASH_DRIVE + static DiskIODriver_USBFlash media_driver_usbFlash; + #endif + + static void selectMediaSDCard() { + #if HAS_SDCARD + changeMedia(&media_driver_sdcard); + #endif + } + + static void selectMediaFlashDrive() { + #if HAS_USB_FLASH_DRIVE + changeMedia(&media_driver_usbFlash); + #endif + } + + static bool isSDCardSelected() { + return TERN0(HAS_SDCARD, TERN1(HAS_MULTI_VOLUME, driver == &media_driver_sdcard)); + } + static bool isFlashDriveSelected() { + return TERN0(HAS_USB_FLASH_DRIVE, TERN1(HAS_MULTI_VOLUME, driver == &media_driver_usbFlash)); + } + static bool isMediaSelected() { + return isSDCardSelected() || isFlashDriveSelected(); + } + + /** + * Media Detection - Inserted, Mounted, Job Running, Job Paused, etc. + * + * Marlin 2.1.x supports up to two drives, either an SD Card or USB-FD + * Onboard SD may have SPI or SDIO interface. USB FD may use MSC. + */ + + // No card detect line? Assume the card is inserted. + static bool isSDCardInserted() { + return ( + #if HAS_SD_DETECT + READ(SD_DETECT_PIN) == SD_DETECT_STATE + #else + ENABLED(HAS_SDCARD) + #endif + ); + } + + // Use the isInserted state from the driver + static bool isFlashDriveInserted() { return TERN0(HAS_USB_FLASH_DRIVE, DiskIODriver_USBFlash::isInserted()); } + + // NOTE: If the SD Card has no DETECT line this always returns true + static bool isInserted() { return isFlashDriveInserted() || isSDCardInserted(); } + + // Mount and release physical media static void mount(); static void release(); static bool isMounted() { return flag.mounted; } - // Handle media insert/remove + // Handle media insert/remove (including mounting on boot-up) static void manage_media(); // SD Card Logging @@ -142,6 +191,9 @@ public: static bool selectNewestFile(); #endif + // The root directory of the current mounted drive + static MediaFile getroot() { return root; } + // Basic file ops static void openFileRead(const char * const path, const uint8_t subcall=0); static void openFileWrite(const char * const path); @@ -232,7 +284,7 @@ public: // Current Working Dir - Set by cd, cdup, cdroot, and diveToFile(true, ...) static char* getWorkDirName() { workDir.getDosName(filename); return filename; } - static MediaFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } + static MediaFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } // Print File stats static uint32_t getFileSize() { return filesize; } @@ -246,9 +298,6 @@ public: static int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } static void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); } - // TODO: rename to diskIODriver() - static DiskIODriver* diskIODriver() { return driver; } - #if ENABLED(AUTO_REPORT_SD_STATUS) // // SD Auto Reporting @@ -257,17 +306,17 @@ public: static AutoReporter auto_reporter; #endif - #if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || HAS_USB_FLASH_DRIVE - #define HAS_USB_FLASH_DRIVE 1 - static DiskIODriver_USBFlash media_driver_usbFlash; - #endif - - #if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI - typedef TERN(NEED_SD2CARD_SDIO, DiskIODriver_SDIO, DiskIODriver_SPI_SD) sdcard_driver_t; - static sdcard_driver_t media_driver_sdcard; - #endif - private: + // + // Driver, volume, and temporary file + // + static DiskIODriver *driver; + static MarlinVolume volume; + + static MediaFile file; + static uint32_t filesize, // Total size of the current file, in bytes + sdpos; // Index most recently read (one behind file.getPos) + // // Working directory and parents // @@ -330,13 +379,6 @@ private: #endif // SDCARD_SORT_ALPHA - static DiskIODriver *driver; - static MarlinVolume volume; - static MediaFile file; - - static uint32_t filesize, // Total size of the current file, in bytes - sdpos; // Index most recently read (one behind file.getPos) - // // Procedure calls to other files // diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 455ba6ba0a..2ae38c64c0 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -179,82 +179,82 @@ void DiskIODriver_USBFlash::idle() { } #endif - static millis_t next_state_ms = millis(); + static millis_t next_state_ms = 0; #define GOTO_STATE_AFTER_DELAY(STATE, DELAY) do{ state = STATE; next_state_ms = millis() + DELAY; }while(0) - if (ELAPSED(millis(), next_state_ms)) { - GOTO_STATE_AFTER_DELAY(state, 250); // Default delay + if (PENDING(millis(), next_state_ms)) return; - switch (state) { + GOTO_STATE_AFTER_DELAY(state, 250); // Default delay - case UNINITIALIZED: - #ifndef MANUAL_USB_STARTUP - GOTO_STATE_AFTER_DELAY( DO_STARTUP, USB_STARTUP_DELAY ); + switch (state) { + + case UNINITIALIZED: + #ifndef MANUAL_USB_STARTUP + GOTO_STATE_AFTER_DELAY( DO_STARTUP, USB_STARTUP_DELAY ); + #endif + break; + + case DO_STARTUP: usbStartup(); break; + + case WAIT_FOR_DEVICE: + if (task_state == UHS_STATE(RUNNING)) { + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("USB device inserted"); #endif - break; + GOTO_STATE_AFTER_DELAY( WAIT_FOR_LUN, 250 ); + } + break; - case DO_STARTUP: usbStartup(); break; + case WAIT_FOR_LUN: + /* USB device is inserted, but if it is an SD card, + * adapter it may not have an SD card in it yet. */ + if (bulk.LUNIsGood(0)) { + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("LUN is good"); + #endif + GOTO_STATE_AFTER_DELAY( MEDIA_READY, 100 ); + } + else { + #ifdef USB_HOST_MANUAL_POLL + // Make sure we catch disconnect events + usb.busprobe(); + usb.VBUS_changed(); + #endif + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("Waiting for media"); + #endif + LCD_MESSAGE(MSG_MEDIA_WAITING); + GOTO_STATE_AFTER_DELAY(state, 2000); + } + break; - case WAIT_FOR_DEVICE: - if (task_state == UHS_STATE(RUNNING)) { - #if USB_DEBUG >= 1 - SERIAL_ECHOLNPGM("USB device inserted"); - #endif - GOTO_STATE_AFTER_DELAY( WAIT_FOR_LUN, 250 ); - } - break; + case MEDIA_READY: break; + case MEDIA_ERROR: break; + } - case WAIT_FOR_LUN: - /* USB device is inserted, but if it is an SD card, - * adapter it may not have an SD card in it yet. */ - if (bulk.LUNIsGood(0)) { - #if USB_DEBUG >= 1 - SERIAL_ECHOLNPGM("LUN is good"); - #endif - GOTO_STATE_AFTER_DELAY( MEDIA_READY, 100 ); - } - else { - #ifdef USB_HOST_MANUAL_POLL - // Make sure we catch disconnect events - usb.busprobe(); - usb.VBUS_changed(); - #endif - #if USB_DEBUG >= 1 - SERIAL_ECHOLNPGM("Waiting for media"); - #endif - LCD_MESSAGE(MSG_MEDIA_WAITING); - GOTO_STATE_AFTER_DELAY(state, 2000); - } - break; + if (state > WAIT_FOR_DEVICE && task_state != UHS_STATE(RUNNING)) { + // Handle device removal events + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("USB device removed"); + #endif + if (state != MEDIA_READY) + LCD_MESSAGE(MSG_MEDIA_USB_REMOVED); + GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); + } - case MEDIA_READY: break; - case MEDIA_ERROR: break; - } + else if (state > WAIT_FOR_LUN && !bulk.LUNIsGood(0)) { + // Handle media removal events + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("Media removed"); + #endif + LCD_MESSAGE(MSG_MEDIA_REMOVED); + GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); + } - if (state > WAIT_FOR_DEVICE && task_state != UHS_STATE(RUNNING)) { - // Handle device removal events - #if USB_DEBUG >= 1 - SERIAL_ECHOLNPGM("USB device removed"); - #endif - if (state != MEDIA_READY) - LCD_MESSAGE(MSG_MEDIA_USB_REMOVED); - GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); - } - - else if (state > WAIT_FOR_LUN && !bulk.LUNIsGood(0)) { - // Handle media removal events - #if USB_DEBUG >= 1 - SERIAL_ECHOLNPGM("Media removed"); - #endif - LCD_MESSAGE(MSG_MEDIA_REMOVED); - GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); - } - - else if (task_state == UHS_STATE(ERROR)) { - LCD_MESSAGE(MSG_MEDIA_READ_ERROR); - GOTO_STATE_AFTER_DELAY(MEDIA_ERROR, 0); - } + else if (task_state == UHS_STATE(ERROR)) { + LCD_MESSAGE(MSG_MEDIA_READ_ERROR); + GOTO_STATE_AFTER_DELAY(MEDIA_ERROR, 0); } } From 5c0e8d594d343d4e38f6d2254916077e0f3a3c7d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 21 Apr 2025 20:00:49 -0500 Subject: [PATCH 30/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Stub?= =?UTF-8?q?=20CardReader,=20proper=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp | 2 +- Marlin/src/HAL/LPC1768/HAL.cpp | 4 +- Marlin/src/HAL/STM32F1/HAL.cpp | 2 +- Marlin/src/MarlinCore.cpp | 12 +++-- Marlin/src/feature/mmu3/mmu3.cpp | 2 +- Marlin/src/feature/pause.cpp | 2 +- Marlin/src/feature/powerloss.cpp | 8 ++-- Marlin/src/gcode/feature/pause/M125.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/lcd/M73.cpp | 2 +- Marlin/src/gcode/queue.cpp | 2 +- Marlin/src/gcode/sd/M21_M22.cpp | 2 +- Marlin/src/gcode/sd/M24_M25.cpp | 2 +- Marlin/src/gcode/sd/M32.cpp | 2 +- Marlin/src/gcode/sd/M524.cpp | 2 +- Marlin/src/gcode/stats/M75-M78.cpp | 2 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 2 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 2 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 2 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 6 +-- .../generic/about_screen.cpp | 6 +-- Marlin/src/lcd/extui/mks_ui/draw_ui.cpp | 13 ----- Marlin/src/lcd/extui/mks_ui/draw_ui.h | 1 - .../lcd/extui/mks_ui/printer_operation.cpp | 2 +- .../extui/mks_ui/tft_lvgl_configuration.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 7 +-- Marlin/src/lcd/marlinui.cpp | 6 +-- Marlin/src/lcd/sovol_rts/sovol_rts.cpp | 10 ++-- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 32 ++++++------- Marlin/src/sd/cardreader.h | 48 ++++++++----------- 31 files changed, 85 insertions(+), 106 deletions(-) diff --git a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp index cf6739c5bd..ff6ff4859b 100644 --- a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp +++ b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp @@ -19,7 +19,7 @@ void sd_mmc_spi_mem_init() { } inline bool media_ready() { - return IS_SD_MOUNTED() && IS_SD_INSERTED() && !IS_SD_FILE_OPEN() && !IS_SD_PRINTING(); + return card.isMounted() && card.isInserted() && !card.isFileOpen() && !card.isStillPrinting(); } bool sd_mmc_spi_unload(bool) { return true; } diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index 55658acb76..6e4357777d 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -175,11 +175,11 @@ void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // If Marlin is using the SD card we need to lock it to prevent access from // a PC via USB. - // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but + // Other HALs use card.isStillPrinting() and card.isFileOpen() to check for access but // this will not reliably detect delete operations. To be safe we will lock // the disk if Marlin has it mounted. Unfortunately there is currently no way // to unmount the disk from the LCD menu. - // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN()) + // if (card.isStillPrinting() || card.isFileOpen()) if (card.isMounted()) MSC_Aquire_Lock(); else diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index e6cbb9fc06..d5f4ade79d 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -264,7 +264,7 @@ void MarlinHAL::idletask() { /** * When Marlin is using the SD card it should be locked to prevent it being * accessed from a PC over USB. - * Other HALs use (IS_SD_PRINTING() || IS_SD_FILE_OPEN()) to check for access + * Other HALs use (card.isStillPrinting() || card.isFileOpen()) to check for access * but this won't reliably detect other file operations. To be safe we just lock * the drive whenever Marlin has it mounted. LCDs should include an Unmount * command so drives can be released as needed. diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index f2b2589ee6..05355ddccb 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -269,6 +269,10 @@ #include "feature/rs485.h" #endif +#if !HAS_MEDIA + CardReader card; // Stub instance with "no media" methods +#endif + PGMSTR(M112_KILL_STR, "M112 Shutdown"); #if ENABLED(CONFIGURABLE_MACHINE_NAME) @@ -339,7 +343,7 @@ bool printer_busy() { /** * A Print Job exists when the timer is running or SD is printing */ -bool printJobOngoing() { return print_job_timer.isRunning() || IS_SD_PRINTING(); } +bool printJobOngoing() { return print_job_timer.isRunning() || card.isStillPrinting(); } /** * Printing is active when a job is underway but not paused @@ -350,7 +354,7 @@ bool printingIsActive() { return !did_pause_print && printJobOngoing(); } * Printing is paused according to SD or host indicators */ bool printingIsPaused() { - return did_pause_print || print_job_timer.isPaused() || IS_SD_PAUSED(); + return did_pause_print || print_job_timer.isPaused() || card.isPaused(); } void startOrResumeJob() { @@ -509,7 +513,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { // Handle a standalone HOME button constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL; static millis_t next_home_key_ms; // = 0 - if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed + if (!card.isStillPrinting() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed if (ELAPSED(ms, next_home_key_ms)) { next_home_key_ms = ms + HOME_DEBOUNCE_DELAY; LCD_MESSAGE(MSG_AUTO_HOME); @@ -804,7 +808,7 @@ void idle(const bool no_stepper_sleep/*=false*/) { // Handle Power-Loss Recovery #if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS) - if (IS_SD_PRINTING()) recovery.outage(); + if (card.isStillPrinting()) recovery.outage(); #endif // Run StallGuard endstop checks diff --git a/Marlin/src/feature/mmu3/mmu3.cpp b/Marlin/src/feature/mmu3/mmu3.cpp index b4d4c76afc..27a1dc05c9 100644 --- a/Marlin/src/feature/mmu3/mmu3.cpp +++ b/Marlin/src/feature/mmu3/mmu3.cpp @@ -456,7 +456,7 @@ namespace MMU3 { if (slot != extruder) { if ( //findaDetectsFilament() - //!IS_SD_PRINTING() && !usb_timer.running() + //!card.isStillPrinting() && !usb_timer.running() !marlin_printingIsActive() ) { // If Tcodes are used manually through the serial diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index fbb78ccbf9..bd86133771 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -439,7 +439,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool // Pause the print job and timer #if HAS_MEDIA - const bool was_sd_printing = IS_SD_PRINTING(); + const bool was_sd_printing = card.isStillPrinting(); if (was_sd_printing) { card.pauseSDPrint(); ++did_pause_print; // Indicate SD pause also diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 3cd96e1155..27f3e44ca5 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -117,7 +117,7 @@ void PrintJobRecovery::enable(const bool onoff) { void PrintJobRecovery::changed() { if (!enabled) purge(); - else if (IS_SD_PRINTING()) + else if (card.isStillPrinting()) save(true); TERN_(EXTENSIBLE_UI, ExtUI::onSetPowerLoss(enabled)); } @@ -174,7 +174,7 @@ void PrintJobRecovery::prepare() { */ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POWER_LOSS_ZRAISE*/, const bool raised/*=false*/) { - // We don't check IS_SD_PRINTING here so a save may occur during a pause + // We don't check isStillPrinting here so a save may occur during a pause #if SAVE_INFO_INTERVAL_MS > 0 static millis_t next_save_ms; // = 0 @@ -202,7 +202,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW // Set Head and Foot to matching non-zero values if (!++info.valid_head) ++info.valid_head; // non-zero in sequence - //if (!IS_SD_PRINTING()) info.valid_head = 0; + //if (!card.isStillPrinting()) info.valid_head = 0; info.valid_foot = info.valid_head; // Machine state @@ -326,7 +326,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW // Save the current position, distance that Z was (or should be) raised, // and a flag whether the raise was already done here. - if (IS_SD_PRINTING()) save(true, zraise, ENABLED(BACKUP_POWER_SUPPLY)); + if (card.isStillPrinting()) save(true, zraise, ENABLED(BACKUP_POWER_SUPPLY)); // Tell the LCD about the outage, even though it is about to die TERN_(EXTENSIBLE_UI, ExtUI::onPowerLoss()); diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index 71fa7c7b4d..75611760f1 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -88,7 +88,7 @@ void GcodeSuite::M125() { park_point += hotend_offset[active_extruder]; #endif - const bool sd_printing = IS_SD_PRINTING(); + const bool sd_printing = card.isStillPrinting(); ui.pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 6dfc54d99e..469ab134d3 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -196,7 +196,7 @@ void GcodeSuite::get_destination_from_command() { #if ENABLED(POWER_LOSS_RECOVERY) && !PIN_EXISTS(POWER_LOSS) // Only update power loss recovery on moves with E - if (recovery.enabled && IS_SD_PRINTING() && seen.e && (seen.x || seen.y)) + if (recovery.enabled && card.isStillPrinting() && seen.e && (seen.x || seen.y)) recovery.save(); #endif diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index 6f74476240..5d9b3bd107 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -62,7 +62,7 @@ void GcodeSuite::M73() { #endif #if ENABLED(M73_REPORT) - if (TERN1(M73_REPORT_SD_ONLY, IS_SD_PRINTING())) { + if (TERN1(M73_REPORT_SD_ONLY, card.isStillPrinting())) { SERIAL_ECHO_START(); SERIAL_ECHOPGM(" M73"); #if ENABLED(SET_PROGRESS_PERCENT) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 657bfab08b..7fa55b70e8 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -570,7 +570,7 @@ void GCodeQueue::get_serial_commands() { static uint8_t sd_input_state = PS_NORMAL; // Get commands if there are more in the file - if (!IS_SD_FETCHING()) return; + if (!card.isStillFetching()) return; int sd_count = 0; while (!ring_buffer.full() && !card.eof()) { diff --git a/Marlin/src/gcode/sd/M21_M22.cpp b/Marlin/src/gcode/sd/M21_M22.cpp index 672dc80f00..eb1594fbaf 100644 --- a/Marlin/src/gcode/sd/M21_M22.cpp +++ b/Marlin/src/gcode/sd/M21_M22.cpp @@ -49,7 +49,7 @@ void GcodeSuite::M21() { * M22: Release SD Card */ void GcodeSuite::M22() { - if (!IS_SD_PRINTING()) card.release(); + if (!card.isStillPrinting()) card.release(); } #endif // HAS_MEDIA diff --git a/Marlin/src/gcode/sd/M24_M25.cpp b/Marlin/src/gcode/sd/M24_M25.cpp index 7bf1ab74d5..f4ad7c7dab 100644 --- a/Marlin/src/gcode/sd/M24_M25.cpp +++ b/Marlin/src/gcode/sd/M24_M25.cpp @@ -101,7 +101,7 @@ void GcodeSuite::M25() { #else // Set initial pause flag to prevent more commands from landing in the queue while we try to pause - if (IS_SD_PRINTING()) card.pauseSDPrint(); + if (card.isStillPrinting()) card.pauseSDPrint(); #if ENABLED(POWER_LOSS_RECOVERY) && DISABLED(DGUS_LCD_UI_MKS) if (recovery.enabled) recovery.save(true); diff --git a/Marlin/src/gcode/sd/M32.cpp b/Marlin/src/gcode/sd/M32.cpp index 3baa552e6e..552a75cdf4 100644 --- a/Marlin/src/gcode/sd/M32.cpp +++ b/Marlin/src/gcode/sd/M32.cpp @@ -40,7 +40,7 @@ * M32 S60 !PATH/TO/FILE.GCO# ; Start FILE.GCO at byte 60 */ void GcodeSuite::M32() { - if (IS_SD_PRINTING()) planner.synchronize(); + if (card.isStillPrinting()) planner.synchronize(); if (card.isMounted()) { const uint8_t call_procedure = parser.boolval('P'); diff --git a/Marlin/src/gcode/sd/M524.cpp b/Marlin/src/gcode/sd/M524.cpp index 61185b7e0b..d72aa0ac35 100644 --- a/Marlin/src/gcode/sd/M524.cpp +++ b/Marlin/src/gcode/sd/M524.cpp @@ -42,7 +42,7 @@ void GcodeSuite::M524() { #else - if (IS_SD_PRINTING()) + if (card.isStillPrinting()) card.abortFilePrintSoon(); else if (card.isMounted()) card.closefile(); diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 8ab94577ef..4e1b1aff9d 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -43,7 +43,7 @@ void GcodeSuite::M75() { startOrResumeJob(); // ... ExtUI::onPrintTimerStarted() #if ENABLED(DWIN_LCD_PROUI) // TODO: Remove if M75 is never used - if (!IS_SD_PRINTING()) dwinPrintHeader(parser.has_string() ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); + if (!card.isStillPrinting()) dwinPrintHeader(parser.has_string() ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); #endif } diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index a0145d6165..265f62ab88 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -841,7 +841,7 @@ void MarlinUI::draw_status_message(const bool blink) { const uint8_t progress = get_progress_percent(); if (progress) { lcd_moveto(pc, pr); - lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:"))); + lcd_put_u8str(card.isStillPrinting() ? F("SD") : F("P:")); lcd_put_u8str(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(get_progress_permyriad()), ui8tostr3rj(progress))); lcd_put_u8str(F("%")); } diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 6766820cfd..4ac012ba93 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -603,7 +603,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const const uint8_t progress = ui.get_progress_percent(); if (progress) { lcd_moveto(0, 2); - lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:"))); + lcd_put_u8str(card.isStillPrinting() ? F("SD") : F("P:")); lcd.print(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress))); lcd.write('%'); } diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index d582b96ed7..aa087cefc4 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -4653,7 +4653,7 @@ void JyersDWIN::popupControl() { #if ENABLED(PARK_HEAD_ON_PAUSE) popupHandler(Popup_Home, true); #if HAS_MEDIA - if (IS_SD_PRINTING()) card.pauseSDPrint(); + if (card.isStillPrinting()) card.pauseSDPrint(); #endif planner.synchronize(); queue.inject(F("M125")); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 7428a4b254..b1df0234b0 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -294,9 +294,9 @@ MenuItem *fanSpeedItem = nullptr; MenuItem *mMeshMoveZItem = nullptr; MenuItem *editZValueItem = nullptr; -bool isPrinting() { return printingIsActive() || printingIsPaused(); } -bool sdPrinting() { return isPrinting() && IS_SD_FILE_OPEN(); } -bool hostPrinting() { return isPrinting() && !IS_SD_FILE_OPEN(); } +bool isPrinting() { return printingIsActive() || printingIsPaused(); } +bool sdPrinting() { return isPrinting() && card.isStillPrinting(); } +bool hostPrinting() { return isPrinting() && !card.isStillPrinting(); } #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp index eac6e646e6..366151959b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp @@ -62,11 +62,11 @@ void AboutScreen::onRedraw(draw_mode_t) { #ifdef LULZBOT_LCD_MACHINE_NAME cmd.tag(3); draw_text_box(cmd, BTN_POS(1,7), BTN_SIZE(4,3), F( - "Firmware:" + "Firmware:" ), OPT_CENTER, font_xlarge); draw_text_box(cmd, BTN_POS(1,10), BTN_SIZE(4,2), F( - "" LULZBOT_M115_EXTRUDER_TYPE "" + "" LULZBOT_M115_EXTRUDER_TYPE "" ), OPT_CENTER, font_xlarge); #endif @@ -77,7 +77,7 @@ void AboutScreen::onRedraw(draw_mode_t) { #endif draw_text_box(cmd, BTN_POS(1,19), BTN_SIZE(4,3), F( - "Version:" + "Version:" ), OPT_CENTER, font_xlarge); draw_text_box(cmd, BTN_POS(1,22), BTN_SIZE(4,2), F( diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 92cc17f8cc..2e66db2c86 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -1332,19 +1332,6 @@ void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue) { lv_label_set_text((lv_obj_t*)btn->child_ll.head, curValue ? machine_menu.enable : machine_menu.disable); } -#if HAS_MEDIA - - void sd_detection() { - static bool last_sd_status; - const bool sd_status = IS_SD_INSERTED(); - if (sd_status != last_sd_status) { - last_sd_status = sd_status; - if (sd_status) card.mount(); else card.release(); - } - } - -#endif - void lv_ex_line(lv_obj_t *line, lv_point_t *points) { // Copy the previous line and apply the new style lv_line_set_points(line, points, 2); // Set the points diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/mks_ui/draw_ui.h index 10b8dcee28..33a0764d2c 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.h @@ -468,7 +468,6 @@ void GUI_RefreshPage(); void clear_cur_ui(); void draw_return_ui(); void goto_previous_ui(); -void sd_detection(); void gCfg_to_spiFlah(); void print_time_count(); diff --git a/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp b/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp index dc47cdb357..9999aa4843 100644 --- a/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp +++ b/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp @@ -88,7 +88,7 @@ void printer_state_polling() { } if (uiCfg.print_state == RESUMING) { - if (IS_SD_PAUSED()) { + if (card.isPaused()) { if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) { sprintf_P(public_buf_m, PSTR("G1 X%s Y%s"), dtostrf(uiCfg.current_x_position_bak, 1, 1, str_1), dtostrf(uiCfg.current_y_position_bak, 1, 1, str_1)); gcode.process_subcommands_now(public_buf_m); diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp index e138449181..729d8bc4b2 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -136,7 +136,7 @@ void tft_lvgl_init() { #if HAS_USB_FLASH_DRIVE #if HAS_MULTI_VOLUME && !HAS_SD_HOST_DRIVE - if (IS_SD_INSERTED()) + if (card.isSDCardInserted()) card.selectMediaSDCard(); else card.selectMediaFlashDrive(); diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index b88df6ee9d..7763bac05a 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -1064,11 +1064,8 @@ namespace ExtUI { TERN(HAS_MEDIA, card.openAndPrintFile(filename), UNUSED(filename)); } - bool isPrintingFromMediaPaused() { - return IS_SD_PAUSED(); - } - - bool isPrintingFromMedia() { return IS_SD_PRINTING() || IS_SD_PAUSED(); } + bool isPrintingFromMedia() { return card.isStillPrinting() || card.isPaused(); } + bool isPrintingFromMediaPaused() { return card.isPaused(); } bool isPrinting() { return commandsInQueue() || isPrintingFromMedia() || printJobOngoing() || printingIsPaused(); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 1726c67930..8b7e64dda8 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1540,7 +1540,7 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, if (printingIsPaused()) msg = GET_TEXT_F(MSG_PRINT_PAUSED); #if HAS_MEDIA - else if (IS_SD_PRINTING()) + else if (card.isStillPrinting()) return set_status_no_expire(card.longest_filename()); #endif else if (print_job_timer.isRunning()) @@ -1743,7 +1743,7 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, void MarlinUI::abort_print() { #if HAS_MEDIA wait_for_heatup = wait_for_user = false; - if (IS_SD_PRINTING()) + if (card.isStillPrinting()) card.abortFilePrintSoon(); else if (card.isMounted()) card.closefile(); @@ -1810,7 +1810,7 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, void MarlinUI::resume_print() { reset_status(); TERN_(PARK_HEAD_ON_PAUSE, wait_for_heatup = wait_for_user = false); - TERN_(HAS_MEDIA, if (IS_SD_PAUSED()) queue.inject_P(M24_STR)); + TERN_(HAS_MEDIA, if (card.isPaused()) queue.inject_P(M24_STR)); #ifdef ACTION_ON_RESUME hostui.resume(); #endif diff --git a/Marlin/src/lcd/sovol_rts/sovol_rts.cpp b/Marlin/src/lcd/sovol_rts/sovol_rts.cpp index dcd5d9b384..bea95be96a 100644 --- a/Marlin/src/lcd/sovol_rts/sovol_rts.cpp +++ b/Marlin/src/lcd/sovol_rts/sovol_rts.cpp @@ -171,7 +171,7 @@ void RTS::sdCardInit() { // Clear the file name displayed in the print interface sendData(0, PRINT_FILE_TEXT_VP + j); } - lcd_sd_status = IS_SD_INSERTED(); + lcd_sd_status = card.isInserted(); } else { // Clean all filename Icons @@ -186,7 +186,7 @@ bool RTS::sdDetected() { static bool state = false, stable = false, was_present = false; static millis_t stable_ms = 0; - const bool present = IS_SD_INSERTED(); + const bool present = card.isInserted(); if (present != was_present) stable = false; else if (!stable) { @@ -1485,7 +1485,7 @@ void RTS::handleData() { sendData(cardRec.display_filename[cardRec.recordcount], PRINT_FILE_TEXT_VP); // Represents to update file list - if (update_sd && lcd_sd_status && IS_SD_INSERTED()) { + if (update_sd && lcd_sd_status && card.isInserted()) { for (uint16_t i = 0; i < cardRec.Filesum; i++) { delay(3); sendData(cardRec.display_filename[i], cardRec.addr[i]); @@ -1654,8 +1654,8 @@ void RTS_Update() { // Check the status of card rts.sdCardUpdate(); - sd_printing = IS_SD_PRINTING(); - card_insert_st = IS_SD_INSERTED(); + sd_printing = card.isStillPrinting(); + card_insert_st = card.isInserted(); if (!card_insert_st && sd_printing) { rts.gotoPage(ID_MediaFail_L, ID_MediaFail_D); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 5c9f122067..0ef0a2f961 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -4772,7 +4772,7 @@ void Temperature::isr() { dwin_heat_time = elapsed.value; #elif ENABLED(SOVOL_SV06_RTS) update_time_value = RTS_UPDATE_VALUE; - if (IS_SD_PRINTING()) rts.refreshTime(); + if (card.isStillPrinting()) rts.refreshTime(); rts.start_print_flag = false; #else ui.reset_status(); diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index cd20f921db..9b0a37913a 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -146,7 +146,7 @@ int16_t CardReader::nrItems = -1; DiskIODriver* CardReader::driver = nullptr; MarlinVolume CardReader::volume; -MediaFile CardReader::file; +MediaFile CardReader::myfile; #if HAS_MEDIA_SUBCALLS uint8_t CardReader::file_subcall_ctr; @@ -463,9 +463,9 @@ void CardReader::ls(const uint8_t lsflags/*=0*/) { // Echo the DOS 8.3 filename (and long filename, if any) // void CardReader::printSelectedFilename() { - if (file.isOpen()) { + if (myfile.isOpen()) { char dosFilename[FILENAME_LENGTH]; - file.getDosName(dosFilename); + myfile.getDosName(dosFilename); SERIAL_ECHO(dosFilename); #if ENABLED(LONG_FILENAME_HOST_SUPPORT) selectFileByName(dosFilename); @@ -517,7 +517,7 @@ void CardReader::mount() { */ void CardReader::manage_media() { static uint8_t prev_stat = 2; // At boot we don't know if media is present or not - uint8_t stat = uint8_t(IS_SD_INSERTED()); + uint8_t stat = uint8_t(isInserted()); if (stat == prev_stat) return; // Already checked and still no change? DEBUG_SECTION(cmm, "CardReader::manage_media()", true); @@ -626,7 +626,7 @@ void CardReader::endFilePrintNow(TERN_(SD_RESORT, const bool re_sort/*=false*/)) TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0); TERN_(DWIN_CREALITY_LCD, hmiFlag.print_finish = flag.sdprinting); flag.abort_sd_printing = false; - if (isFileOpen()) file.close(); + if (isFileOpen()) myfile.close(); TERN_(SD_RESORT, if (re_sort) presort()); } @@ -661,7 +661,7 @@ void CardReader::getAbsFilenameInCWD(char *dst) { appendAtom(workDirParents[i]); if (cnt < MAXPATHNAMELENGTH - (FILENAME_LENGTH) - 1) { // Leave room for filename and nul - appendAtom(file); + appendAtom(myfile); --dst; } *dst = '\0'; @@ -738,8 +738,8 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ const char * const fname = diveToFile(true, diveDir, path); if (!fname) return openFailed(path); - if (file.open(diveDir, fname, O_READ)) { - filesize = file.fileSize(); + if (myfile.open(diveDir, fname, O_READ)) { + filesize = myfile.fileSize(); sdpos = 0; { // Don't remove this block, as the PORT_REDIRECT is a RAII @@ -778,7 +778,7 @@ void CardReader::openFileWrite(const char * const path) { if (!fname) return openFailed(path); #if DISABLED(SDCARD_READONLY) - if (file.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { + if (myfile.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { flag.saving = true; selectFileByName(fname); TERN_(EMERGENCY_PARSER, emergency_parser.disable()); @@ -832,7 +832,7 @@ void CardReader::removeFile(const char * const name) { #if ENABLED(SDCARD_READONLY) SERIAL_ECHOLNPGM("Deletion failed (read-only), File: ", fname, "."); #else - if (file.remove(itsDirPtr, fname)) { + if (myfile.remove(itsDirPtr, fname)) { SERIAL_ECHOLNPGM("File deleted:", fname); sdpos = 0; TERN_(SDCARD_SORT_ALPHA, presort()); @@ -866,7 +866,7 @@ void CardReader::write_command(char * const buf) { *npos = nullptr, *end = buf + strlen(buf) - 1; - file.writeError = false; + myfile.writeError = false; if ((npos = strchr(buf, 'N'))) { begin = strchr(npos, ' ') + 1; end = strchr(npos, '*') - 1; @@ -874,9 +874,9 @@ void CardReader::write_command(char * const buf) { end[1] = '\r'; end[2] = '\n'; end[3] = '\0'; - file.write(begin); + myfile.write(begin); - if (file.writeError) SERIAL_ERROR_MSG(STR_SD_ERR_WRITE_TO_FILE); + if (myfile.writeError) SERIAL_ERROR_MSG(STR_SD_ERR_WRITE_TO_FILE); } #if DISABLED(NO_SD_AUTOSTART) @@ -1001,8 +1001,8 @@ void CardReader::write_command(char * const buf) { // Close the working file. // void CardReader::closefile(const bool store_location/*=false*/) { - file.sync(); - file.close(); + myfile.sync(); + myfile.close(); flag.saving = flag.logging = false; sdpos = 0; @@ -1441,7 +1441,7 @@ int16_t CardReader::get_num_items() { // Return from procedure or close out the Print Job. // void CardReader::fileHasFinished() { - file.close(); + myfile.close(); #if HAS_MEDIA_SUBCALLS if (file_subcall_ctr > 0) { // Resume calling file after closing procedure diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 7dfe7e344f..1fa23ececf 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -230,6 +230,7 @@ public: static void pauseSDPrint() { flag.sdprinting = false; } static bool isPrinting() { return flag.sdprinting; } static bool isStillPrinting() { return flag.sdprinting && !flag.abort_sd_printing; } + static bool isStillFetching() { return isStillPrinting() && !flag.sdprintdone; } static bool isPaused() { return isFileOpen() && !isPrinting(); } #if HAS_PRINT_PROGRESS_PERMYRIAD static uint16_t permyriadDone() { @@ -289,14 +290,14 @@ public: // Print File stats static uint32_t getFileSize() { return filesize; } static uint32_t getIndex() { return sdpos; } - static bool isFileOpen() { return isMounted() && file.isOpen(); } + static bool isFileOpen() { return isMounted() && myfile.isOpen(); } static bool eof() { return getIndex() >= getFileSize(); } // File data operations - static int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; } - static int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } - static int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } - static void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); } + static int16_t get() { int16_t out = (int16_t)myfile.read(); sdpos = myfile.curPosition(); return out; } + static int16_t read(void *buf, uint16_t nbyte) { return myfile.isOpen() ? myfile.read(buf, nbyte) : -1; } + static int16_t write(void *buf, uint16_t nbyte) { return myfile.isOpen() ? myfile.write(buf, nbyte) : -1; } + static void setIndex(const uint32_t index) { myfile.seekSet((sdpos = index)); } #if ENABLED(AUTO_REPORT_SD_STATUS) // @@ -313,7 +314,7 @@ private: static DiskIODriver *driver; static MarlinVolume volume; - static MediaFile file; + static MediaFile myfile; static uint32_t filesize, // Total size of the current file, in bytes sdpos; // Index most recently read (one behind file.getPos) @@ -405,31 +406,22 @@ private: #endif }; -#if HAS_USB_FLASH_DRIVE - #define IS_SD_INSERTED() DiskIODriver_USBFlash::isInserted() -#elif HAS_SD_DETECT - #define IS_SD_INSERTED() (READ(SD_DETECT_PIN) == SD_DETECT_STATE) -#else - // No card detect line? Assume the card is inserted. - #define IS_SD_INSERTED() true -#endif - -#define IS_SD_MOUNTED() card.isMounted() -#define IS_SD_PRINTING() card.isStillPrinting() -#define IS_SD_FETCHING() (!card.flag.sdprintdone && card.isStillPrinting()) -#define IS_SD_PAUSED() card.isPaused() -#define IS_SD_FILE_OPEN() card.isFileOpen() - -extern CardReader card; - #else // !HAS_MEDIA -#define IS_SD_MOUNTED() false -#define IS_SD_PRINTING() false -#define IS_SD_FETCHING() false -#define IS_SD_PAUSED() false -#define IS_SD_FILE_OPEN() false +class CardReader { +public: + static constexpr bool isFlashDriveInserted() { return false; } + static constexpr bool isSDCardInserted() { return false; } + static constexpr bool isInserted() { return false; } + static constexpr bool isMounted() { return false; } + static constexpr bool isStillPrinting() { return false; } + static constexpr bool isStillFetching() { return false; } + static constexpr bool isPaused() { return false; } + static constexpr bool isFileOpen() { return false; } +}; #define LONG_FILENAME_LENGTH 0 #endif // !HAS_MEDIA + +extern CardReader card; From 06ef78dd19a3741f2bd2050ea34995701fad4575 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Apr 2025 22:30:14 -0500 Subject: [PATCH 31/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Speci?= =?UTF-8?q?fic=20SD=20/=20FD=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 3 --- .../cocoa_press/status_screen.cpp | 6 +++-- .../generic/status_screen.cpp | 6 +++-- Marlin/src/lcd/extui/ui_api.cpp | 4 +++- Marlin/src/lcd/extui/ui_api.h | 3 +++ Marlin/src/lcd/language/language_en.h | 2 +- Marlin/src/lcd/language/language_es.h | 2 +- Marlin/src/lcd/language/language_gl.h | 2 +- Marlin/src/lcd/language/language_it.h | 2 +- Marlin/src/lcd/marlinui.cpp | 7 +++++- Marlin/src/sd/cardreader.cpp | 13 +++++++++- Marlin/src/sd/cardreader.h | 24 +++++++++++++++---- .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 2 +- 13 files changed, 57 insertions(+), 19 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 05355ddccb..de6677fc9a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -820,9 +820,6 @@ void idle(const bool no_stepper_sleep/*=false*/) { // Handle SD Card insert / remove TERN_(HAS_MEDIA, card.manage_media()); - // Handle USB Flash Drive insert / remove - TERN_(HAS_USB_FLASH_DRIVE, card.diskIODriver()->idle()); - // Announce Host Keepalive state (if any) TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive()); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp index 1a7ccd8be5..65ac4551b9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp @@ -432,8 +432,10 @@ void StatusScreen::onIdle() { } void StatusScreen::onMediaMounted() { - if (AT_SCREEN(StatusScreen)) - setStatusMessage(GET_TEXT_F(MSG_MEDIA_INSERTED)); + if (!AT_SCREEN(StatusScreen)) return; + setStatusMessage(ExtUI::isMediaMountedSD() ? GET_TEXT_F(MSG_MEDIA_INSERTED_SD) : + ExtUI::isMediaMountedUSB() ? GET_TEXT_F(MSG_MEDIA_INSERTED_USB) : + GET_TEXT_F(MSG_MEDIA_INSERTED)); } void StatusScreen::onMediaRemoved() { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp index 420758ca88..7b9e8f9f34 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp @@ -588,8 +588,10 @@ bool StatusScreen::onTouchEnd(uint8_t tag) { } void StatusScreen::onMediaMounted() { - if (AT_SCREEN(StatusScreen)) - setStatusMessage(GET_TEXT_F(MSG_MEDIA_INSERTED)); + if (!AT_SCREEN(StatusScreen)) return; + setStatusMessage(ExtUI::isMediaMountedSD() ? GET_TEXT_F(MSG_MEDIA_INSERTED_SD) : + ExtUI::isMediaMountedUSB() ? GET_TEXT_F(MSG_MEDIA_INSERTED_USB) : + GET_TEXT_F(MSG_MEDIA_INSERTED)); } void StatusScreen::onMediaRemoved() { diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 7763bac05a..b3f4c39c24 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -1079,7 +1079,9 @@ namespace ExtUI { return isPrintingFromMedia() || printJobOngoing(); } - bool isMediaMounted() { return TERN0(HAS_MEDIA, card.isMounted()); } + bool isMediaMounted() { return card.isMounted(); } + bool isMediaMountedSD() { return card.isSDCardMounted(); } + bool isMediaMountedUSB() { return card.isFlashDriveMounted(); } // Pause/Resume/Stop are implemented in MarlinUI void pausePrint() { ui.pause_print(); } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 5e781706bc..7796a4e49f 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -464,6 +464,9 @@ namespace ExtUI { * Use these to operate on files */ bool isMediaMounted(); + bool isMediaMountedSD(); + bool isMediaMountedUSB(); + bool isPrintingFromMediaPaused(); bool isPrintingFromMedia(); bool isPrinting(); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index d23e638a78..7ea17d5bb3 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -44,7 +44,7 @@ #if HAS_SDCARD && !HAS_USB_FLASH_DRIVE #define MEDIA_TYPE_EN "SD Card" -#elif HAS_USB_FLASH_DRIVE +#elif HAS_USB_FLASH_DRIVE && !HAS_SDCARD #define MEDIA_TYPE_EN "USB Drive" #else #define MEDIA_TYPE_EN "Media" diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index d1e4babf2b..a92efd5389 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -30,7 +30,7 @@ #if HAS_SDCARD && !HAS_USB_FLASH_DRIVE #define MEDIA_TYPE_ES "SD" -#elif HAS_USB_FLASH_DRIVE +#elif HAS_USB_FLASH_DRIVE && !HAS_SDCARD #define MEDIA_TYPE_ES "USB" #else #define MEDIA_TYPE_ES "SD/FD" diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 6dd699f1bd..3b7620de90 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -32,7 +32,7 @@ #if HAS_SDCARD && !HAS_USB_FLASH_DRIVE #define MEDIA_TYPE_GL "SD" -#elif HAS_USB_FLASH_DRIVE +#elif HAS_USB_FLASH_DRIVE && !HAS_SDCARD #define MEDIA_TYPE_GL "FD" #else #define MEDIA_TYPE_GL "SD/FD" diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 424bcd8367..4bcde87859 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -40,7 +40,7 @@ #if HAS_SDCARD && !HAS_USB_FLASH_DRIVE #define MEDIA_TYPE_IT "SD" -#elif HAS_USB_FLASH_DRIVE +#elif HAS_USB_FLASH_DRIVE && !HAS_SDCARD #define MEDIA_TYPE_IT "USB" #else #define MEDIA_TYPE_IT "Media" diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 8b7e64dda8..f6b1b60c7d 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1907,7 +1907,12 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, quick_feedback(); goto_screen(MEDIA_MENU_GATEWAY); #else - LCD_MESSAGE(MSG_MEDIA_INSERTED); + if (card.isSDCardSelected()) + LCD_MESSAGE(MSG_MEDIA_INSERTED_SD); + else if (card.isFlashDriveSelected()) + LCD_MESSAGE(MSG_MEDIA_INSERTED_USB); + else + LCD_MESSAGE(MSG_MEDIA_INSERTED); #endif } else { // Media Removed diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 9b0a37913a..21bc6e780a 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -501,7 +501,14 @@ void CardReader::mount() { cdroot(); else { #if ANY(HAS_SD_DETECT, HAS_USB_FLASH_DRIVE) - if (marlin_state != MarlinState::MF_INITIALIZING) LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL); + if (marlin_state != MarlinState::MF_INITIALIZING) { + if (isSDCardSelected()) + LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL_SD); + else if (isFlashDriveSelected()) + LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL_USB); + else + LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL); + } #endif } @@ -516,6 +523,10 @@ void CardReader::mount() { * Handle SD card events */ void CardReader::manage_media() { + #if HAS_USB_FLASH_DRIVE // Wrap for optimal non-virtual? + driver->idle(); // Handle device tasks (e.g., USB Drive insert / remove) + #endif + static uint8_t prev_stat = 2; // At boot we don't know if media is present or not uint8_t stat = uint8_t(isInserted()); if (stat == prev_stat) return; // Already checked and still no change? diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 1fa23ececf..1a8843da58 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -143,10 +143,11 @@ public: } /** - * Media Detection - Inserted, Mounted, Job Running, Job Paused, etc. + * Media Detection - Inserted and Mounted Media * - * Marlin 2.1.x supports up to two drives, either an SD Card or USB-FD - * Onboard SD may have SPI or SDIO interface. USB FD may use MSC. + * Marlin 2.1.x supports up to two drives, either an SD Card or USB-FD. + * SD Card may have SPI or SDIO interface. + * SDIO / USB drives may be shared via MSC when not in use by Marlin. */ // No card detect line? Assume the card is inserted. @@ -169,8 +170,16 @@ public: // Mount and release physical media static void mount(); static void release(); + static bool isMounted() { return flag.mounted; } + static bool isSDCardMounted() { + return isMounted() && isSDCardSelected(); + } + static bool isFlashDriveMounted() { + return isMounted() && isFlashDriveSelected(); + } + // Handle media insert/remove (including mounting on boot-up) static void manage_media(); @@ -410,10 +419,17 @@ private: class CardReader { public: - static constexpr bool isFlashDriveInserted() { return false; } + static constexpr bool isSDCardSelected() { return false; } + static constexpr bool isFlashDriveSelected() { return false; } + static constexpr bool isSDCardInserted() { return false; } + static constexpr bool isFlashDriveInserted() { return false; } static constexpr bool isInserted() { return false; } + + static constexpr bool isSDCardMounted() { return false; } + static constexpr bool isFlashDriveMounted() { return false; } static constexpr bool isMounted() { return false; } + static constexpr bool isStillPrinting() { return false; } static constexpr bool isStillFetching() { return false; } static constexpr bool isPaused() { return false; } diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 2ae38c64c0..e6e6f30ae6 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -30,7 +30,7 @@ * 3 - perform block range checking * 4 - print each block access */ -#define USB_DEBUG 1 +#define USB_DEBUG TERN(MARLIN_DEV_MODE, 1, 0) #define USB_STARTUP_DELAY 0 // uncomment to get 'printf' console debugging. NOT FOR UNO! From 1383a4e413307a458b6fb95c4a92563b04f1c93e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Apr 2025 22:04:42 -0500 Subject: [PATCH 32/51] =?UTF-8?q?=F0=9F=94=A7=20Allow=20SMOOTH=5FLIN=5FADV?= =?UTF-8?q?ANCE=20with=20DISTINCT=5FE=5FFACTORS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 3182d93e92..074cfe0dcb 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -854,8 +854,6 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #if ENABLED(SMOOTH_LIN_ADVANCE) #ifndef CPU_32_BIT #error "SMOOTH_LIN_ADVANCE requires a 32-bit CPU." - #elif DISTINCT_E > 1 - #error "SMOOTH_LIN_ADVANCE is not compatible with multiple extruders." #elif ENABLED(S_CURVE_ACCELERATION) #error "SMOOTH_LIN_ADVANCE is not compatible with S_CURVE_ACCELERATION." #elif ENABLED(INPUT_SHAPING_E_SYNC) && NONE(INPUT_SHAPING_X, INPUT_SHAPING_Y) From ad71b81b0c78cd62fbfe98814b0110956adeda5b Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 25 Apr 2025 00:31:00 +0000 Subject: [PATCH 33/51] [cron] Bump distribution date (2025-04-25) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index e8a64a95f0..c96f304a03 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 "2025-04-24" +//#define STRING_DISTRIBUTION_DATE "2025-04-25" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 8a91fbdb71..43e63deb20 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 "2025-04-24" + #define STRING_DISTRIBUTION_DATE "2025-04-25" #endif /** From e0d8ea57a8261160f040431016db5f827e7a47c6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Apr 2025 21:54:53 -0500 Subject: [PATCH 34/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Group?= =?UTF-8?q?=20HAL/*/eeprom=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/DUE/{ => eeprom}/eeprom_flash.cpp | 6 +++--- Marlin/src/HAL/DUE/{ => eeprom}/eeprom_wired.cpp | 6 +++--- .../src/HAL/GD32_MFL/{ => eeprom}/eeprom_bl24cxx.cpp | 8 ++++---- Marlin/src/HAL/GD32_MFL/{ => eeprom}/eeprom_if_iic.cpp | 8 ++++---- Marlin/src/HAL/GD32_MFL/{ => eeprom}/eeprom_wired.cpp | 8 ++++---- Marlin/src/HAL/HC32/{ => eeprom}/eeprom_bl24cxx.cpp | 6 +++--- Marlin/src/HAL/HC32/{ => eeprom}/eeprom_if_iic.cpp | 6 +++--- Marlin/src/HAL/HC32/{ => eeprom}/eeprom_sdcard.cpp | 6 +++--- Marlin/src/HAL/HC32/{ => eeprom}/eeprom_wired.cpp | 6 +++--- Marlin/src/HAL/LPC1768/{ => eeprom}/eeprom_flash.cpp | 4 ++-- Marlin/src/HAL/LPC1768/{ => eeprom}/eeprom_sdcard.cpp | 4 ++-- Marlin/src/HAL/LPC1768/{ => eeprom}/eeprom_wired.cpp | 6 +++--- Marlin/src/HAL/RP2040/{ => eeprom}/eeprom_flash.cpp | 6 +++--- Marlin/src/HAL/RP2040/{ => eeprom}/eeprom_wired.cpp | 8 ++++---- Marlin/src/HAL/SAMD21/{ => eeprom}/QSPIFlash.cpp | 2 +- Marlin/src/HAL/SAMD21/{ => eeprom}/QSPIFlash.h | 0 Marlin/src/HAL/SAMD21/{ => eeprom}/eeprom_flash.cpp | 4 ++-- Marlin/src/HAL/SAMD21/{ => eeprom}/eeprom_qspi.cpp | 4 ++-- Marlin/src/HAL/SAMD21/{ => eeprom}/eeprom_wired.cpp | 6 +++--- Marlin/src/HAL/SAMD51/{ => eeprom}/QSPIFlash.cpp | 2 +- Marlin/src/HAL/SAMD51/{ => eeprom}/QSPIFlash.h | 0 Marlin/src/HAL/SAMD51/{ => eeprom}/eeprom_flash.cpp | 4 ++-- Marlin/src/HAL/SAMD51/{ => eeprom}/eeprom_qspi.cpp | 4 ++-- Marlin/src/HAL/SAMD51/{ => eeprom}/eeprom_wired.cpp | 6 +++--- Marlin/src/HAL/STM32/{ => eeprom}/eeprom_bl24cxx.cpp | 8 ++++---- Marlin/src/HAL/STM32/{ => eeprom}/eeprom_flash.cpp | 10 +++++----- Marlin/src/HAL/STM32/{ => eeprom}/eeprom_if_iic.cpp | 8 ++++---- Marlin/src/HAL/STM32/{ => eeprom}/eeprom_sdcard.cpp | 8 ++++---- Marlin/src/HAL/STM32/{ => eeprom}/eeprom_sram.cpp | 8 ++++---- Marlin/src/HAL/STM32/{ => eeprom}/eeprom_wired.cpp | 8 ++++---- Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_bl24cxx.cpp | 6 +++--- Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_flash.cpp | 4 ++-- Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_if_iic.cpp | 6 +++--- Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_sdcard.cpp | 6 +++--- Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_wired.cpp | 6 +++--- platformio.ini | 1 + 36 files changed, 100 insertions(+), 99 deletions(-) rename Marlin/src/HAL/DUE/{ => eeprom}/eeprom_flash.cpp (99%) rename Marlin/src/HAL/DUE/{ => eeprom}/eeprom_wired.cpp (95%) rename Marlin/src/HAL/GD32_MFL/{ => eeprom}/eeprom_bl24cxx.cpp (94%) rename Marlin/src/HAL/GD32_MFL/{ => eeprom}/eeprom_if_iic.cpp (91%) rename Marlin/src/HAL/GD32_MFL/{ => eeprom}/eeprom_wired.cpp (94%) rename Marlin/src/HAL/HC32/{ => eeprom}/eeprom_bl24cxx.cpp (95%) rename Marlin/src/HAL/HC32/{ => eeprom}/eeprom_if_iic.cpp (92%) rename Marlin/src/HAL/HC32/{ => eeprom}/eeprom_sdcard.cpp (96%) rename Marlin/src/HAL/HC32/{ => eeprom}/eeprom_wired.cpp (95%) rename Marlin/src/HAL/LPC1768/{ => eeprom}/eeprom_flash.cpp (98%) rename Marlin/src/HAL/LPC1768/{ => eeprom}/eeprom_sdcard.cpp (98%) rename Marlin/src/HAL/LPC1768/{ => eeprom}/eeprom_wired.cpp (95%) rename Marlin/src/HAL/RP2040/{ => eeprom}/eeprom_flash.cpp (95%) rename Marlin/src/HAL/RP2040/{ => eeprom}/eeprom_wired.cpp (94%) rename Marlin/src/HAL/SAMD21/{ => eeprom}/QSPIFlash.cpp (98%) rename Marlin/src/HAL/SAMD21/{ => eeprom}/QSPIFlash.h (100%) rename Marlin/src/HAL/SAMD21/{ => eeprom}/eeprom_flash.cpp (98%) rename Marlin/src/HAL/SAMD21/{ => eeprom}/eeprom_qspi.cpp (96%) rename Marlin/src/HAL/SAMD21/{ => eeprom}/eeprom_wired.cpp (95%) rename Marlin/src/HAL/SAMD51/{ => eeprom}/QSPIFlash.cpp (98%) rename Marlin/src/HAL/SAMD51/{ => eeprom}/QSPIFlash.h (100%) rename Marlin/src/HAL/SAMD51/{ => eeprom}/eeprom_flash.cpp (97%) rename Marlin/src/HAL/SAMD51/{ => eeprom}/eeprom_qspi.cpp (96%) rename Marlin/src/HAL/SAMD51/{ => eeprom}/eeprom_wired.cpp (95%) rename Marlin/src/HAL/STM32/{ => eeprom}/eeprom_bl24cxx.cpp (94%) rename Marlin/src/HAL/STM32/{ => eeprom}/eeprom_flash.cpp (98%) rename Marlin/src/HAL/STM32/{ => eeprom}/eeprom_if_iic.cpp (91%) rename Marlin/src/HAL/STM32/{ => eeprom}/eeprom_sdcard.cpp (94%) rename Marlin/src/HAL/STM32/{ => eeprom}/eeprom_sram.cpp (93%) rename Marlin/src/HAL/STM32/{ => eeprom}/eeprom_wired.cpp (94%) rename Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_bl24cxx.cpp (95%) rename Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_flash.cpp (98%) rename Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_if_iic.cpp (93%) rename Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_sdcard.cpp (96%) rename Marlin/src/HAL/STM32F1/{ => eeprom}/eeprom_wired.cpp (95%) diff --git a/Marlin/src/HAL/DUE/eeprom_flash.cpp b/Marlin/src/HAL/DUE/eeprom/eeprom_flash.cpp similarity index 99% rename from Marlin/src/HAL/DUE/eeprom_flash.cpp rename to Marlin/src/HAL/DUE/eeprom/eeprom_flash.cpp index 55206a0f9d..b33d15e106 100644 --- a/Marlin/src/HAL/DUE/eeprom_flash.cpp +++ b/Marlin/src/HAL/DUE/eeprom/eeprom_flash.cpp @@ -21,7 +21,7 @@ */ #ifdef ARDUINO_ARCH_SAM -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(FLASH_EEPROM_EMULATION) @@ -132,7 +132,7 @@ static uint8_t buffer[256] = {0}, // The RAM buffer to accumulate writes curGroup = 0xFF; // Current FLASH group #define DEBUG_OUT ENABLED(EE_EMU_DEBUG) -#include "../../core/debug_out.h" +#include "../../../core/debug_out.h" static void ee_Dump(const int page, const void *data) { @@ -953,7 +953,7 @@ static void ee_Init() { /* PersistentStore -----------------------------------------------------------*/ -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE 0x1000 // 4KB diff --git a/Marlin/src/HAL/DUE/eeprom_wired.cpp b/Marlin/src/HAL/DUE/eeprom/eeprom_wired.cpp similarity index 95% rename from Marlin/src/HAL/DUE/eeprom_wired.cpp rename to Marlin/src/HAL/DUE/eeprom/eeprom_wired.cpp index 84338ccb4b..cf9233816c 100644 --- a/Marlin/src/HAL/DUE/eeprom_wired.cpp +++ b/Marlin/src/HAL/DUE/eeprom/eeprom_wired.cpp @@ -21,7 +21,7 @@ */ #ifdef ARDUINO_ARCH_SAM -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM @@ -30,8 +30,8 @@ * with simple implementations supplied by Marlin. */ -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." diff --git a/Marlin/src/HAL/GD32_MFL/eeprom_bl24cxx.cpp b/Marlin/src/HAL/GD32_MFL/eeprom/eeprom_bl24cxx.cpp similarity index 94% rename from Marlin/src/HAL/GD32_MFL/eeprom_bl24cxx.cpp rename to Marlin/src/HAL/GD32_MFL/eeprom/eeprom_bl24cxx.cpp index 2d3329c7f6..9c44933fe3 100644 --- a/Marlin/src/HAL/GD32_MFL/eeprom_bl24cxx.cpp +++ b/Marlin/src/HAL/GD32_MFL/eeprom/eeprom_bl24cxx.cpp @@ -25,16 +25,16 @@ * with simple implementations supplied by Marlin. */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef ARDUINO_ARCH_MFL -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #error "MARLIN_EEPROM_SIZE is required for IIC_BL24CXX_EEPROM." diff --git a/Marlin/src/HAL/GD32_MFL/eeprom_if_iic.cpp b/Marlin/src/HAL/GD32_MFL/eeprom/eeprom_if_iic.cpp similarity index 91% rename from Marlin/src/HAL/GD32_MFL/eeprom_if_iic.cpp rename to Marlin/src/HAL/GD32_MFL/eeprom/eeprom_if_iic.cpp index 96eebea122..ea563f742c 100644 --- a/Marlin/src/HAL/GD32_MFL/eeprom_if_iic.cpp +++ b/Marlin/src/HAL/GD32_MFL/eeprom/eeprom_if_iic.cpp @@ -25,16 +25,16 @@ * Enable USE_SHARED_EEPROM if not supplied by the framework. */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef ARDUINO_ARCH_MFL -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) -#include "../../libs/BL24CXX.h" -#include "../shared/eeprom_if.h" +#include "../../../libs/BL24CXX.h" +#include "../../shared/eeprom_if.h" void eeprom_init() { BL24CXX::init(); diff --git a/Marlin/src/HAL/GD32_MFL/eeprom_wired.cpp b/Marlin/src/HAL/GD32_MFL/eeprom/eeprom_wired.cpp similarity index 94% rename from Marlin/src/HAL/GD32_MFL/eeprom_wired.cpp rename to Marlin/src/HAL/GD32_MFL/eeprom/eeprom_wired.cpp index 58a6f85e7f..8860e53a62 100644 --- a/Marlin/src/HAL/GD32_MFL/eeprom_wired.cpp +++ b/Marlin/src/HAL/GD32_MFL/eeprom/eeprom_wired.cpp @@ -19,11 +19,11 @@ * along with this program. If not, see . * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef ARDUINO_ARCH_MFL -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM @@ -32,8 +32,8 @@ * with simple implementations supplied by Marlin. */ -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE size_t(E2END + 1) diff --git a/Marlin/src/HAL/HC32/eeprom_bl24cxx.cpp b/Marlin/src/HAL/HC32/eeprom/eeprom_bl24cxx.cpp similarity index 95% rename from Marlin/src/HAL/HC32/eeprom_bl24cxx.cpp rename to Marlin/src/HAL/HC32/eeprom/eeprom_bl24cxx.cpp index 59da99b3f5..a53a7c4062 100644 --- a/Marlin/src/HAL/HC32/eeprom_bl24cxx.cpp +++ b/Marlin/src/HAL/HC32/eeprom/eeprom_bl24cxx.cpp @@ -26,12 +26,12 @@ */ #ifdef ARDUINO_ARCH_HC32 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) -#include "../shared/eeprom_api.h" -#include "../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" #ifndef MARLIN_EEPROM_SIZE #error "MARLIN_EEPROM_SIZE is required for IIC_BL24CXX_EEPROM." diff --git a/Marlin/src/HAL/HC32/eeprom_if_iic.cpp b/Marlin/src/HAL/HC32/eeprom/eeprom_if_iic.cpp similarity index 92% rename from Marlin/src/HAL/HC32/eeprom_if_iic.cpp rename to Marlin/src/HAL/HC32/eeprom/eeprom_if_iic.cpp index 02b1d3fd54..85d21a972a 100644 --- a/Marlin/src/HAL/HC32/eeprom_if_iic.cpp +++ b/Marlin/src/HAL/HC32/eeprom/eeprom_if_iic.cpp @@ -26,12 +26,12 @@ */ #ifdef ARDUINO_ARCH_HC32 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) -#include "../../libs/BL24CXX.h" -#include "../shared/eeprom_if.h" +#include "../../../libs/BL24CXX.h" +#include "../../shared/eeprom_if.h" void eeprom_init() { BL24CXX::init(); diff --git a/Marlin/src/HAL/HC32/eeprom_sdcard.cpp b/Marlin/src/HAL/HC32/eeprom/eeprom_sdcard.cpp similarity index 96% rename from Marlin/src/HAL/HC32/eeprom_sdcard.cpp rename to Marlin/src/HAL/HC32/eeprom/eeprom_sdcard.cpp index 601e86dd30..45f3b01cf7 100644 --- a/Marlin/src/HAL/HC32/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/HC32/eeprom/eeprom_sdcard.cpp @@ -25,12 +25,12 @@ */ #ifdef ARDUINO_ARCH_HC32 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(SDCARD_EEPROM_EMULATION) -#include "../shared/eeprom_api.h" -#include "../../sd/cardreader.h" +#include "../../shared/eeprom_api.h" +#include "../../../sd/cardreader.h" #define EEPROM_FILENAME "eeprom.dat" diff --git a/Marlin/src/HAL/HC32/eeprom_wired.cpp b/Marlin/src/HAL/HC32/eeprom/eeprom_wired.cpp similarity index 95% rename from Marlin/src/HAL/HC32/eeprom_wired.cpp rename to Marlin/src/HAL/HC32/eeprom/eeprom_wired.cpp index aea5fc87db..997180bd98 100644 --- a/Marlin/src/HAL/HC32/eeprom_wired.cpp +++ b/Marlin/src/HAL/HC32/eeprom/eeprom_wired.cpp @@ -21,7 +21,7 @@ */ #ifdef ARDUINO_ARCH_HC32 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM @@ -32,8 +32,8 @@ * with simple implementations supplied by Marlin. */ -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." diff --git a/Marlin/src/HAL/LPC1768/eeprom_flash.cpp b/Marlin/src/HAL/LPC1768/eeprom/eeprom_flash.cpp similarity index 98% rename from Marlin/src/HAL/LPC1768/eeprom_flash.cpp rename to Marlin/src/HAL/LPC1768/eeprom/eeprom_flash.cpp index 9f873d5774..3610f433eb 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_flash.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom/eeprom_flash.cpp @@ -36,11 +36,11 @@ * 16Kb I/O buffers (intended to hold DMA USB and Ethernet data, but currently * unused). */ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(FLASH_EEPROM_EMULATION) -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" extern "C" { #include diff --git a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp b/Marlin/src/HAL/LPC1768/eeprom/eeprom_sdcard.cpp similarity index 98% rename from Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp rename to Marlin/src/HAL/LPC1768/eeprom/eeprom_sdcard.cpp index 30ecb01a09..3500f3e7cf 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom/eeprom_sdcard.cpp @@ -26,13 +26,13 @@ #ifdef TARGET_LPC1768 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(SDCARD_EEPROM_EMULATION) //#define DEBUG_SD_EEPROM_EMULATION -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" #include #include diff --git a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp b/Marlin/src/HAL/LPC1768/eeprom/eeprom_wired.cpp similarity index 95% rename from Marlin/src/HAL/LPC1768/eeprom_wired.cpp rename to Marlin/src/HAL/LPC1768/eeprom/eeprom_wired.cpp index 3230e29afc..6a5d90bd02 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom/eeprom_wired.cpp @@ -21,7 +21,7 @@ */ #ifdef TARGET_LPC1768 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM @@ -30,8 +30,8 @@ * with implementations supplied by the framework. */ -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE 0x8000 // 32K diff --git a/Marlin/src/HAL/RP2040/eeprom_flash.cpp b/Marlin/src/HAL/RP2040/eeprom/eeprom_flash.cpp similarity index 95% rename from Marlin/src/HAL/RP2040/eeprom_flash.cpp rename to Marlin/src/HAL/RP2040/eeprom/eeprom_flash.cpp index 5b1131ed43..89e882d77b 100644 --- a/Marlin/src/HAL/RP2040/eeprom_flash.cpp +++ b/Marlin/src/HAL/RP2040/eeprom/eeprom_flash.cpp @@ -19,15 +19,15 @@ * along with this program. If not, see . * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef __PLAT_RP2040__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(FLASH_EEPROM_EMULATION) -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" // NOTE: The Bigtreetech SKR Pico has an onboard W25Q16 flash module diff --git a/Marlin/src/HAL/RP2040/eeprom_wired.cpp b/Marlin/src/HAL/RP2040/eeprom/eeprom_wired.cpp similarity index 94% rename from Marlin/src/HAL/RP2040/eeprom_wired.cpp rename to Marlin/src/HAL/RP2040/eeprom/eeprom_wired.cpp index 974f6f8dc1..7a5ca86c4c 100644 --- a/Marlin/src/HAL/RP2040/eeprom_wired.cpp +++ b/Marlin/src/HAL/RP2040/eeprom/eeprom_wired.cpp @@ -19,11 +19,11 @@ * along with this program. If not, see . * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef __PLAT_RP2040__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM @@ -32,8 +32,8 @@ * with simple implementations supplied by Marlin. */ -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE size_t(E2END + 1) diff --git a/Marlin/src/HAL/SAMD21/QSPIFlash.cpp b/Marlin/src/HAL/SAMD21/eeprom/QSPIFlash.cpp similarity index 98% rename from Marlin/src/HAL/SAMD21/QSPIFlash.cpp rename to Marlin/src/HAL/SAMD21/eeprom/QSPIFlash.cpp index fa54c62071..2a93226a6f 100644 --- a/Marlin/src/HAL/SAMD21/QSPIFlash.cpp +++ b/Marlin/src/HAL/SAMD21/eeprom/QSPIFlash.cpp @@ -24,7 +24,7 @@ * SAMD21 HAL developed by Bart Meijer (brupje) * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) */ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(QSPI_EEPROM) diff --git a/Marlin/src/HAL/SAMD21/QSPIFlash.h b/Marlin/src/HAL/SAMD21/eeprom/QSPIFlash.h similarity index 100% rename from Marlin/src/HAL/SAMD21/QSPIFlash.h rename to Marlin/src/HAL/SAMD21/eeprom/QSPIFlash.h diff --git a/Marlin/src/HAL/SAMD21/eeprom_flash.cpp b/Marlin/src/HAL/SAMD21/eeprom/eeprom_flash.cpp similarity index 98% rename from Marlin/src/HAL/SAMD21/eeprom_flash.cpp rename to Marlin/src/HAL/SAMD21/eeprom/eeprom_flash.cpp index 66329bff19..1c190495de 100644 --- a/Marlin/src/HAL/SAMD21/eeprom_flash.cpp +++ b/Marlin/src/HAL/SAMD21/eeprom/eeprom_flash.cpp @@ -26,7 +26,7 @@ */ #ifdef __SAMD21__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(FLASH_EEPROM_EMULATION) @@ -35,7 +35,7 @@ /* reserve flash memory */ static const uint8_t flashdata[TOTAL_FLASH_SIZE] __attribute__((__aligned__(256))) { }; \ -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE - eeprom_exclude_size; } diff --git a/Marlin/src/HAL/SAMD21/eeprom_qspi.cpp b/Marlin/src/HAL/SAMD21/eeprom/eeprom_qspi.cpp similarity index 96% rename from Marlin/src/HAL/SAMD21/eeprom_qspi.cpp rename to Marlin/src/HAL/SAMD21/eeprom/eeprom_qspi.cpp index 12977a178c..8bd1bd3539 100644 --- a/Marlin/src/HAL/SAMD21/eeprom_qspi.cpp +++ b/Marlin/src/HAL/SAMD21/eeprom/eeprom_qspi.cpp @@ -26,13 +26,13 @@ */ #ifdef __SAMD21__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(QSPI_EEPROM) #error "QSPI_EEPROM emulation Not implemented on SAMD21" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" #include "QSPIFlash.h" diff --git a/Marlin/src/HAL/SAMD21/eeprom_wired.cpp b/Marlin/src/HAL/SAMD21/eeprom/eeprom_wired.cpp similarity index 95% rename from Marlin/src/HAL/SAMD21/eeprom_wired.cpp rename to Marlin/src/HAL/SAMD21/eeprom/eeprom_wired.cpp index da0eb1b0c8..82c701ebb1 100644 --- a/Marlin/src/HAL/SAMD21/eeprom_wired.cpp +++ b/Marlin/src/HAL/SAMD21/eeprom/eeprom_wired.cpp @@ -26,7 +26,7 @@ */ #ifdef __SAMD21__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM @@ -36,8 +36,8 @@ * with simple implementations supplied by Marlin. */ -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." diff --git a/Marlin/src/HAL/SAMD51/QSPIFlash.cpp b/Marlin/src/HAL/SAMD51/eeprom/QSPIFlash.cpp similarity index 98% rename from Marlin/src/HAL/SAMD51/QSPIFlash.cpp rename to Marlin/src/HAL/SAMD51/eeprom/QSPIFlash.cpp index fc21a1ad8c..191da1f30c 100644 --- a/Marlin/src/HAL/SAMD51/QSPIFlash.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom/QSPIFlash.cpp @@ -20,7 +20,7 @@ * */ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(QSPI_EEPROM) diff --git a/Marlin/src/HAL/SAMD51/QSPIFlash.h b/Marlin/src/HAL/SAMD51/eeprom/QSPIFlash.h similarity index 100% rename from Marlin/src/HAL/SAMD51/QSPIFlash.h rename to Marlin/src/HAL/SAMD51/eeprom/QSPIFlash.h diff --git a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp b/Marlin/src/HAL/SAMD51/eeprom/eeprom_flash.cpp similarity index 97% rename from Marlin/src/HAL/SAMD51/eeprom_flash.cpp rename to Marlin/src/HAL/SAMD51/eeprom/eeprom_flash.cpp index 7d5518956c..2387a0f99e 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom/eeprom_flash.cpp @@ -25,11 +25,11 @@ */ #ifdef __SAMD51__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(FLASH_EEPROM_EMULATION) -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" #define NVMCTRL_CMD(c) do{ \ SYNC(!NVMCTRL->STATUS.bit.READY); \ diff --git a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp b/Marlin/src/HAL/SAMD51/eeprom/eeprom_qspi.cpp similarity index 96% rename from Marlin/src/HAL/SAMD51/eeprom_qspi.cpp rename to Marlin/src/HAL/SAMD51/eeprom/eeprom_qspi.cpp index a39e4c4fa3..e829c28e26 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom/eeprom_qspi.cpp @@ -25,11 +25,11 @@ */ #ifdef __SAMD51__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(QSPI_EEPROM) -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" #include "QSPIFlash.h" diff --git a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp b/Marlin/src/HAL/SAMD51/eeprom/eeprom_wired.cpp similarity index 95% rename from Marlin/src/HAL/SAMD51/eeprom_wired.cpp rename to Marlin/src/HAL/SAMD51/eeprom/eeprom_wired.cpp index 00a739a587..fc1eb09a0c 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom/eeprom_wired.cpp @@ -25,7 +25,7 @@ */ #ifdef __SAMD51__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM @@ -34,8 +34,8 @@ * with simple implementations supplied by Marlin. */ -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." diff --git a/Marlin/src/HAL/STM32/eeprom_bl24cxx.cpp b/Marlin/src/HAL/STM32/eeprom/eeprom_bl24cxx.cpp similarity index 94% rename from Marlin/src/HAL/STM32/eeprom_bl24cxx.cpp rename to Marlin/src/HAL/STM32/eeprom/eeprom_bl24cxx.cpp index 3e0bb58dad..8240f15d3a 100644 --- a/Marlin/src/HAL/STM32/eeprom_bl24cxx.cpp +++ b/Marlin/src/HAL/STM32/eeprom/eeprom_bl24cxx.cpp @@ -20,7 +20,7 @@ * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef HAL_STM32 @@ -29,12 +29,12 @@ * with simple implementations supplied by Marlin. */ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" // // PersistentStore diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom/eeprom_flash.cpp similarity index 98% rename from Marlin/src/HAL/STM32/eeprom_flash.cpp rename to Marlin/src/HAL/STM32/eeprom/eeprom_flash.cpp index 14e6e4d854..9f1e49a4f6 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom/eeprom_flash.cpp @@ -19,15 +19,15 @@ * along with this program. If not, see . * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef HAL_STM32 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(FLASH_EEPROM_EMULATION) -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" // Better: "utility/stm32_eeprom.h", but only after updating stm32duino to 2.0.0 // Use EEPROM.h for compatibility, for now. @@ -50,10 +50,10 @@ #if ENABLED(FLASH_EEPROM_LEVELING) - #include "stm32_def.h" + #include #define DEBUG_OUT ENABLED(EEPROM_CHITCHAT) - #include "../../core/debug_out.h" + #include "../../../core/debug_out.h" #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE 0x1000 // 4KB diff --git a/Marlin/src/HAL/STM32/eeprom_if_iic.cpp b/Marlin/src/HAL/STM32/eeprom/eeprom_if_iic.cpp similarity index 91% rename from Marlin/src/HAL/STM32/eeprom_if_iic.cpp rename to Marlin/src/HAL/STM32/eeprom/eeprom_if_iic.cpp index ad8712c0c0..9cabdd681b 100644 --- a/Marlin/src/HAL/STM32/eeprom_if_iic.cpp +++ b/Marlin/src/HAL/STM32/eeprom/eeprom_if_iic.cpp @@ -20,7 +20,7 @@ * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef HAL_STM32 @@ -29,12 +29,12 @@ * Enable USE_SHARED_EEPROM if not supplied by the framework. */ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) -#include "../../libs/BL24CXX.h" -#include "../shared/eeprom_if.h" +#include "../../../libs/BL24CXX.h" +#include "../../shared/eeprom_if.h" void eeprom_init() { BL24CXX::init(); } diff --git a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32/eeprom/eeprom_sdcard.cpp similarity index 94% rename from Marlin/src/HAL/STM32/eeprom_sdcard.cpp rename to Marlin/src/HAL/STM32/eeprom/eeprom_sdcard.cpp index 071d0bac00..bcc76df813 100644 --- a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32/eeprom/eeprom_sdcard.cpp @@ -20,7 +20,7 @@ * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef HAL_STM32 @@ -28,12 +28,12 @@ * Implementation of EEPROM settings in SD Card */ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(SDCARD_EEPROM_EMULATION) -#include "../shared/eeprom_api.h" -#include "../../sd/cardreader.h" +#include "../../shared/eeprom_api.h" +#include "../../../sd/cardreader.h" #define EEPROM_FILENAME "eeprom.dat" diff --git a/Marlin/src/HAL/STM32/eeprom_sram.cpp b/Marlin/src/HAL/STM32/eeprom/eeprom_sram.cpp similarity index 93% rename from Marlin/src/HAL/STM32/eeprom_sram.cpp rename to Marlin/src/HAL/STM32/eeprom/eeprom_sram.cpp index 58a67f1759..a9d62ec29c 100644 --- a/Marlin/src/HAL/STM32/eeprom_sram.cpp +++ b/Marlin/src/HAL/STM32/eeprom/eeprom_sram.cpp @@ -19,16 +19,16 @@ * along with this program. If not, see . * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef HAL_STM32 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(SRAM_EEPROM_EMULATION) -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE 0x1000 // 4KB diff --git a/Marlin/src/HAL/STM32/eeprom_wired.cpp b/Marlin/src/HAL/STM32/eeprom/eeprom_wired.cpp similarity index 94% rename from Marlin/src/HAL/STM32/eeprom_wired.cpp rename to Marlin/src/HAL/STM32/eeprom/eeprom_wired.cpp index 5440030bd4..fa45e6c40d 100644 --- a/Marlin/src/HAL/STM32/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32/eeprom/eeprom_wired.cpp @@ -19,11 +19,11 @@ * along with this program. If not, see . * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef HAL_STM32 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM @@ -32,8 +32,8 @@ * with simple implementations supplied by Marlin. */ -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE size_t(E2END + 1) diff --git a/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp b/Marlin/src/HAL/STM32F1/eeprom/eeprom_bl24cxx.cpp similarity index 95% rename from Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp rename to Marlin/src/HAL/STM32F1/eeprom/eeprom_bl24cxx.cpp index 1252e77b0b..9e96a741bf 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom/eeprom_bl24cxx.cpp @@ -26,12 +26,12 @@ * with simple implementations supplied by Marlin. */ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" // // PersistentStore diff --git a/Marlin/src/HAL/STM32F1/eeprom_flash.cpp b/Marlin/src/HAL/STM32F1/eeprom/eeprom_flash.cpp similarity index 98% rename from Marlin/src/HAL/STM32F1/eeprom_flash.cpp rename to Marlin/src/HAL/STM32F1/eeprom/eeprom_flash.cpp index 50d9cfc4f4..485bc4f1ba 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom/eeprom_flash.cpp @@ -28,11 +28,11 @@ #ifdef __STM32F1__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(FLASH_EEPROM_EMULATION) -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_api.h" #include #include diff --git a/Marlin/src/HAL/STM32F1/eeprom_if_iic.cpp b/Marlin/src/HAL/STM32F1/eeprom/eeprom_if_iic.cpp similarity index 93% rename from Marlin/src/HAL/STM32F1/eeprom_if_iic.cpp rename to Marlin/src/HAL/STM32F1/eeprom/eeprom_if_iic.cpp index 78b7af0b04..e1d5e06b68 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_if_iic.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom/eeprom_if_iic.cpp @@ -27,12 +27,12 @@ #ifdef __STM32F1__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) -#include "../../libs/BL24CXX.h" -#include "../shared/eeprom_if.h" +#include "../../../libs/BL24CXX.h" +#include "../../shared/eeprom_if.h" void eeprom_init() { BL24CXX::init(); } diff --git a/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32F1/eeprom/eeprom_sdcard.cpp similarity index 96% rename from Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp rename to Marlin/src/HAL/STM32F1/eeprom/eeprom_sdcard.cpp index 6b72193422..4d28ce8e0a 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom/eeprom_sdcard.cpp @@ -27,12 +27,12 @@ #ifdef __STM32F1__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(SDCARD_EEPROM_EMULATION) -#include "../shared/eeprom_api.h" -#include "../../sd/cardreader.h" +#include "../../shared/eeprom_api.h" +#include "../../../sd/cardreader.h" #define EEPROM_FILENAME "eeprom.dat" diff --git a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp b/Marlin/src/HAL/STM32F1/eeprom/eeprom_wired.cpp similarity index 95% rename from Marlin/src/HAL/STM32F1/eeprom_wired.cpp rename to Marlin/src/HAL/STM32F1/eeprom/eeprom_wired.cpp index bfb7718094..a1464ab983 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom/eeprom_wired.cpp @@ -26,12 +26,12 @@ #ifdef __STM32F1__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if USE_WIRED_EEPROM -#include "../shared/eeprom_if.h" -#include "../shared/eeprom_api.h" +#include "../../shared/eeprom_if.h" +#include "../../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." diff --git a/platformio.ini b/platformio.ini index d69fdc6cea..4d03696b5a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -78,6 +78,7 @@ default_src_filter = + - - - - - + - - - - From f60bc278fa14abc7d7fabf79a8ac9335a1a764b4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 26 Apr 2025 17:21:41 -0500 Subject: [PATCH 35/51] =?UTF-8?q?=F0=9F=A9=B9=20Misc.=20HAL,=20flag=20fixe?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp | 11 ++++++----- Marlin/src/HAL/LPC1768/HAL.cpp | 9 ++------- Marlin/src/HAL/LPC1768/eeprom/eeprom_sdcard.cpp | 2 +- Marlin/src/HAL/RP2040/HAL.cpp | 2 +- Marlin/src/HAL/STM32/HAL.cpp | 2 +- Marlin/src/HAL/STM32/usb_serial.cpp | 4 ++-- Marlin/src/HAL/STM32F1/HAL.cpp | 3 ++- Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp | 2 +- ini/stm32f1-maple.ini | 2 +- ini/stm32f1.ini | 9 +++++---- 10 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp index ff6ff4859b..74cfd9b39b 100644 --- a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp +++ b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp @@ -29,11 +29,10 @@ bool sd_mmc_spi_wr_protect() { return false; } bool sd_mmc_spi_removal() { return !media_ready(); } Ctrl_status sd_mmc_spi_test_unit_ready() { - #ifdef DISABLE_DUE_SD_MMC + #if ENABLED(DISABLE_DUE_SD_MMC) return CTRL_NO_PRESENT; #endif - if (sd_mmc_spi_removal()) return CTRL_NO_PRESENT; - return CTRL_GOOD; + return sd_mmc_spi_removal() ? CTRL_NO_PRESENT : CTRL_GOOD; } // NOTE: This function is defined as returning the address of the last block @@ -58,9 +57,10 @@ uint8_t sector_buf[SD_MMC_BLOCK_SIZE]; // #define DEBUG_MMC Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) { - #ifdef DISABLE_DUE_SD_MMC + #if ENABLED(DISABLE_DUE_SD_MMC) return CTRL_NO_PRESENT; #endif + if (sd_mmc_spi_removal()) return CTRL_NO_PRESENT; #ifdef DEBUG_MMC @@ -97,9 +97,10 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) { } Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) { - #ifdef DISABLE_DUE_SD_MMC + #if ENABLED(DISABLE_DUE_SD_MMC) return CTRL_NO_PRESENT; #endif + if (sd_mmc_spi_removal()) return CTRL_NO_PRESENT; #ifdef DEBUG_MMC diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index 6e4357777d..4b0e255f37 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -173,13 +173,8 @@ void MarlinHAL::init() { // HAL idle task void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA - // If Marlin is using the SD card we need to lock it to prevent access from - // a PC via USB. - // Other HALs use card.isStillPrinting() and card.isFileOpen() to check for access but - // this will not reliably detect delete operations. To be safe we will lock - // the disk if Marlin has it mounted. Unfortunately there is currently no way - // to unmount the disk from the LCD menu. - // if (card.isStillPrinting() || card.isFileOpen()) + // When Marlin is using the SD Card it must be locked to prevent PC access via USB. + // For maximum safety we lock the disk if Marlin has it mounted for any reason. if (card.isMounted()) MSC_Aquire_Lock(); else diff --git a/Marlin/src/HAL/LPC1768/eeprom/eeprom_sdcard.cpp b/Marlin/src/HAL/LPC1768/eeprom/eeprom_sdcard.cpp index 3500f3e7cf..5bf2d353b6 100644 --- a/Marlin/src/HAL/LPC1768/eeprom/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom/eeprom_sdcard.cpp @@ -52,7 +52,6 @@ bool eeprom_file_open = false; size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE - eeprom_exclude_size; } bool PersistentStore::access_start() { - const char eeprom_erase_value = 0xFF; MSC_Aquire_Lock(); if (f_mount(&fat_fs, "", 1)) { MSC_Release_Lock(); @@ -65,6 +64,7 @@ bool PersistentStore::access_start() { UINT bytes_written; FSIZE_t file_size = f_size(&eeprom_file); f_lseek(&eeprom_file, file_size); + const char eeprom_erase_value = 0xFF; while (file_size < capacity() && res == FR_OK) { res = f_write(&eeprom_file, &eeprom_erase_value, 1, &bytes_written); file_size++; diff --git a/Marlin/src/HAL/RP2040/HAL.cpp b/Marlin/src/HAL/RP2040/HAL.cpp index ceaf540452..6e35fac938 100644 --- a/Marlin/src/HAL/RP2040/HAL.cpp +++ b/Marlin/src/HAL/RP2040/HAL.cpp @@ -77,7 +77,7 @@ void MarlinHAL::init() { HAL_timer_init(); - #if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC + #if ALL(EMERGENCY_PARSER, USBD_USE_CDC) USB_Hook_init(); #endif diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index 6bebaa24f0..a44c333096 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -87,7 +87,7 @@ void MarlinHAL::init() { SetTimerInterruptPriorities(); - #if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC) + #if ENABLED(EMERGENCY_PARSER) && ANY(USBD_USE_CDC, USBD_USE_CDC_MSC) USB_Hook_init(); #endif diff --git a/Marlin/src/HAL/STM32/usb_serial.cpp b/Marlin/src/HAL/STM32/usb_serial.cpp index 0b2372f3a7..1ca8b19976 100644 --- a/Marlin/src/HAL/STM32/usb_serial.cpp +++ b/Marlin/src/HAL/STM32/usb_serial.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC) +#if ENABLED(EMERGENCY_PARSER) && ANY(USBD_USE_CDC, USBD_USE_CDC_MSC) #include "usb_serial.h" #include "../../feature/e_parser.h" @@ -56,5 +56,5 @@ void USB_Hook_init() { USBD_CDC_fops.Receive = USBD_CDC_Receive_hook; } -#endif // EMERGENCY_PARSER && USBD_USE_CDC +#endif // EMERGENCY_PARSER && (USBD_USE_CDC || USBD_USE_CDC_MSC) #endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index d5f4ade79d..4072e55652 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -65,7 +65,8 @@ uint16_t adc_results[ADC_COUNT]; emergency_parser.update(MSerial0.emergency_state, buf[i + total - len]); } #endif -#endif + +#endif // SERIAL_USB && !HAS_SD_HOST_DRIVE // ------------------------ // Watchdog Timer diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp index fd3849d1ed..6f3d44dd7f 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp @@ -109,7 +109,7 @@ bool MAX3421e::start() { // Initialize pins and SPI bus SET_OUTPUT(USB_CS_PIN); - SET_INPUT_PULLUP(USB_INTR_PIN); + SET_INPUT_PULLUP(USB_INTR_PIN); // Active LOW ncs(); spiBegin(); diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 0e77ff8dfa..ddd75549c8 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -219,7 +219,7 @@ board_build.address = 0x08010000 board_build.rename = project.bin board_build.ldscript = STM32F103VE_longer.ld build_flags = ${STM32F1_maple.build_flags} - -DMCU_STM32F103VE -DSTM32F1xx -USERIAL_USB -DU20 -DTS_V12 + -DMCU_STM32F103VE -DSTM32F1xx -DSERIAL_USB -DU20 -DTS_V12 build_unflags = ${STM32F1_maple.build_unflags} -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index ed60983a23..58b33afaaf 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -64,13 +64,14 @@ board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 [USBD_CDC_MSC] -build_flags = -DUSE_USB_FS -DUSBD_USE_CDC_MSC -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 +build_flags = -DUSE_USB_FS -DUSBD_USE_CDC_MSC -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 +build_unflags = -DUSBD_USE_CDC [env:STM32F103RC_btt_USB] extends = env:STM32F103RC_btt platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${env:STM32F103RC_btt.build_flags} ${USBD_CDC_MSC.build_flags} -build_unflags = ${env:STM32F103RC_btt.build_unflags} -DUSBD_USE_CDC +build_unflags = ${env:STM32F103RC_btt.build_unflags} ${USBD_CDC_MSC.build_unflags} # # Panda Pi V2.9 - Standalone (STM32F103RC) @@ -227,7 +228,7 @@ upload_protocol = jlink extends = env:STM32F103RE_btt platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${env:STM32F103RE_btt.build_flags} ${USBD_CDC_MSC.build_flags} -build_unflags = ${env:STM32F103RE_btt.build_unflags} -DUSBD_USE_CDC +build_unflags = ${env:STM32F103RE_btt.build_unflags} ${USBD_CDC_MSC.build_unflags} # # ZNP Robin Nano V1.2 @@ -473,7 +474,7 @@ board_upload.maximum_size = 237568 extra_scripts = ${stm32_variant.extra_scripts} build_flags = ${stm32_variant.build_flags} ${USBD_CDC_MSC.build_flags} -DSS_TIMER=4 -DTIMER_SERVO=TIM5 -build_unflags = ${stm32_variant.build_unflags} -DUSBD_USE_CDC +build_unflags = ${stm32_variant.build_unflags} ${USBD_CDC_MSC.build_unflags} [env:STM32F103RC_ZM3E2_USB] extends = ZONESTAR_ZM3E From 75d60b77bac5300e38725c0aae6f788b70ef085b Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 27 Apr 2025 00:37:52 +0000 Subject: [PATCH 36/51] [cron] Bump distribution date (2025-04-27) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index c96f304a03..d48398ed22 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 "2025-04-25" +//#define STRING_DISTRIBUTION_DATE "2025-04-27" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 43e63deb20..f3a12580c9 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 "2025-04-25" + #define STRING_DISTRIBUTION_DATE "2025-04-27" #endif /** From 4d8f82df328016c1b325520d9af10d25e3a86aee Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 27 Apr 2025 15:02:58 -0500 Subject: [PATCH 37/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Organ?= =?UTF-8?q?ize=20some=20HAL=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/HAL.h | 2 +- Marlin/src/HAL/DUE/usb/ctrl_access.c | 4 ++-- Marlin/src/HAL/ESP32/HAL.cpp | 10 ++++------ Marlin/src/HAL/ESP32/HAL.h | 8 +++----- Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp | 2 +- Marlin/src/HAL/ESP32/{ => wifi}/WebSocketSerial.cpp | 2 +- Marlin/src/HAL/ESP32/{ => wifi}/WebSocketSerial.h | 4 ++-- Marlin/src/HAL/ESP32/{ => wifi}/ota.cpp | 2 +- Marlin/src/HAL/ESP32/{ => wifi}/ota.h | 0 Marlin/src/HAL/ESP32/{ => wifi}/spiffs.cpp | 4 ++-- Marlin/src/HAL/ESP32/{ => wifi}/spiffs.h | 0 Marlin/src/HAL/ESP32/{ => wifi}/web.cpp | 4 ++-- Marlin/src/HAL/ESP32/{ => wifi}/web.h | 0 Marlin/src/HAL/ESP32/{ => wifi}/wifi.cpp | 4 ++-- Marlin/src/HAL/ESP32/{ => wifi}/wifi.h | 0 Marlin/src/HAL/GD32_MFL/{ => sd}/SDCard.cpp | 6 +++--- Marlin/src/HAL/GD32_MFL/{ => sd}/SDCard.h | 4 ++-- Marlin/src/HAL/GD32_MFL/{ => sd}/sdio.cpp | 6 ++---- Marlin/src/HAL/GD32_MFL/{ => sd}/sdio.h | 0 Marlin/src/HAL/HAL.h | 2 +- Marlin/src/HAL/LINUX/HAL.h | 2 +- Marlin/src/HAL/LINUX/arduino.cpp | 2 -- Marlin/src/HAL/LINUX/include/Arduino.h | 1 - Marlin/src/HAL/NATIVE_SIM/HAL.h | 2 +- Marlin/src/HAL/RP2040/HAL.cpp | 2 +- Marlin/src/HAL/RP2040/HAL.h | 2 +- Marlin/src/HAL/STM32/HAL.cpp | 6 +++--- Marlin/src/HAL/STM32/HAL.h | 8 ++------ Marlin/src/HAL/STM32/{ => sd}/msc_sd.cpp | 11 +++++------ Marlin/src/HAL/STM32/{ => sd}/msc_sd.h | 0 Marlin/src/HAL/STM32/{ => sd}/usb_host.cpp | 9 ++++----- Marlin/src/HAL/STM32/{ => sd}/usb_host.h | 0 Marlin/src/HAL/STM32F1/HAL.cpp | 2 +- Marlin/src/HAL/STM32F1/HAL.h | 2 +- Marlin/src/HAL/STM32F1/{ => sd}/msc_sd.cpp | 9 +++++---- Marlin/src/HAL/STM32F1/{ => sd}/msc_sd.h | 4 ++-- Marlin/src/HAL/STM32F1/{ => sd}/onboard_sd.cpp | 6 +++--- Marlin/src/HAL/STM32F1/{ => sd}/onboard_sd.h | 0 Marlin/src/HAL/STM32F1/{ => sd}/sdio.cpp | 6 +++--- Marlin/src/HAL/STM32F1/{ => sd}/sdio.h | 2 +- Marlin/src/HAL/shared/math_32bit.h | 1 + Marlin/src/inc/MarlinConfig.h | 1 - Marlin/src/inc/MarlinConfigPre-6-type.h | 1 - Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 6 +++--- Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp | 4 ++-- Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp | 4 ++-- Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp | 4 ++-- Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp | 4 ++-- Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp | 4 ++-- 49 files changed, 77 insertions(+), 92 deletions(-) rename Marlin/src/HAL/ESP32/{ => wifi}/WebSocketSerial.cpp (99%) rename Marlin/src/HAL/ESP32/{ => wifi}/WebSocketSerial.h (96%) rename Marlin/src/HAL/ESP32/{ => wifi}/ota.cpp (98%) rename Marlin/src/HAL/ESP32/{ => wifi}/ota.h (100%) rename Marlin/src/HAL/ESP32/{ => wifi}/spiffs.cpp (94%) rename Marlin/src/HAL/ESP32/{ => wifi}/spiffs.h (100%) rename Marlin/src/HAL/ESP32/{ => wifi}/web.cpp (94%) rename Marlin/src/HAL/ESP32/{ => wifi}/web.h (100%) rename Marlin/src/HAL/ESP32/{ => wifi}/wifi.cpp (96%) rename Marlin/src/HAL/ESP32/{ => wifi}/wifi.h (100%) rename Marlin/src/HAL/GD32_MFL/{ => sd}/SDCard.cpp (99%) rename Marlin/src/HAL/GD32_MFL/{ => sd}/SDCard.h (99%) rename Marlin/src/HAL/GD32_MFL/{ => sd}/sdio.cpp (98%) rename Marlin/src/HAL/GD32_MFL/{ => sd}/sdio.h (100%) rename Marlin/src/HAL/STM32/{ => sd}/msc_sd.cpp (96%) rename Marlin/src/HAL/STM32/{ => sd}/msc_sd.h (100%) rename Marlin/src/HAL/STM32/{ => sd}/usb_host.cpp (96%) rename Marlin/src/HAL/STM32/{ => sd}/usb_host.h (100%) rename Marlin/src/HAL/STM32F1/{ => sd}/msc_sd.cpp (96%) rename Marlin/src/HAL/STM32F1/{ => sd}/msc_sd.h (93%) rename Marlin/src/HAL/STM32F1/{ => sd}/onboard_sd.cpp (99%) rename Marlin/src/HAL/STM32F1/{ => sd}/onboard_sd.h (100%) rename Marlin/src/HAL/STM32F1/{ => sd}/sdio.cpp (98%) rename Marlin/src/HAL/STM32F1/{ => sd}/sdio.h (98%) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index b420236956..e7a82a3b83 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -204,7 +204,7 @@ public: static void isr_on() { sei(); } static void isr_off() { cli(); } - static void delay_ms(const int ms) { _delay_ms(ms); } + static void delay_ms(const int ms) { delay(ms); } // Tasks, called from idle() static void idletask() {} diff --git a/Marlin/src/HAL/DUE/usb/ctrl_access.c b/Marlin/src/HAL/DUE/usb/ctrl_access.c index b766ed1273..ec0e4adc4b 100644 --- a/Marlin/src/HAL/DUE/usb/ctrl_access.c +++ b/Marlin/src/HAL/DUE/usb/ctrl_access.c @@ -63,8 +63,8 @@ #include "compiler.h" #include "preprocessor.h" #ifdef FREERTOS_USED -#include "FreeRTOS.h" -#include "semphr.h" +#include +#include #endif #include "ctrl_access.h" diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 415e2510e2..705b856aaa 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -34,13 +34,13 @@ #if ENABLED(WIFISUPPORT) #include - #include "wifi.h" + #include "wifi/wifi.h" #if ENABLED(OTASUPPORT) - #include "ota.h" + #include "wifi/ota.h" #endif #if ENABLED(WEBSUPPORT) - #include "spiffs.h" - #include "web.h" + #include "wifi/spiffs.h" + #include "wifi/web.h" #endif #endif @@ -175,8 +175,6 @@ uint8_t MarlinHAL::get_reset_source() { return rtc_get_reset_reason(1); } void MarlinHAL::reboot() { ESP.restart(); } -void _delay_ms(const int ms) { delay(ms); } - // return free memory between end of heap (or end bss) and whatever is current int MarlinHAL::freeMemory() { return ESP.getFreeHeap(); } diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 0acb3676a2..baa03d8a76 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -37,11 +37,11 @@ #include "i2s.h" #if ENABLED(WIFISUPPORT) - #include "WebSocketSerial.h" + #include "wifi/WebSocketSerial.h" #endif #if ENABLED(ESP3D_WIFISUPPORT) - #include "esp3dlib.h" + #include #endif #include "FlushableHardwareSerial.h" @@ -165,8 +165,6 @@ int freeMemory(); #pragma GCC diagnostic pop -void _delay_ms(const int ms); - // ------------------------ // MarlinHAL Class // ------------------------ @@ -194,7 +192,7 @@ public: static void isr_on() { if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock); } static void isr_off() { portENTER_CRITICAL(&spinlock); } - static void delay_ms(const int ms) { _delay_ms(ms); } + static void delay_ms(const int ms) { delay(ms); } // Tasks, called from idle() static void idletask(); diff --git a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp index a4c1980adc..42903da9d3 100644 --- a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp +++ b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp @@ -35,7 +35,7 @@ #if HAS_MEDIA #include "../../sd/cardreader.h" #if ENABLED(ESP3D_WIFISUPPORT) - #include "sd_ESP32.h" + #include #endif #endif diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp b/Marlin/src/HAL/ESP32/wifi/WebSocketSerial.cpp similarity index 99% rename from Marlin/src/HAL/ESP32/WebSocketSerial.cpp rename to Marlin/src/HAL/ESP32/wifi/WebSocketSerial.cpp index eb5b9d6039..9c8933289d 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp +++ b/Marlin/src/HAL/ESP32/wifi/WebSocketSerial.cpp @@ -21,7 +21,7 @@ */ #ifdef ARDUINO_ARCH_ESP32 -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ENABLED(WIFISUPPORT) diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.h b/Marlin/src/HAL/ESP32/wifi/WebSocketSerial.h similarity index 96% rename from Marlin/src/HAL/ESP32/WebSocketSerial.h rename to Marlin/src/HAL/ESP32/wifi/WebSocketSerial.h index 6b3e419d10..3d2fdf1e6a 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.h +++ b/Marlin/src/HAL/ESP32/wifi/WebSocketSerial.h @@ -21,8 +21,8 @@ */ #pragma once -#include "../../inc/MarlinConfig.h" -#include "../../core/serial_hook.h" +#include "../../../inc/MarlinConfig.h" +#include "../../../core/serial_hook.h" #include diff --git a/Marlin/src/HAL/ESP32/ota.cpp b/Marlin/src/HAL/ESP32/wifi/ota.cpp similarity index 98% rename from Marlin/src/HAL/ESP32/ota.cpp rename to Marlin/src/HAL/ESP32/wifi/ota.cpp index be5847b831..03508840a5 100644 --- a/Marlin/src/HAL/ESP32/ota.cpp +++ b/Marlin/src/HAL/ESP32/wifi/ota.cpp @@ -27,7 +27,7 @@ #undef ENABLED #undef DISABLED -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ALL(WIFISUPPORT, OTASUPPORT) diff --git a/Marlin/src/HAL/ESP32/ota.h b/Marlin/src/HAL/ESP32/wifi/ota.h similarity index 100% rename from Marlin/src/HAL/ESP32/ota.h rename to Marlin/src/HAL/ESP32/wifi/ota.h diff --git a/Marlin/src/HAL/ESP32/spiffs.cpp b/Marlin/src/HAL/ESP32/wifi/spiffs.cpp similarity index 94% rename from Marlin/src/HAL/ESP32/spiffs.cpp rename to Marlin/src/HAL/ESP32/wifi/spiffs.cpp index 043ad7849a..ba891acda9 100644 --- a/Marlin/src/HAL/ESP32/spiffs.cpp +++ b/Marlin/src/HAL/ESP32/wifi/spiffs.cpp @@ -21,11 +21,11 @@ */ #ifdef ARDUINO_ARCH_ESP32 -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ALL(WIFISUPPORT, WEBSUPPORT) -#include "../../core/serial.h" +#include "../../../core/serial.h" #include #include diff --git a/Marlin/src/HAL/ESP32/spiffs.h b/Marlin/src/HAL/ESP32/wifi/spiffs.h similarity index 100% rename from Marlin/src/HAL/ESP32/spiffs.h rename to Marlin/src/HAL/ESP32/wifi/spiffs.h diff --git a/Marlin/src/HAL/ESP32/web.cpp b/Marlin/src/HAL/ESP32/wifi/web.cpp similarity index 94% rename from Marlin/src/HAL/ESP32/web.cpp rename to Marlin/src/HAL/ESP32/wifi/web.cpp index 63a101595f..f08dfd87c0 100644 --- a/Marlin/src/HAL/ESP32/web.cpp +++ b/Marlin/src/HAL/ESP32/wifi/web.cpp @@ -21,11 +21,11 @@ */ #ifdef ARDUINO_ARCH_ESP32 -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ALL(WIFISUPPORT, WEBSUPPORT) -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #undef DISABLED // esp32-hal-gpio.h #include diff --git a/Marlin/src/HAL/ESP32/web.h b/Marlin/src/HAL/ESP32/wifi/web.h similarity index 100% rename from Marlin/src/HAL/ESP32/web.h rename to Marlin/src/HAL/ESP32/wifi/web.h diff --git a/Marlin/src/HAL/ESP32/wifi.cpp b/Marlin/src/HAL/ESP32/wifi/wifi.cpp similarity index 96% rename from Marlin/src/HAL/ESP32/wifi.cpp rename to Marlin/src/HAL/ESP32/wifi/wifi.cpp index aa2796adea..1f31ca1bb9 100644 --- a/Marlin/src/HAL/ESP32/wifi.cpp +++ b/Marlin/src/HAL/ESP32/wifi/wifi.cpp @@ -21,11 +21,11 @@ */ #ifdef ARDUINO_ARCH_ESP32 -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ENABLED(WIFISUPPORT) -#include "../../core/serial.h" +#include "../../../core/serial.h" #include #include diff --git a/Marlin/src/HAL/ESP32/wifi.h b/Marlin/src/HAL/ESP32/wifi/wifi.h similarity index 100% rename from Marlin/src/HAL/ESP32/wifi.h rename to Marlin/src/HAL/ESP32/wifi/wifi.h diff --git a/Marlin/src/HAL/GD32_MFL/SDCard.cpp b/Marlin/src/HAL/GD32_MFL/sd/SDCard.cpp similarity index 99% rename from Marlin/src/HAL/GD32_MFL/SDCard.cpp rename to Marlin/src/HAL/GD32_MFL/sd/SDCard.cpp index 15d33d2596..c46e0fc6fb 100644 --- a/Marlin/src/HAL/GD32_MFL/SDCard.cpp +++ b/Marlin/src/HAL/GD32_MFL/sd/SDCard.cpp @@ -15,12 +15,12 @@ // If not, see . // -#include "../platforms.h" +#include "../../platforms.h" #ifdef ARDUINO_ARCH_MFL -#include "../../inc/MarlinConfig.h" -#include "../shared/Delay.h" +#include "../../../inc/MarlinConfig.h" +#include "../../shared/Delay.h" #include "SDCard.h" #include diff --git a/Marlin/src/HAL/GD32_MFL/SDCard.h b/Marlin/src/HAL/GD32_MFL/sd/SDCard.h similarity index 99% rename from Marlin/src/HAL/GD32_MFL/SDCard.h rename to Marlin/src/HAL/GD32_MFL/sd/SDCard.h index 467482a605..e202be6eb5 100644 --- a/Marlin/src/HAL/GD32_MFL/SDCard.h +++ b/Marlin/src/HAL/GD32_MFL/sd/SDCard.h @@ -16,9 +16,9 @@ // #pragma once -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" -#include "SDIO.hpp" +#include namespace sdio { diff --git a/Marlin/src/HAL/GD32_MFL/sdio.cpp b/Marlin/src/HAL/GD32_MFL/sd/sdio.cpp similarity index 98% rename from Marlin/src/HAL/GD32_MFL/sdio.cpp rename to Marlin/src/HAL/GD32_MFL/sd/sdio.cpp index 4b6d75d74f..69905feb51 100644 --- a/Marlin/src/HAL/GD32_MFL/sdio.cpp +++ b/Marlin/src/HAL/GD32_MFL/sd/sdio.cpp @@ -20,11 +20,11 @@ * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef ARDUINO_ARCH_MFL -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(ONBOARD_SDIO) @@ -215,7 +215,6 @@ void DMA1_IRQHandler() { } } - extern "C" { void SDIO_IRQHandler(void) { @@ -228,6 +227,5 @@ extern "C" { } // extern "C" - #endif // ONBOARD_SDIO #endif // ARDUINO_ARCH_MFL diff --git a/Marlin/src/HAL/GD32_MFL/sdio.h b/Marlin/src/HAL/GD32_MFL/sd/sdio.h similarity index 100% rename from Marlin/src/HAL/GD32_MFL/sdio.h rename to Marlin/src/HAL/GD32_MFL/sd/sdio.h diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index f3e16cfdf1..a211dfe259 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -27,7 +27,7 @@ #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif -#include HAL_PATH(..,HAL.h) +#include HAL_PATH(.., HAL.h) extern MarlinHAL hal; #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index bb5fb73e05..68e0e1062c 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -124,7 +124,7 @@ public: static void isr_on() {} static void isr_off() {} - static void delay_ms(const int ms) { _delay_ms(ms); } + static void delay_ms(const int ms) { delay(ms); } // Tasks, called from idle() static void idletask() {} diff --git a/Marlin/src/HAL/LINUX/arduino.cpp b/Marlin/src/HAL/LINUX/arduino.cpp index a387a9623e..0a09a11091 100644 --- a/Marlin/src/HAL/LINUX/arduino.cpp +++ b/Marlin/src/HAL/LINUX/arduino.cpp @@ -31,8 +31,6 @@ void cli() { } // Disable void sei() { } // Enable // Time functions -void _delay_ms(const int ms) { delay(ms); } - unsigned long millis() { return (unsigned long)Clock::millis(); } diff --git a/Marlin/src/HAL/LINUX/include/Arduino.h b/Marlin/src/HAL/LINUX/include/Arduino.h index b11e75ccbc..87148a40b2 100644 --- a/Marlin/src/HAL/LINUX/include/Arduino.h +++ b/Marlin/src/HAL/LINUX/include/Arduino.h @@ -74,7 +74,6 @@ extern "C" { // Time functions extern "C" void delay(const int ms); -void _delay_ms(const int ms); void delayMicroseconds(unsigned long); unsigned long millis(); diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index ffede7ef34..661c502f22 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -195,7 +195,7 @@ public: static void isr_on() {} static void isr_off() {} - static void delay_ms(const int ms) { _delay_ms(ms); } + static void delay_ms(const int ms) { delay(ms); } // Tasks, called from idle() static void idletask(); diff --git a/Marlin/src/HAL/RP2040/HAL.cpp b/Marlin/src/HAL/RP2040/HAL.cpp index 6e35fac938..8c35d45542 100644 --- a/Marlin/src/HAL/RP2040/HAL.cpp +++ b/Marlin/src/HAL/RP2040/HAL.cpp @@ -87,7 +87,7 @@ void MarlinHAL::init() { #if PIN_EXISTS(USB_CONNECT) OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection - delay_ms(1000); // Give OS time to notice + delay_ms(1000); // Give OS time to notice WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING); #endif } diff --git a/Marlin/src/HAL/RP2040/HAL.h b/Marlin/src/HAL/RP2040/HAL.h index fbd3b61e1c..4862986d11 100644 --- a/Marlin/src/HAL/RP2040/HAL.h +++ b/Marlin/src/HAL/RP2040/HAL.h @@ -139,7 +139,7 @@ public: static void isr_on() { __enable_irq(); } static void isr_off() { __disable_irq(); } - static void delay_ms(const int ms) { ::delay(ms); } + static void delay_ms(const int ms) { delay(ms); } // Tasks, called from idle() static void idletask() {} diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index a44c333096..bdccdd546d 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -43,8 +43,8 @@ #endif #if HAS_SD_HOST_DRIVE - #include "msc_sd.h" - #include "usbd_cdc_if.h" + #include "sd/msc_sd.h" + #include #endif // ------------------------ @@ -97,7 +97,7 @@ void MarlinHAL::init() { #if PIN_EXISTS(USB_CONNECT) OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection - delay(1000); // Give OS time to notice + delay_ms(1000); // Give OS time to notice WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING); #endif } diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index f43413fcd9..a8ef51bcfc 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -23,18 +23,14 @@ #define CPU_32_BIT -#include "../../core/macros.h" -#include "../shared/Marduino.h" +#include "../../inc/MarlinConfigPre.h" + #include "../shared/math_32bit.h" #include "../shared/HAL_SPI.h" #include "temp_soc.h" #include "fastio.h" #include "Servo.h" -#include "../../inc/MarlinConfigPre.h" - -#include - // // Default graphical display delays // diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/sd/msc_sd.cpp similarity index 96% rename from Marlin/src/HAL/STM32/msc_sd.cpp rename to Marlin/src/HAL/STM32/sd/msc_sd.cpp index d4afc5990a..f198b3e49a 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/sd/msc_sd.cpp @@ -20,20 +20,19 @@ * along with this program. If not, see . * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef HAL_STM32 -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if HAS_SD_HOST_DRIVE -#include "../shared/Marduino.h" +#include "../../../sd/cardreader.h" + #include "msc_sd.h" -#include "usbd_core.h" - -#include "../../sd/cardreader.h" +#include #include #include diff --git a/Marlin/src/HAL/STM32/msc_sd.h b/Marlin/src/HAL/STM32/sd/msc_sd.h similarity index 100% rename from Marlin/src/HAL/STM32/msc_sd.h rename to Marlin/src/HAL/STM32/sd/msc_sd.h diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/sd/usb_host.cpp similarity index 96% rename from Marlin/src/HAL/STM32/usb_host.cpp rename to Marlin/src/HAL/STM32/sd/usb_host.cpp index afafe1d4f3..f411771c8a 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/sd/usb_host.cpp @@ -20,18 +20,17 @@ * */ -#include "../platforms.h" +#include "../../platforms.h" #ifdef HAL_STM32 -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if ALL(USE_OTG_USB_HOST, USBHOST) #include "usb_host.h" -#include "../shared/Marduino.h" -#include "usbh_core.h" -#include "usbh_msc.h" +#include +#include USBH_HandleTypeDef hUsbHost; USBHost usb; diff --git a/Marlin/src/HAL/STM32/usb_host.h b/Marlin/src/HAL/STM32/sd/usb_host.h similarity index 100% rename from Marlin/src/HAL/STM32/usb_host.h rename to Marlin/src/HAL/STM32/sd/usb_host.h diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index 4072e55652..b0f86ae4ed 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -253,7 +253,7 @@ void MarlinHAL::init() { #endif #if PIN_EXISTS(USB_CONNECT) OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection - delay(1000); // Give OS time to notice + delay_ms(1000); // Give OS time to notice WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING); #endif TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the minimal serial handler diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index daf94dceb5..68773bdf27 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -40,7 +40,7 @@ #include "../../inc/MarlinConfigPre.h" #if HAS_SD_HOST_DRIVE - #include "msc_sd.h" + #include "sd/msc_sd.h" #endif // ------------------------ diff --git a/Marlin/src/HAL/STM32F1/msc_sd.cpp b/Marlin/src/HAL/STM32F1/sd/msc_sd.cpp similarity index 96% rename from Marlin/src/HAL/STM32F1/msc_sd.cpp rename to Marlin/src/HAL/STM32F1/sd/msc_sd.cpp index 067b46eb8b..5f1ba30c8a 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.cpp +++ b/Marlin/src/HAL/STM32F1/sd/msc_sd.cpp @@ -22,20 +22,21 @@ */ #ifdef __STM32F1__ -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if HAS_SD_HOST_DRIVE #include "msc_sd.h" -#include "SPI.h" -#include "usb_reg_map.h" +#include "../SPI.h" + +#include #define PRODUCT_ID 0x29 USBMassStorage MarlinMSC; Serial1Class MarlinCompositeSerial(true); -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if SD_CONNECTION_IS(ONBOARD) diff --git a/Marlin/src/HAL/STM32F1/msc_sd.h b/Marlin/src/HAL/STM32F1/sd/msc_sd.h similarity index 93% rename from Marlin/src/HAL/STM32F1/msc_sd.h rename to Marlin/src/HAL/STM32F1/sd/msc_sd.h index 371211efc6..871d98eaf2 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.h +++ b/Marlin/src/HAL/STM32F1/sd/msc_sd.h @@ -24,8 +24,8 @@ #include -#include "../../inc/MarlinConfigPre.h" -#include "../../core/serial_hook.h" +#include "../../../inc/MarlinConfigPre.h" +#include "../../../core/serial_hook.h" extern USBMassStorage MarlinMSC; extern Serial1Class MarlinCompositeSerial; diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.cpp b/Marlin/src/HAL/STM32F1/sd/onboard_sd.cpp similarity index 99% rename from Marlin/src/HAL/STM32F1/onboard_sd.cpp rename to Marlin/src/HAL/STM32F1/sd/onboard_sd.cpp index a3d8dcb2d5..ace1204b75 100644 --- a/Marlin/src/HAL/STM32F1/onboard_sd.cpp +++ b/Marlin/src/HAL/STM32F1/sd/onboard_sd.cpp @@ -13,13 +13,13 @@ #ifdef __STM32F1__ -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #if SD_CONNECTION_IS(ONBOARD) #include "onboard_sd.h" -#include "SPI.h" -#include "fastio.h" +#include "../SPI.h" +#include "../fastio.h" #ifndef ONBOARD_SPI_DEVICE #define ONBOARD_SPI_DEVICE SPI_DEVICE diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.h b/Marlin/src/HAL/STM32F1/sd/onboard_sd.h similarity index 100% rename from Marlin/src/HAL/STM32F1/onboard_sd.h rename to Marlin/src/HAL/STM32F1/sd/onboard_sd.h diff --git a/Marlin/src/HAL/STM32F1/sdio.cpp b/Marlin/src/HAL/STM32F1/sd/sdio.cpp similarity index 98% rename from Marlin/src/HAL/STM32F1/sdio.cpp rename to Marlin/src/HAL/STM32F1/sd/sdio.cpp index 258422eba3..d657fd3b0e 100644 --- a/Marlin/src/HAL/STM32F1/sdio.cpp +++ b/Marlin/src/HAL/STM32F1/sd/sdio.cpp @@ -19,11 +19,11 @@ * along with this program. If not, see . * */ -#ifdef ARDUINO_ARCH_STM32F1 +#ifdef __STM32F1__ #include -#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density +#include "../../../inc/MarlinConfig.h" // Allow pins/pins.h to set density #if ANY(STM32_HIGH_DENSITY, STM32_XL_DENSITY) @@ -308,4 +308,4 @@ bool SDIO_GetCmdResp7() { } #endif // STM32_HIGH_DENSITY || STM32_XL_DENSITY -#endif // ARDUINO_ARCH_STM32F1 +#endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/sdio.h b/Marlin/src/HAL/STM32F1/sd/sdio.h similarity index 98% rename from Marlin/src/HAL/STM32F1/sdio.h rename to Marlin/src/HAL/STM32F1/sd/sdio.h index 08c884666d..ffcd354915 100644 --- a/Marlin/src/HAL/STM32F1/sdio.h +++ b/Marlin/src/HAL/STM32F1/sd/sdio.h @@ -21,7 +21,7 @@ */ #pragma once -#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to override SDIO clock / retries +#include "../../../inc/MarlinConfig.h" // Allow pins/pins.h to override SDIO clock / retries #include #include diff --git a/Marlin/src/HAL/shared/math_32bit.h b/Marlin/src/HAL/shared/math_32bit.h index 1fb233e3e8..daf82e0650 100644 --- a/Marlin/src/HAL/shared/math_32bit.h +++ b/Marlin/src/HAL/shared/math_32bit.h @@ -22,6 +22,7 @@ #pragma once #include "../../core/macros.h" +#include /** * Math helper functions for 32 bit CPUs diff --git a/Marlin/src/inc/MarlinConfig.h b/Marlin/src/inc/MarlinConfig.h index 0164b7c2f7..f962a5ff5c 100644 --- a/Marlin/src/inc/MarlinConfig.h +++ b/Marlin/src/inc/MarlinConfig.h @@ -25,7 +25,6 @@ // Prefix header for all Marlin sources // -#include "MarlinConfigPre-6-type.h" // Include even with __MARLIN_DEPS__ #include "Conditionals-6-type.h" #ifndef __MARLIN_DEPS__ diff --git a/Marlin/src/inc/MarlinConfigPre-6-type.h b/Marlin/src/inc/MarlinConfigPre-6-type.h index 31597c6eb8..09367219d9 100644 --- a/Marlin/src/inc/MarlinConfigPre-6-type.h +++ b/Marlin/src/inc/MarlinConfigPre-6-type.h @@ -21,7 +21,6 @@ */ #pragma once -#include "MarlinConfigPre-5-post.h" #include "Conditionals-5-post.h" #ifndef __MARLIN_DEPS__ diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index e6e6f30ae6..8b25df16b9 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -84,10 +84,10 @@ #elif ENABLED(USE_OTG_USB_HOST) #if HAS_SD_HOST_DRIVE - #include HAL_PATH(../.., msc_sd.h) + #include HAL_PATH(../.., sd/msc_sd.h) #endif - #include HAL_PATH(../.., usb_host.h) + #include HAL_PATH(../.., sd/usb_host.h) #define UHS_START usb.start() #define rREVISION 0 @@ -293,7 +293,7 @@ uint32_t DiskIODriver_USBFlash::cardSize() { #if USB_DEBUG < 3 const uint32_t #endif - lun0_capacity = bulk.GetCapacity(0); + lun0_capacity = bulk.GetCapacity(0); return lun0_capacity; } diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp index aa102e228f..6c45b7eee7 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp @@ -29,7 +29,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if HAS_USB_FLASH_DRIVE && DISABLED(USE_UHS3_USB) +#if ALL(HAS_USB_FLASH_DRIVE, USE_UHS2_USB) #include "Usb.h" @@ -792,4 +792,4 @@ uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { return ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, nullptr, nullptr); } -#endif // HAS_USB_FLASH_DRIVE && !USE_UHS3_USB +#endif // HAS_USB_FLASH_DRIVE && USE_UHS2_USB diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp index a6124ab0fe..c311d7f9dd 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp @@ -25,7 +25,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if HAS_USB_FLASH_DRIVE && DISABLED(USE_UHS3_USB) +#if ALL(HAS_USB_FLASH_DRIVE, USE_UHS2_USB) #include "masstorage.h" @@ -1204,4 +1204,4 @@ uint8_t BulkOnly::Read(uint8_t lun __attribute__((unused)), uint32_t addr __attr #endif } -#endif // HAS_USB_FLASH_DRIVE && !USE_UHS3_USB +#endif // HAS_USB_FLASH_DRIVE && USE_UHS2_USB diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp index afe9e86e52..2984a6cf03 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp @@ -25,7 +25,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if HAS_USB_FLASH_DRIVE && DISABLED(USE_UHS3_USB) +#if ALL(HAS_USB_FLASH_DRIVE, USE_UHS2_USB) #include "Usb.h" @@ -125,4 +125,4 @@ void E_Notify(double d, int lvl) { #endif // DEBUG_USB_HOST -#endif // HAS_USB_FLASH_DRIVE && !USE_UHS3_USB +#endif // HAS_USB_FLASH_DRIVE && USE_UHS2_USB diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp index 4b2ef4b1f9..ae34006742 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp @@ -25,7 +25,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if HAS_USB_FLASH_DRIVE && DISABLED(USE_UHS3_USB) +#if ALL(HAS_USB_FLASH_DRIVE, USE_UHS2_USB) #include "Usb.h" @@ -74,4 +74,4 @@ bool PTPListParser::Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, return true; } -#endif // HAS_USB_FLASH_DRIVE && !USE_UHS3_USB +#endif // HAS_USB_FLASH_DRIVE && USE_UHS2_USB diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp index 6f3d44dd7f..47282bbd63 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp @@ -25,7 +25,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if HAS_USB_FLASH_DRIVE && DISABLED(USE_UHS3_USB) +#if ALL(HAS_USB_FLASH_DRIVE, USE_UHS2_USB) #if !PINS_EXIST(USB_CS, USB_INTR) #error "USB_FLASH_DRIVE_SUPPORT requires USB_CS_PIN and USB_INTR_PIN (or USE_UHS3_USB) to be defined." @@ -203,4 +203,4 @@ uint8_t MAX3421e::IntHandler() { return HIRQ_sendback; } -#endif // HAS_USB_FLASH_DRIVE && !USE_UHS3_USB +#endif // HAS_USB_FLASH_DRIVE && USE_UHS2_USB From 38d6d61912df9a5220acdffc4064b287b78dab90 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 27 Apr 2025 18:50:35 -0500 Subject: [PATCH 38/51] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20MSC?= =?UTF-8?q?=20for=20RP2040=20-=20alpha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/RP2040/HAL.h | 8 +- Marlin/src/HAL/RP2040/HAL_MinSerial.cpp | 1 - Marlin/src/HAL/RP2040/inc/Conditionals_adv.h | 2 +- Marlin/src/HAL/RP2040/msc_sd.cpp | 148 ++++++++----------- ini/raspberrypi.ini | 1 + 5 files changed, 64 insertions(+), 96 deletions(-) diff --git a/Marlin/src/HAL/RP2040/HAL.h b/Marlin/src/HAL/RP2040/HAL.h index 4862986d11..11472f72f5 100644 --- a/Marlin/src/HAL/RP2040/HAL.h +++ b/Marlin/src/HAL/RP2040/HAL.h @@ -29,16 +29,16 @@ #include "arduino_extras.h" #include "../../core/macros.h" -#include "../shared/Marduino.h" #include "../shared/math_32bit.h" #include "../shared/HAL_SPI.h" #include "fastio.h" -//#include "Servo.h" #include "watchdog.h" #include "../../inc/MarlinConfigPre.h" -#include +#if HAS_SD_HOST_DRIVE + #include "msc_sd.h" +#endif // // Serial Ports @@ -142,7 +142,7 @@ public: static void delay_ms(const int ms) { delay(ms); } // Tasks, called from idle() - static void idletask() {} + static void idletask() { TERN_(HAS_SD_HOST_DRIVE, tuh_task()); } // Reset static uint8_t get_reset_source(); diff --git a/Marlin/src/HAL/RP2040/HAL_MinSerial.cpp b/Marlin/src/HAL/RP2040/HAL_MinSerial.cpp index 5a65163591..d829edff24 100644 --- a/Marlin/src/HAL/RP2040/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/RP2040/HAL_MinSerial.cpp @@ -29,7 +29,6 @@ #include "../shared/HAL_MinSerial.h" - static void TXBegin() { #if !WITHIN(SERIAL_PORT, -1, 2) #warning "Using POSTMORTEM_DEBUGGING requires a physical U(S)ART hardware in case of severe error." diff --git a/Marlin/src/HAL/RP2040/inc/Conditionals_adv.h b/Marlin/src/HAL/RP2040/inc/Conditionals_adv.h index 442639e130..b96b3baa64 100644 --- a/Marlin/src/HAL/RP2040/inc/Conditionals_adv.h +++ b/Marlin/src/HAL/RP2040/inc/Conditionals_adv.h @@ -21,7 +21,7 @@ */ #pragma once -#if ALL(SDSUPPORT, USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE) +#if HAS_MEDIA && DISABLED(NO_SD_HOST_DRIVE) #define HAS_SD_HOST_DRIVE 1 #endif diff --git a/Marlin/src/HAL/RP2040/msc_sd.cpp b/Marlin/src/HAL/RP2040/msc_sd.cpp index 58c900302d..b0de2241e5 100644 --- a/Marlin/src/HAL/RP2040/msc_sd.cpp +++ b/Marlin/src/HAL/RP2040/msc_sd.cpp @@ -27,109 +27,77 @@ #if HAS_SD_HOST_DRIVE -#include "../shared/Marduino.h" -#include "msc_sd.h" -#include "usbd_core.h" - #include "../../sd/cardreader.h" -#include -#include +#include // TinyUSB device stack #define BLOCK_SIZE 512 -#define PRODUCT_ID 0x29 +#define SD_MULTIBLOCK_RETRY_CNT 1 -class Sd2CardUSBMscHandler : public USBMscHandler { -public: - DiskIODriver* diskIODriver() { - #if HAS_MULTI_VOLUME - #if SHARED_VOLUME_IS(SD_ONBOARD) - return &card.media_driver_sdcard; - #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) - return &card.media_driver_usbFlash; - #endif - #else - return card.diskIODriver(); +DiskIODriver* diskIODriver() { + #if HAS_MULTI_VOLUME + #if SHARED_VOLUME_IS(SD_ONBOARD) + return &card.media_driver_sdcard; + #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) + return &card.media_driver_usbFlash; #endif - } + #else + return card.diskIODriver(); + #endif +} - bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize) { - *pBlockNum = diskIODriver()->cardSize(); - *pBlockSize = BLOCK_SIZE; - return true; - } +/** Callbacks used by TinyUSB MSC **/ - bool Write(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) { - auto sd2card = diskIODriver(); - // single block - if (blkLen == 1) { - watchdog_refresh(); - sd2card->writeBlock(blkAddr, pBuf); - return true; +extern "C" { + +bool tud_msc_ready_cb(uint8_t lun) { + return diskIODriver()->isReady(); +} + +int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, void* buffer, uint32_t bufsize) { + const uint32_t blocks = bufsize / BLOCK_SIZE; + for (uint16_t rcount = SD_MULTIBLOCK_RETRY_CNT; rcount--; ) { + if (diskIODriver()->readBlocks(lba, (uint8_t*)buffer, blocks)) + return bufsize; // Success + } + return -1; // Failure after retries +} + +int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint8_t const* buffer, uint32_t bufsize) { + const uint32_t blocks = bufsize / BLOCK_SIZE; + for (uint16_t rcount = SD_MULTIBLOCK_RETRY_CNT; rcount--; ) { + if (diskIODriver()->writeBlocks(lba, buffer, blocks)) + return bufsize; // Success + } + return -1; // Failure after retries +} + +void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) { + memcpy(vendor_id, "MARLIN ", 8); + memcpy(product_id, "Product ", 16); + memcpy(product_rev, "0.01", 4); +} + +void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size) { + *block_count = diskIODriver()->cardSize(); + *block_size = BLOCK_SIZE; +} + +void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) { + if (load_eject) { + if (start) { + // Handle media load + } else { + // Handle media eject } - - // multi block optimization - sd2card->writeStart(blkAddr, blkLen); - while (blkLen--) { - watchdog_refresh(); - sd2card->writeData(pBuf); - pBuf += BLOCK_SIZE; - } - sd2card->writeStop(); - return true; } +} - bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) { - auto sd2card = diskIODriver(); - // single block - if (blkLen == 1) { - watchdog_refresh(); - sd2card->readBlock(blkAddr, pBuf); - return true; - } - - // multi block optimization - sd2card->readStart(blkAddr); - while (blkLen--) { - watchdog_refresh(); - sd2card->readData(pBuf); - pBuf += BLOCK_SIZE; - } - sd2card->readStop(); - return true; - } - - bool IsReady() { - return diskIODriver()->isReady(); - } -}; - -Sd2CardUSBMscHandler usbMscHandler; - -/* USB Mass storage Standard Inquiry Data */ -uint8_t Marlin_STORAGE_Inquirydata[] = { /* 36 */ - /* LUN 0 */ - 0x00, - 0x80, - 0x02, - 0x02, - (STANDARD_INQUIRY_DATA_LEN - 5), - 0x00, - 0x00, - 0x00, - 'M', 'A', 'R', 'L', 'I', 'N', ' ', ' ', /* Manufacturer : 8 bytes */ - 'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */ - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - '0', '.', '0', '1', /* Version : 4 Bytes */ -}; - -USBMscHandler *pSingleMscHandler = &usbMscHandler; +} // extern "C" void MSC_SD_init() { - USBDevice.end(); - delay(200); - USBDevice.registerMscHandlers(1, &pSingleMscHandler, Marlin_STORAGE_Inquirydata); - USBDevice.begin(); + tusb_init(); + // Add USB reinitialization logic if needed } #endif // HAS_SD_HOST_DRIVE diff --git a/ini/raspberrypi.ini b/ini/raspberrypi.ini index c61b89b461..059f4d1821 100644 --- a/ini/raspberrypi.ini +++ b/ini/raspberrypi.ini @@ -21,6 +21,7 @@ lib_ignore = WiFi build_flags = ${common.build_flags} -D__PLAT_RP2040__ -DPLATFORM_M997_SUPPORT -Wno-expansion-to-defined -Wno-vla -Wno-ignored-qualifiers #debug_tool = jlink #upload_protocol = jlink +custom_marlin.HAS_SD_HOST_DRIVE = tinyusb [env:RP2040-alt] extends = env:RP2040 From f78aaf956277bd73840a007a319ca487068f0683 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Apr 2025 11:06:47 -0500 Subject: [PATCH 39/51] =?UTF-8?q?=F0=9F=9A=B8=20Detect=20multi-volume=20in?= =?UTF-8?q?sert=20/=20remove?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 7 +- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 2 +- .../extui/mks_ui/tft_lvgl_configuration.cpp | 24 +-- Marlin/src/lcd/marlinui.cpp | 36 ++++- Marlin/src/lcd/marlinui.h | 2 +- Marlin/src/sd/cardreader.cpp | 152 ++++++++++++++---- Marlin/src/sd/cardreader.h | 11 ++ 7 files changed, 168 insertions(+), 66 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index de6677fc9a..aa229e80b6 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1349,8 +1349,11 @@ void setup() { #endif #endif - #if HAS_MEDIA && ANY(SDCARD_EEPROM_EMULATION, POWER_LOSS_RECOVERY) - SETUP_RUN(card.mount()); // Mount media with settings before first_load + #if HAS_MEDIA + SETUP_RUN(card.init()); // Prepare for media usage + #if ANY(SDCARD_EEPROM_EMULATION, POWER_LOSS_RECOVERY) + SETUP_RUN(card.mount()); // Mount media with settings before first_load + #endif #endif // Prepare some LCDs to display early diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index e6e8c88155..b4e1978283 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -740,7 +740,7 @@ void ChironTFT::panelAction(uint8_t req) { break; case 26: // A26 Refresh SD - if (card.isMounted())card.release(); + card.release(); card.mount(); safe_delay(500); filenavigator.reset(); diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp index 729d8bc4b2..903afad884 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -131,32 +131,16 @@ void tft_lvgl_init() { // Init TFT first! SPI_TFT.spiInit(SPI_FULL_SPEED); SPI_TFT.lcdInit(); - hal.watchdog_refresh(); // LVGL init takes time - #if HAS_USB_FLASH_DRIVE - #if HAS_MULTI_VOLUME && !HAS_SD_HOST_DRIVE - if (card.isSDCardInserted()) - card.selectMediaSDCard(); - else - card.selectMediaFlashDrive(); - #endif - // Wait up to two seconds for USB Drive to mount - for (uint16_t usb_flash_loop = 500; --usb_flash_loop;) { - hal.watchdog_refresh(); - card.media_driver_usbFlash.idle(); - delay(4); - if (card.media_driver_usbFlash.isInserted()) break; - } - card.mount(); - #elif HAS_LOGO_IN_FLASH + #if HAS_LOGO_IN_FLASH + // Leave the boot screen visible for a moment delay(1000); - hal.watchdog_refresh(); + hal.watchdog_refresh(); // LVGL init takes time delay(1000); + hal.watchdog_refresh(); // LVGL init takes time #endif - hal.watchdog_refresh(); // LVGL init takes time - #if HAS_MEDIA UpdateAssets(); hal.watchdog_refresh(); // LVGL init takes time diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index f6b1b60c7d..2b730581c8 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1891,40 +1891,60 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, #include "extui/ui_api.h" #endif - void MarlinUI::media_changed(const uint8_t old_status, const uint8_t status) { + void MarlinUI::media_changed(const MediaPresence old_status, const MediaPresence status) { TERN_(HAS_DISPLAY_SLEEP, refresh_screen_timeout()); if (old_status == status) { TERN_(EXTENSIBLE_UI, ExtUI::onMediaError()); // Failed to mount/unmount return; } - if (old_status < 2) { // Skip this section on first boot check - if (status) { // Media Mounted + if (old_status > MEDIA_BOOT) { // Skip this section on first boot check + + if (status > old_status) { // Media Mounted + #if ENABLED(EXTENSIBLE_UI) + ExtUI::onMediaMounted(); + #elif ENABLED(BROWSE_MEDIA_ON_INSERT) + clear_menu_history(); quick_feedback(); goto_screen(MEDIA_MENU_GATEWAY); + #else + if (card.isSDCardSelected()) LCD_MESSAGE(MSG_MEDIA_INSERTED_SD); else if (card.isFlashDriveSelected()) LCD_MESSAGE(MSG_MEDIA_INSERTED_USB); else LCD_MESSAGE(MSG_MEDIA_INSERTED); + #endif } else { // Media Removed + #if ENABLED(EXTENSIBLE_UI) + ExtUI::onMediaRemoved(); - #elif HAS_SD_DETECT // Q: Does "Media Removed" need to be shown for manual release too? - LCD_MESSAGE(MSG_MEDIA_REMOVED); - #if HAS_MARLINUI_MENU - if (ENABLED(HAS_WIRED_LCD) || !defer_return_to_status) return_to_status(); - #endif + + #elif HAS_SD_DETECT || HAS_USB_FLASH_DRIVE // Q: Does "Media Removed" need to be shown for manual release too? + + if ((old_status ^ status) & INSERT_SD) + LCD_MESSAGE(MSG_MEDIA_REMOVED_SD); + else if ((old_status ^ status) & INSERT_USB) + LCD_MESSAGE(MSG_MEDIA_REMOVED_USB); + else + LCD_MESSAGE(MSG_MEDIA_REMOVED); + + if (ENABLED(HAS_WIRED_LCD) || !defer_return_to_status) + return_to_status(); + #elif HAS_WIRED_LCD + return_to_status(); + #endif } } diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 9f2ac5a69a..076fc63f2a 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -256,7 +256,7 @@ public: #if HAS_MEDIA #define MEDIA_MENU_GATEWAY TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media) - static void media_changed(const uint8_t old_stat, const uint8_t stat); + static void media_changed(const MediaPresence old_stat, const MediaPresence stat); #endif #if HAS_LCD_BRIGHTNESS diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 21bc6e780a..5502561ea4 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -145,6 +145,7 @@ int16_t CardReader::nrItems = -1; #endif DiskIODriver* CardReader::driver = nullptr; + MarlinVolume CardReader::volume; MediaFile CardReader::myfile; @@ -483,11 +484,15 @@ void CardReader::mount() { nrItems = -1; if (root.isOpen()) root.close(); - if (!driver->init(SD_SPI_SPEED, SD_SS_PIN) + const bool driver_init = ( + driver->init(SD_SPI_SPEED, SD_SS_PIN) #if PIN_EXISTS(LCD_SDSS) && (LCD_SDSS_PIN != SD_SS_PIN) - && !driver->init(SD_SPI_SPEED, LCD_SDSS_PIN) + || driver->init(SD_SPI_SPEED, LCD_SDSS_PIN) #endif - ) SERIAL_ECHO_MSG(STR_SD_INIT_FAIL); + ); + + if (!driver_init) + SERIAL_ECHO_MSG(STR_SD_INIT_FAIL); else if (!volume.init(driver)) SERIAL_WARN_MSG(STR_SD_VOL_INIT_FAIL); else if (!root.openRoot(&volume)) @@ -519,69 +524,146 @@ void CardReader::mount() { #include "../module/stepper.h" #endif +// Provide a little time for drives to prepare +void CardReader::init() { + #if HAS_USB_FLASH_DRIVE + for (uint8_t i = 10; --i;) { + media_driver_usbFlash.idle(); + hal.watchdog_refresh(); + if (media_driver_usbFlash.isInserted()) break; + delay(20); + } + #endif +} + /** - * Handle SD card events + * Handle media insertion and removal events + * based on SD Card detect and/or driver.isInserted() + * + * MULTI_VOLUME: + * - Track insert/remove for both media drives. + * - If the MOUNTED media is removed call release(). + * - If media is INSERTED when NO MEDIA is mounted, select and mount it. */ void CardReader::manage_media() { - #if HAS_USB_FLASH_DRIVE // Wrap for optimal non-virtual? - driver->idle(); // Handle device tasks (e.g., USB Drive insert / remove) + /** + * Handle device tasks (e.g., USB Drive insert / remove) + * - USB Flash Drive needs to run even when not selected. + * - SD Card currently has no background tasks. + */ + //driver->idle(); + #if HAS_USB_FLASH_DRIVE + //if (!isFlashDriveSelected()) + media_driver_usbFlash.idle(); #endif - static uint8_t prev_stat = 2; // At boot we don't know if media is present or not - uint8_t stat = uint8_t(isInserted()); + // Prevent re-entry during Marlin::idle + #if HAS_MULTI_VOLUME + static bool no_reenter = false; + if (no_reenter) return; + #endif + + static MediaPresence prev_stat = MEDIA_BOOT; // At boot we don't know if media is present or not + + // Live status is based on available media flags + MediaPresence stat = MediaPresence( + #if HAS_MULTI_VOLUME + (isSDCardInserted() ? INSERT_SD : 0) // Without SD Detect it's always "inserted" + | (isFlashDriveInserted() ? INSERT_USB : 0) + #else + isInserted() ? INSERT_MEDIA : 0 // Without SD Detect it's always "inserted" + #endif + ); + if (stat == prev_stat) return; // Already checked and still no change? DEBUG_SECTION(cmm, "CardReader::manage_media()", true); DEBUG_ECHOLNPGM("Media present: ", prev_stat, " -> ", stat); - if (!ui.detected()) { - DEBUG_ECHOLNPGM("SD: No UI Detected."); - return; - } + // Without a UI there's no auto-mount or release + if (!ui.detected()) { DEBUG_ECHOLNPGM("SD: No UI Detected."); return; } - flag.workDirIsRoot = true; // Return to root on mount/release/init - - const uint8_t old_stat = prev_stat; + const MediaPresence old_stat = prev_stat, + old_real = old_stat == MEDIA_BOOT ? INSERT_NONE : old_stat; prev_stat = stat; // Change now to prevent re-entry in safe_delay - if (stat) { // Media Inserted - safe_delay(500); // Some boards need a delay to get settled + #if HAS_MULTI_VOLUME + const int8_t vdiff = (old_real ^ stat), vadd = vdiff & stat; + #endif + const bool did_insert = TERN(HAS_MULTI_VOLUME, vadd, stat) != INSERT_NONE; - // Try to mount the media (only later with SD_IGNORE_AT_STARTUP) - if (TERN1(SD_IGNORE_AT_STARTUP, old_stat != 2)) mount(); - if (!isMounted()) stat = 0; // Not mounted? + if (did_insert) { // Media Inserted + + TERN_(HAS_MULTI_VOLUME, ui.refresh()); // Refresh for insert events without messages + + // Some media is already mounted? Nothing to do. + if (TERN0(HAS_MULTI_VOLUME, isMounted())) return; + + // Prevent re-entry during the following phases + TERN_(HAS_MULTI_VOLUME, no_reenter = true); + + // Try to mount the media (but not at boot if SD_IGNORE_AT_STARTUP) + if (TERN1(SD_IGNORE_AT_STARTUP, old_stat > MEDIA_BOOT)) { + #if HAS_MULTI_VOLUME + if ((vadd & INSERT_SD) && !isSDCardSelected()) + selectMediaSDCard(); + if ((vadd & INSERT_USB) && !isFlashDriveSelected()) + selectMediaFlashDrive(); + #endif + safe_delay(500); // Time for inserted media to settle. May re-enter for multiple media? + mount(); + } + + // If the selected media isn't mounted throw an alert in ui.media_changed + if (!isMounted()) stat = old_real; TERN_(RESET_STEPPERS_ON_MEDIA_INSERT, reset_stepper_drivers()); // Workaround for Cheetah bug + + // Re-enable media detection logic + TERN_(HAS_MULTI_VOLUME, no_reenter = false); + } + else if ( + // Media was removed from the device slot + #if HAS_MULTI_VOLUME + (isSDCardSelected() && (vdiff & INSERT_SD)) + || (isFlashDriveSelected() && (vdiff & INSERT_USB)) + #else + stat // == INSERT_MEDIA + #endif + ) { + flag.workDirIsRoot = true; // Return to root on release + release(); + //TERN_(HAS_MULTI_VOLUME, prev_stat = INSERT_NONE); // HACK to try mounting any remaining media } else { - TERN_(HAS_SD_DETECT, release()); // Card is released + #if HAS_MULTI_VOLUME + stat = old_real; // Ignore un-mounted media being ejected + ui.refresh(); // Refresh for menus that show inserted unmounted media + #endif } - ui.media_changed(old_stat, stat); // Update the UI or flag an error + ui.media_changed(old_stat, stat); // Update the UI or flag an error - if (!stat) return; // Exit if no media is present - - bool do_auto = true; UNUSED(do_auto); + if (stat == INSERT_NONE) return; // Exit if no media is present // First mount on boot? Load emulated EEPROM and look for PLR file. - if (old_stat == 2) { + if (old_stat <= MEDIA_BOOT) { DEBUG_ECHOLNPGM("First mount."); // Load settings the first time media is inserted (not just during init) TERN_(SDCARD_EEPROM_EMULATION, settings.first_load()); - // Check for PLR file. Skip One-Click and auto#.g if found - TERN_(POWER_LOSS_RECOVERY, if (recovery.check()) do_auto = false); + // Check for PLR file. If found skip other procedures! + if (TERN0(POWER_LOSS_RECOVERY, recovery.check())) return; } - // Find the newest file and prompt to print it. - TERN_(ONE_CLICK_PRINT, if (do_auto && one_click_check()) do_auto = false); + // Find the newest file and prompt to print it. Skip other procedures! + if (TERN0(ONE_CLICK_PRINT, one_click_check())) return; - // Also for the first mount run auto#.g for machine init. - // (Skip if PLR or One-Click Print was invoked.) - if (old_stat == 2) { + // On first mount at boot run auto#.g for machine init. + if (old_stat <= MEDIA_BOOT) { // Look for auto0.g on the next idle() - IF_DISABLED(NO_SD_AUTOSTART, if (do_auto) autofile_begin()); + IF_DISABLED(NO_SD_AUTOSTART, autofile_begin()); } } @@ -590,6 +672,8 @@ void CardReader::manage_media() { * Used by M22, "Release Media", manage_media. */ void CardReader::release() { + if (!flag.mounted) return; + // Card removed while printing? Abort! if (isStillPrinting()) abortFilePrintSoon(); diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 1a8843da58..6c1f05b8af 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -78,6 +78,14 @@ typedef struct { ; } card_flags_t; +enum MediaPresence : int8_t { + MEDIA_BOOT = -1, + INSERT_NONE = 0x00, + INSERT_MEDIA = 0x01, + INSERT_SD = TERN(HAS_MULTI_VOLUME, 0x02, 0x00), + INSERT_USB = TERN(HAS_MULTI_VOLUME, 0x04, 0x00) +}; + enum ListingFlags : uint8_t { LS_LONG_FILENAME, LS_ONLY_BIN, LS_TIMESTAMP }; enum SortFlag : int8_t { AS_REV = -1, AS_OFF, AS_FWD, AS_ALSO_REV }; @@ -102,6 +110,9 @@ public: CardReader(); + // Init at startup before mounting media + static void init(); + /** * Media Selection - Only one drive may be active at a time, * so switching drives (currently) returns to the root folder. From 99c29cd9242387176a6be0f70acace28ac27ec03 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Apr 2025 11:20:15 -0500 Subject: [PATCH 40/51] =?UTF-8?q?=F0=9F=9A=B8=20Simplified=20Media=20Menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/password/password.cpp | 2 +- Marlin/src/feature/password/password.h | 2 + Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 8 +- Marlin/src/lcd/language/language_en.h | 9 +- Marlin/src/lcd/marlinui.h | 6 +- Marlin/src/lcd/menu/menu.h | 3 +- Marlin/src/lcd/menu/menu_item.h | 3 + Marlin/src/lcd/menu/menu_main.cpp | 154 +++++++++++++++----- Marlin/src/lcd/menu/menu_media.cpp | 46 +++--- Marlin/src/lcd/menu/menu_password.cpp | 12 +- Marlin/src/lcd/tft/ui_color_ui.cpp | 2 +- 11 files changed, 171 insertions(+), 76 deletions(-) diff --git a/Marlin/src/feature/password/password.cpp b/Marlin/src/feature/password/password.cpp index 1d376cc586..d36b3edd09 100644 --- a/Marlin/src/feature/password/password.cpp +++ b/Marlin/src/feature/password/password.cpp @@ -36,7 +36,7 @@ uint32_t Password::value, Password::value_entry; // // Authenticate user with password. -// Called from Setup, after SD Prinitng Stops/Aborts, and M510 +// Called from Setup, after SD Printing Stops/Aborts, and M510 // void Password::lock_machine() { is_locked = true; diff --git a/Marlin/src/feature/password/password.h b/Marlin/src/feature/password/password.h index 208765b212..0f8bc28bd8 100644 --- a/Marlin/src/feature/password/password.h +++ b/Marlin/src/feature/password/password.h @@ -37,6 +37,8 @@ public: static void access_menu_password(); static void authentication_done(); static void media_gatekeeper(); + static void media_gatekeeper_sd(); + static void media_gatekeeper_usb(); private: static void authenticate_user(const screenFunc_t, const screenFunc_t); diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 4ac012ba93..d772447551 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -175,9 +175,9 @@ void TFTGLCD::clr_screen() { SPI_SEND_ONE(CLR_SCREEN); WRITE(TFTGLCD_CS, HIGH); #else - Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); //set I2C device address + Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); // Transmit to LCD via I2C Wire.write(CLR_SCREEN); - Wire.endTransmission(); //transmit data + Wire.endTransmission(); // Send the data #endif } @@ -378,10 +378,6 @@ void MarlinUI::clear_for_drawing() { clear_lcd(); } void MarlinUI::_set_contrast() { lcd.setContrast(contrast); } #endif -#if !IS_TFTGLCD_PANEL - void lcd_moveto(const uint8_t col, const uint8_t row) { lcd.setCursor(col, row); } -#endif - static void center_text(FSTR_P const fstart, const uint8_t y) { const uint8_t len = utf8_strlen(fstart); lcd_moveto(len < LCD_WIDTH ? (LCD_WIDTH - len) / 2 : 0, y); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 7ea17d5bb3..5ed5b24635 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -574,10 +574,8 @@ namespace LanguageNarrow_en { LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Obj"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Obj {"); LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Job"); - LSTR MSG_MEDIA_MENU = MEDIA_TYPE_EN _UxGT(" Print"); LSTR MSG_TURN_OFF = _UxGT("Turn off now"); LSTR MSG_END_LOOPS = _UxGT("End Loops"); - LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN; LSTR MSG_DWELL = _UxGT("Sleep..."); LSTR MSG_USERWAIT = _UxGT("Click to Resume..."); LSTR MSG_PRINT_PAUSED = _UxGT("Print Paused"); @@ -641,6 +639,10 @@ namespace LanguageNarrow_en { LSTR MSG_RUN_AUTOFILES = _UxGT("Run Autofiles"); LSTR MSG_RUN_AUTOFILES_SD = _UxGT("Run SD Autofiles"); LSTR MSG_RUN_AUTOFILES_USB = _UxGT("Run USB Autofiles"); + LSTR MSG_MEDIA_MENU = MEDIA_TYPE_EN _UxGT(" Print"); + LSTR MSG_MEDIA_MENU_SD = _UxGT("Select from SD"); + LSTR MSG_MEDIA_MENU_USB = _UxGT("Select from USB"); + LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN _UxGT(" Detected"); LSTR MSG_ZPROBE_OUT = _UxGT("Z Probe Past Bed"); LSTR MSG_SKEW_FACTOR = _UxGT("Skew Factor"); @@ -1130,6 +1132,9 @@ namespace LanguageWide_en { LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Object {"); LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Print Job"); LSTR MSG_MEDIA_MENU = _UxGT("Select from ") MEDIA_TYPE_EN; + LSTR MSG_MEDIA_MENU_SD = _UxGT("Select from SD Card"); + LSTR MSG_MEDIA_MENU_USB = _UxGT("Select from USB Drive"); + LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN _UxGT(" Found"); LSTR MSG_TURN_OFF = _UxGT("Turn off the printer"); LSTR MSG_END_LOOPS = _UxGT("End Repeat Loops"); LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("No media inserted."); // ProUI diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 076fc63f2a..a610796ebc 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -255,7 +255,9 @@ public: #endif #if HAS_MEDIA - #define MEDIA_MENU_GATEWAY TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media) + #define MEDIA_MENU_GATEWAY TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_file_selector) + #define MEDIA_MENU_GATEWAY_SD TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper_sd, menu_file_selector_sd) + #define MEDIA_MENU_GATEWAY_USB TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper_usb, menu_file_selector_usb) static void media_changed(const MediaPresence old_stat, const MediaPresence stat); #endif @@ -864,7 +866,7 @@ public: TERN_(REVERSE_SELECT_DIRECTION, encoderDirection = -(ENCODERBASE)); } - #else + #else // !HAS_ENCODER_ACTION static void update_buttons() {} static bool hw_button_pressed() { return false; } diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index b7861655e2..47f5a312eb 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -212,7 +212,8 @@ void menu_move(); #if HAS_MEDIA void menu_file_selector(); - void menu_media(); + void menu_file_selector_sd(); + void menu_file_selector_usb(); #endif //////////////////////////////////////////// diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index af4558cefc..d79956aea7 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -226,6 +226,9 @@ class MenuItem_bool : public MenuEditItemBase { * should be done before the menu loop (START_MENU / START_SCREEN). */ +// CAUTION! When using menu items in a lambda or sub-function always use: +#define INJECT_MENU_ITEMS(FN) { FN; if (ui.screen_changed) return; } + /** * SCREEN_OR_MENU_LOOP generates header code for a screen or menu * diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 7e2d458e41..04bbc41074 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -237,8 +237,8 @@ void menu_configuration(); void menu_main() { const bool busy = printingIsActive(); #if HAS_MEDIA - const bool card_detected = card.isMounted(), - card_open = card_detected && card.isFileOpen(); + const bool card_is_mounted = card.isMounted(), + card_open = card_is_mounted && card.isFileOpen(); #endif START_MENU(); @@ -248,45 +248,123 @@ void menu_main() { #define MEDIA_MENU_AT_TOP #endif - auto media_menus = [&]{ - #if HAS_MEDIA - if (card_detected) { - if (!card_open) { - #if ENABLED(MENU_ADDAUTOSTART) - ACTION_ITEM(MSG_RUN_AUTOFILES, card.autofile_begin); // Run Auto Files - #endif + // Show "Attach" for drives that don't auto-detect media (yet) + //#define ATTACH_WITHOUT_INSERT_SD + #define ATTACH_WITHOUT_INSERT_USB - #if HAS_SD_DETECT - GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21" TERN_(HAS_MULTI_VOLUME, "S"))); // M21 Change Media - #if HAS_MULTI_VOLUME - GCODES_ITEM(MSG_ATTACH_USB, F("M21U")); // M21 Attach USB Media - #endif - #else // - or - - ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media - queue.inject(F("M22")); - #if ENABLED(TFT_COLOR_UI) - // Menu display issue on item removal with multi language selection menu - if (encoderTopLine > 0) encoderTopLine--; - ui.refresh(); - #endif - }); - #endif - SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) - } + // Show all "inserted" drives and mount as-needed + #define SHOW_UNMOUNTED_DRIVES + + /** + * Previously: + * - The "selected" media is mounted? + * - [Run Auto Files] + * - HAS_SD_DETECT: + * - [Change Media] = M21 / M21S + * - HAS_MULTI_VOLUME? + * - [Attach USB Drive] = M21U + * - ELSE: + * - [Release Media] = M22 + * - [Select from Media] (or Password Gateway) > + * + * - The "selected" media is not mounted? + * - HAS_SD_DETECT? + * - [No Media] (does nothing) + * - HAS_MULTI_VOLUME? + * - [Attach SD Card] = M21S + * - [Attach USB Drive] = M21U + * - ELSE: + * - [Attach Media] = M21 + * + * Updated: + * - Something is mounted? + * - [Run SD/USB Autofiles] + * - [Release SD/USB] = M22 + * - [Select from SD/USB] (or Password Gateway) > + * + * - Something is inserted and SHOW_UNMOUNTED_DRIVES? + * - [Select from SD/USB] (or Password Gateway) > + * + * - The "selected" Card is NOT DETECTED? + * - Trust all media detect methods? + * - [No Media] (does nothing) + * - HAS_MULTI_VOLUME? + * - [Attach SD Card] = M21S + * - [Attach USB Drive] = M21U + * - ELSE: + * - [Attach SD Card/USB Drive] = M21 + * + * Ideal: + * - Password Gateway? + * - Use gateway passthroughs for all SD/USB Drive menu items... + * - [Run SD Autofiles] + * - [Run USB Autofiles] + * - [Select from SD Card] (or Password Gateway) > + * - [Select from USB Drive] (or Password Gateway) > + * - [Eject SD Card/USB Drive] + */ + auto media_menu_items = [&]{ + #if HAS_MEDIA + if (card_open) return; + + if (card_is_mounted) { + #if ENABLED(MENU_ADDAUTOSTART) + // [Run AutoFiles] for mounted drive(s) + if (card.isSDCardMounted()) + ACTION_ITEM(MSG_RUN_AUTOFILES_SD, card.autofile_begin); + if (card.isFlashDriveMounted()) + ACTION_ITEM(MSG_RUN_AUTOFILES_USB, card.autofile_begin); + #endif + + #if ENABLED(TFT_COLOR_UI) + // Menu display issue on item removal with multi language selection menu + #define M22_ITEM(T) do{ \ + ACTION_ITEM(T, []{ \ + queue.inject(F("M22")); encoderTopLine -= (encoderTopLine > 0); ui.refresh(); \ + }); \ + }while(0) + #else + #define M22_ITEM(T) GCODES_ITEM(T, F("M22")) + #endif + + // [Release Media] for mounted drive(s) + if (card.isSDCardMounted()) + M22_ITEM(MSG_RELEASE_SD); + if (card.isFlashDriveMounted()) + M22_ITEM(MSG_RELEASE_USB); + + // [Select from SD/USB] (or Password First) + if (card.isSDCardMounted()) + SUBMENU(MSG_MEDIA_MENU_SD, MEDIA_MENU_GATEWAY); + else if (TERN0(SHOW_UNMOUNTED_DRIVES, card.isSDCardInserted())) + SUBMENU(MSG_MEDIA_MENU_SD, MEDIA_MENU_GATEWAY_SD); + if (card.isFlashDriveMounted()) + SUBMENU(MSG_MEDIA_MENU_USB, MEDIA_MENU_GATEWAY); + else if (TERN0(SHOW_UNMOUNTED_DRIVES, card.isFlashDriveInserted())) + SUBMENU(MSG_MEDIA_MENU_USB, MEDIA_MENU_GATEWAY_USB); } else { - #if HAS_SD_DETECT - ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" - #else - #if HAS_MULTI_VOLUME - GCODES_ITEM(MSG_ATTACH_SD, F("M21S")); // M21S Attach SD Card - GCODES_ITEM(MSG_ATTACH_USB, F("M21U")); // M21U Attach USB Media + // NOTE: If the SD Card has no SD_DETECT it will always appear to be "inserted" + const bool att_sd = ENABLED(ATTACH_WITHOUT_INSERT_SD) || card.isSDCardInserted(), + att_usb = ENABLED(ATTACH_WITHOUT_INSERT_USB) || card.isFlashDriveInserted(); + if (!att_sd && !att_usb) { + ACTION_ITEM(MSG_NO_MEDIA, nullptr); // [No Media] + } + else { + #if ALL(HAS_MULTI_VOLUME, SHOW_UNMOUNTED_DRIVES) + // [Select from SD/USB] (or Password First) + if (TERN0(SHOW_UNMOUNTED_DRIVES, card.isSDCardInserted())) + SUBMENU(MSG_MEDIA_MENU_SD, MEDIA_MENU_GATEWAY_SD); + if (TERN0(SHOW_UNMOUNTED_DRIVES, card.isFlashDriveInserted())) + SUBMENU(MSG_MEDIA_MENU_USB, MEDIA_MENU_GATEWAY_USB); #else - GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media + #define M21(T) F("M21" TERN_(HAS_MULTI_VOLUME, T)) + if (att_sd) GCODES_ITEM(MSG_ATTACH_SD, M21("S")); // M21 S - [Attach SD Card] + if (att_usb) GCODES_ITEM(MSG_ATTACH_USB, M21("U")); // M21 U - [Attach USB Drive] #endif - #endif + } } - #endif + #endif // HAS_MEDIA }; if (busy) { @@ -317,7 +395,9 @@ void menu_main() { else { // SD Card / Flash Drive - TERN_(MEDIA_MENU_AT_TOP, media_menus()); + #if ENABLED(MEDIA_MENU_AT_TOP) + INJECT_MENU_ITEMS(media_menu_items()); + #endif if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print); @@ -407,7 +487,7 @@ void menu_main() { // SD Card / Flash Drive #if DISABLED(MEDIA_MENU_AT_TOP) - if (!busy) media_menus(); + if (!busy) INJECT_MENU_ITEMS(media_menu_items()); #endif #if HAS_SERVICE_INTERVALS diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index 8747685fe5..f4c409c4a3 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -101,29 +101,27 @@ class MenuItem_sdfolder : public MenuItem_sdbase { } }; -#if HAS_MULTI_VOLUME - void menu_media_select() { - START_MENU(); - BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN_MENU) : GET_TEXT_F(MSG_BACK)); - #if HAS_SDCARD - ACTION_ITEM(MSG_SD_CARD, []{ card.selectMediaSDCard(); card.mount(); ui.goto_screen(menu_file_selector); }); - #endif - #if HAS_USB_FLASH_DRIVE - ACTION_ITEM(MSG_USB_DISK, []{ card.selectMediaFlashDrive(); card.mount(); ui.goto_screen(menu_file_selector); }); - #endif - END_MENU(); +// Shortcut menu items to go directly to inserted — not necessarily mounted — drives +void menu_file_selector_sd() { + if (!card.isSDCardSelected()) { + card.release(); + card.selectMediaSDCard(); } -#endif - -/** - * "Select From Media" menu item. Depending on single or multiple drives: - * - menu_file_selector - List files on the current media - * - menu_media_select - Select one of the attached drives, then go to the file list - */ -void menu_media() { - ui.goto_screen(TERN(HAS_MULTI_VOLUME, menu_media_select, menu_file_selector)); + if (!card.isSDCardMounted()) card.mount(); + ui.goto_screen(menu_file_selector); } +// Shortcut menu items to go directly to inserted — not necessarily mounted — drives +void menu_file_selector_usb() { + if (!card.isFlashDriveSelected()) { + card.release(); + card.selectMediaFlashDrive(); + } + if (!card.isFlashDriveMounted()) card.mount(); + ui.goto_screen(menu_file_selector); +} + +// Shortcut menu items to go directly to inserted — not necessarily mounted — drives void menu_file_selector() { ui.encoder_direction_menus(); @@ -135,11 +133,9 @@ void menu_file_selector() { #endif START_MENU(); - #if HAS_MULTI_VOLUME - ACTION_ITEM(MSG_BACK, []{ ui.goto_screen(menu_media_select); }); - #else - BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN_MENU) : GET_TEXT_F(MSG_BACK)); - #endif + + BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN_MENU) : GET_TEXT_F(MSG_BACK)); + if (card.flag.workDirIsRoot) { #if !HAS_SD_DETECT ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); }); diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index 33d4231cd5..5e3db846ac 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -140,8 +140,18 @@ void Password::access_menu_password() { #if ENABLED(PASSWORD_ON_SD_PRINT_MENU) void Password::media_gatekeeper() { - authenticate_user(menu_media, menu_main); + authenticate_user(menu_file_selector, menu_main); } + #if HAS_SDCARD + void Password::media_gatekeeper_sd() { + authenticate_user(menu_file_selector_sd, menu_main); + } + #endif + #if HAS_USB_FLASH_DRIVE + void Password::media_gatekeeper_usb() { + authenticate_user(menu_file_selector_usb, menu_main); + } + #endif #endif void Password::start_over() { diff --git a/Marlin/src/lcd/tft/ui_color_ui.cpp b/Marlin/src/lcd/tft/ui_color_ui.cpp index 8186650070..6c90cb6c36 100644 --- a/Marlin/src/lcd/tft/ui_color_ui.cpp +++ b/Marlin/src/lcd/tft/ui_color_ui.cpp @@ -323,7 +323,7 @@ void MarlinUI::draw_status_screen() { if (cm && pa) add_control(SDCARD_ICON_X, SDCARD_ICON_Y, STOP, imgCancel, true, COLOR_CONTROL_CANCEL); else - add_control(SDCARD_ICON_X, SDCARD_ICON_Y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, COLOR_CONTROL_DISABLED); + add_control(SDCARD_ICON_X, SDCARD_ICON_Y, menu_file_selector, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, COLOR_CONTROL_DISABLED); #endif #endif From 85f6090f2046d2c616f333c3d8df538405af8315 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 26 Apr 2025 17:54:54 -0500 Subject: [PATCH 41/51] =?UTF-8?q?=F0=9F=94=A7=20Apply=20DEFAULT=5FVOLUME?= =?UTF-8?q?=20on=20boot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 3 ++- Marlin/src/HAL/STM32/sd/msc_sd.cpp | 1 + Marlin/src/inc/Changes.h | 28 +++++++++++++++++++++++++++ Marlin/src/inc/Conditionals-4-adv.h | 9 +++++---- Marlin/src/inc/SanityCheck.h | 16 ++++++++++++--- Marlin/src/sd/cardreader.cpp | 30 ++++++++++++++--------------- 6 files changed, 64 insertions(+), 23 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b1ad8d9629..a48a337270 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1960,7 +1960,8 @@ #if ENABLED(MULTI_VOLUME) #define VOLUME_SD_ONBOARD #define VOLUME_USB_FLASH_DRIVE - #define DEFAULT_SHARED_VOLUME SV_USB_FLASH_DRIVE + #define DEFAULT_VOLUME SD_ONBOARD // :[ 'SD_ONBOARD', 'USB_FLASH_DRIVE' ] + #define DEFAULT_SHARED_VOLUME USB_FLASH_DRIVE // :[ 'SD_ONBOARD', 'USB_FLASH_DRIVE' ] #endif #endif // HAS_MEDIA diff --git a/Marlin/src/HAL/STM32/sd/msc_sd.cpp b/Marlin/src/HAL/STM32/sd/msc_sd.cpp index f198b3e49a..9bb65aab4a 100644 --- a/Marlin/src/HAL/STM32/sd/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/sd/msc_sd.cpp @@ -48,6 +48,7 @@ class Sd2CardUSBMscHandler : public USBMscHandler { public: DiskIODriver* diskIODriver() { + // TODO: Explore a variable shared volume, or auto share the un-mounted volume(s) #if HAS_MULTI_VOLUME #if SHARED_VOLUME_IS(SD_ONBOARD) return &card.media_driver_sdcard; diff --git a/Marlin/src/inc/Changes.h b/Marlin/src/inc/Changes.h index abd7db8011..839804d920 100644 --- a/Marlin/src/inc/Changes.h +++ b/Marlin/src/inc/Changes.h @@ -799,3 +799,31 @@ #undef _POWERSTEP01 #undef _TMC26X #undef _TMC26X_STANDALONE + +#if ENABLED(MULTI_VOLUME) + // Change to a generic ID without SV_ prefix + #define SV_SD_ONBOARD 201 + #define SV_USB_FLASH_DRIVE 202 + #if DEFAULT_VOLUME_IS(SV_SD_ONBOARD) || SHARED_VOLUME_IS(SV_SD_ONBOARD) + #error "SV_SD_ONBOARD is now SD_ONBOARD." + #elif DEFAULT_VOLUME_IS(SV_USB_FLASH_DRIVE) || SHARED_VOLUME_IS(SV_USB_FLASH_DRIVE) + #error "SV_USB_FLASH_DRIVE is now USB_FLASH_DRIVE." + #endif + // Skip less clear "bad value" errors in inc/SanityCheck.h + #if DEFAULT_VOLUME_IS(SV_SD_ONBOARD) + #undef DEFAULT_VOLUME + #define DEFAULT_VOLUME SD_ONBOARD + #elif DEFAULT_VOLUME_IS(SV_USB_FLASH_DRIVE) + #undef DEFAULT_VOLUME + #define DEFAULT_VOLUME USB_FLASH_DRIVE + #endif + #if SHARED_VOLUME_IS(SV_SD_ONBOARD) + #undef DEFAULT_SHARED_VOLUME + #define DEFAULT_SHARED_VOLUME SD_ONBOARD + #elif SHARED_VOLUME_IS(SV_USB_FLASH_DRIVE) + #undef DEFAULT_SHARED_VOLUME + #define DEFAULT_SHARED_VOLUME USB_FLASH_DRIVE + #endif + #undef SV_SD_ONBOARD + #undef SV_USB_FLASH_DRIVE +#endif diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index a9427c3605..629ee98273 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -1248,11 +1248,12 @@ #if ENABLED(MULTI_VOLUME) #define HAS_MULTI_VOLUME 1 - #define SV_SD_ONBOARD 101 - #define SV_USB_FLASH_DRIVE 102 - #define _VOLUME_ID(N) _CAT(SV_, N) - #define SHARED_VOLUME_IS(N) (DEFAULT_SHARED_VOLUME == _VOLUME_ID(N)) + #define SD_ONBOARD 101 + #define USB_FLASH_DRIVE 102 + #define DEFAULT_VOLUME_IS(N) (DEFAULT_VOLUME == N) + #define SHARED_VOLUME_IS(N) (DEFAULT_SHARED_VOLUME == N) #else + #define DEFAULT_VOLUME_IS(...) 0 #define SHARED_VOLUME_IS(...) 0 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 074cfe0dcb..cff241db72 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -416,10 +416,20 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L /** * SD Card Settings */ -#if ALL(HAS_MEDIA, HAS_SD_DETECT, SD_CONNECTION_TYPICAL, ELB_FULL_GRAPHIC_CONTROLLER, HAS_MARLINUI_MENU) && SD_DETECT_STATE == LOW - #error "SD_DETECT_STATE must be set HIGH for SD on the ELB_FULL_GRAPHIC_CONTROLLER." +#if HAS_MEDIA + #if HAS_MULTI_VOLUME + #if !(DEFAULT_VOLUME_IS(SD_ONBOARD) || DEFAULT_VOLUME_IS(USB_FLASH_DRIVE)) + #error "DEFAULT_VOLUME must be either SD_ONBOARD or USB_FLASH_DRIVE." + #endif + #if !(SHARED_VOLUME_IS(SD_ONBOARD) || SHARED_VOLUME_IS(USB_FLASH_DRIVE)) + #error "DEFAULT_SHARED_VOLUME must be either SD_ONBOARD or USB_FLASH_DRIVE." + #endif + #endif + #if ALL(ELB_FULL_GRAPHIC_CONTROLLER, HAS_MARLINUI_MENU, SD_CONNECTION_TYPICAL, HAS_SD_DETECT) && SD_DETECT_STATE == LOW + #error "SD_DETECT_STATE must be set HIGH for SD on the ELB_FULL_GRAPHIC_CONTROLLER." + #endif + #undef SD_CONNECTION_TYPICAL #endif -#undef SD_CONNECTION_TYPICAL /** * SD File Sorting diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 5502561ea4..b7d6f70f65 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -28,10 +28,6 @@ #if HAS_MEDIA -#if HAS_MULTI_VOLUME && !SHARED_VOLUME_IS(SD_ONBOARD) && !SHARED_VOLUME_IS(USB_FLASH_DRIVE) - #error "DEFAULT_SHARED_VOLUME must be either SV_SD_ONBOARD or SV_USB_FLASH_DRIVE." -#endif - //#define DEBUG_CARDREADER #include "cardreader.h" @@ -144,7 +140,13 @@ int16_t CardReader::nrItems = -1; DiskIODriver_USBFlash CardReader::media_driver_usbFlash; #endif -DiskIODriver* CardReader::driver = nullptr; +DiskIODriver* CardReader::driver = ( + #if HAS_USB_FLASH_DRIVE && !DEFAULT_VOLUME_IS(SD_ONBOARD) + &CardReader::media_driver_usbFlash + #else + &CardReader::media_driver_sdcard + #endif +); MarlinVolume CardReader::volume; MediaFile CardReader::myfile; @@ -158,12 +160,6 @@ MediaFile CardReader::myfile; uint32_t CardReader::filesize, CardReader::sdpos; CardReader::CardReader() { - #if HAS_USB_FLASH_DRIVE && !SHARED_VOLUME_IS(SD_ONBOARD) - selectMediaFlashDrive(); - #else - selectMediaSDCard(); - #endif - #if ENABLED(SDCARD_SORT_ALPHA) sort_count = 0; #if ENABLED(SDSORT_GCODE) @@ -604,11 +600,15 @@ void CardReader::manage_media() { // Try to mount the media (but not at boot if SD_IGNORE_AT_STARTUP) if (TERN1(SD_IGNORE_AT_STARTUP, old_stat > MEDIA_BOOT)) { + // If both SD/FD mount simultaneously prefer the default #if HAS_MULTI_VOLUME - if ((vadd & INSERT_SD) && !isSDCardSelected()) - selectMediaSDCard(); - if ((vadd & INSERT_USB) && !isFlashDriveSelected()) - selectMediaFlashDrive(); + #if HAS_USB_FLASH_DRIVE && !DEFAULT_VOLUME_IS(SD_ONBOARD) + if (vadd & INSERT_USB) selectMediaFlashDrive(); + else if (vadd & INSERT_SD) selectMediaSDCard(); + #else + if (vadd & INSERT_SD) selectMediaSDCard(); + else if (vadd & INSERT_USB) selectMediaFlashDrive(); + #endif #endif safe_delay(500); // Time for inserted media to settle. May re-enter for multiple media? mount(); From 827c03b05648ea994496319d0e00904c587d0c8f Mon Sep 17 00:00:00 2001 From: Norman Chong <8681541+Grenite@users.noreply.github.com> Date: Mon, 28 Apr 2025 23:18:59 -0400 Subject: [PATCH 42/51] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20Ultimain=202=20MOTOR?= =?UTF-8?q?=5FCURRENT=5FPWM=5FRANGE=20(#27705)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/ramps/pins_ULTIMAIN_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h index 4633bfc037..b7b04352d0 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h @@ -85,7 +85,7 @@ #define MOTOR_CURRENT_PWM_E_PIN 46 // Motor current PWM conversion, PWM value = MotorCurrentSetting * 255 / range #ifndef MOTOR_CURRENT_PWM_RANGE - #define MOTOR_CURRENT_PWM_RANGE 2000 + #define MOTOR_CURRENT_PWM_RANGE 2900 #endif #define DEFAULT_PWM_MOTOR_CURRENT {1300, 1300, 1250} From fea70777df6cd61aad0035bd13e89430284b8334 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 29 Apr 2025 06:10:06 +0000 Subject: [PATCH 43/51] [cron] Bump distribution date (2025-04-29) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index d48398ed22..da4a399ef0 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 "2025-04-27" +//#define STRING_DISTRIBUTION_DATE "2025-04-29" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index f3a12580c9..c4282ea03a 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 "2025-04-27" + #define STRING_DISTRIBUTION_DATE "2025-04-29" #endif /** From 585cbbb20316b75f70514b340339601ba37d70ab Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 29 Apr 2025 13:41:53 -0500 Subject: [PATCH 44/51] =?UTF-8?q?=F0=9F=A9=B9=20Minor=20ExtUI/DGUS=20code?= =?UTF-8?q?=20fix/cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp | 6 ++---- Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp | 6 ++---- Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp | 6 ++---- Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp | 6 ++---- Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp | 2 +- Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp | 6 ++---- Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp | 6 ++---- Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp | 6 ++---- Marlin/src/lcd/extui/nextion/nextion_extui.cpp | 6 ++---- 9 files changed, 17 insertions(+), 33 deletions(-) diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp index b983fa3740..83db56ae20 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp @@ -70,13 +70,11 @@ namespace ExtUI { void onUserConfirmRequired(const char * const msg) { chiron.confirmationRequest(msg); } // For fancy LCDs include an icon ID, message, and translated button title - void onUserConfirmRequired(const int icon, const char * const cstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, const char * const cstr, FSTR_P const) { onUserConfirmRequired(cstr); - UNUSED(icon); UNUSED(fBtn); } - void onUserConfirmRequired(const int icon, FSTR_P const fstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, FSTR_P const fstr, FSTR_P const) { onUserConfirmRequired(fstr); - UNUSED(icon); UNUSED(fBtn); } #if ENABLED(ADVANCED_PAUSE_FEATURE) diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp index 7070c22602..d6dc4002b1 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp @@ -58,13 +58,11 @@ namespace ExtUI { void onUserConfirmRequired(const char * const msg) { anycubicTFT.onUserConfirmRequired(msg); } // For fancy LCDs include an icon ID, message, and translated button title - void onUserConfirmRequired(const int icon, const char * const cstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, const char * const cstr, FSTR_P const) { onUserConfirmRequired(cstr); - UNUSED(icon); UNUSED(fBtn); } - void onUserConfirmRequired(const int icon, FSTR_P const fstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, FSTR_P const fstr, FSTR_P const) { onUserConfirmRequired(fstr); - UNUSED(icon); UNUSED(fBtn); } #if ENABLED(ADVANCED_PAUSE_FEATURE) diff --git a/Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp b/Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp index 5fbe813446..8cd6e89ef1 100644 --- a/Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp @@ -70,13 +70,11 @@ namespace ExtUI { void onUserConfirmRequired(const char * const msg) { dgus.confirmationRequest(msg); } // For fancy LCDs include an icon ID, message, and translated button title - void onUserConfirmRequired(const int icon, const char * const cstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, const char * const cstr, FSTR_P const) { onUserConfirmRequired(cstr); - UNUSED(icon); UNUSED(fBtn); } - void onUserConfirmRequired(const int icon, FSTR_P const fstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, FSTR_P const fstr, FSTR_P const) { onUserConfirmRequired(fstr); - UNUSED(icon); UNUSED(fBtn); } #if ENABLED(ADVANCED_PAUSE_FEATURE) diff --git a/Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp b/Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp index 3b3f6db5b2..20012b689f 100644 --- a/Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp @@ -88,13 +88,11 @@ namespace ExtUI { } // For fancy LCDs include an icon ID, message, and translated button title - void onUserConfirmRequired(const int icon, const char * const cstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, const char * const cstr, FSTR_P const) { onUserConfirmRequired(cstr); - UNUSED(icon); UNUSED(fBtn); } - void onUserConfirmRequired(const int icon, FSTR_P const fstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, FSTR_P const fstr, FSTR_P const) { onUserConfirmRequired(fstr); - UNUSED(icon); UNUSED(fBtn); } #if ENABLED(ADVANCED_PAUSE_FEATURE) diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index a0551fa28c..e195654caa 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -503,7 +503,7 @@ void DGUSRxHandler::probe(DGUS_VP &vp, void *data_ptr) { UNUSED(data_ptr); #if ENABLED(MESH_BED_LEVELING) - screen.setStatusMessage(FPSTR(DGUS_MSG_ABL_REQUIRED)); + screen.setStatusMessage(GET_TEXT_F(DGUS_MSG_ABL_REQUIRED)); return; #endif diff --git a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp index 9aeb06dba1..e8ee497297 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp @@ -83,13 +83,11 @@ namespace ExtUI { } // For fancy LCDs include an icon ID, message, and translated button title - void onUserConfirmRequired(const int icon, const char * const cstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, const char * const cstr, FSTR_P const) { onUserConfirmRequired(cstr); - UNUSED(icon); UNUSED(fBtn); } - void onUserConfirmRequired(const int icon, FSTR_P const fstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, FSTR_P const fstr, FSTR_P const) { onUserConfirmRequired(fstr); - UNUSED(icon); UNUSED(fBtn); } #if ENABLED(ADVANCED_PAUSE_FEATURE) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index c26a809037..2f9da20ecc 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -133,13 +133,11 @@ namespace ExtUI { #endif // For fancy LCDs include an icon ID, message, and translated button title - void onUserConfirmRequired(const int icon, const char * const cstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, const char * const cstr, FSTR_P const) { onUserConfirmRequired(cstr); - UNUSED(icon); UNUSED(fBtn); } - void onUserConfirmRequired(const int icon, FSTR_P const fstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, FSTR_P const fstr, FSTR_P const) { onUserConfirmRequired(fstr); - UNUSED(icon); UNUSED(fBtn); } #if ENABLED(ADVANCED_PAUSE_FEATURE) diff --git a/Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp b/Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp index 4a1d49a020..86a19f6089 100644 --- a/Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp +++ b/Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp @@ -233,13 +233,11 @@ void onUserConfirmRequired(const char *const msg) { } // For fancy LCDs include an icon ID, message, and translated button title -void onUserConfirmRequired(const int icon, const char * const cstr, FSTR_P const fBtn) { +void onUserConfirmRequired(const int, const char * const cstr, FSTR_P const) { onUserConfirmRequired(cstr); - UNUSED(icon); UNUSED(fBtn); } -void onUserConfirmRequired(const int icon, FSTR_P const fstr, FSTR_P const fBtn) { +void onUserConfirmRequired(const int, FSTR_P const fstr, FSTR_P const) { onUserConfirmRequired(fstr); - UNUSED(icon); UNUSED(fBtn); } #if ENABLED(ADVANCED_PAUSE_FEATURE) diff --git a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp index 570624afcc..7beecfecbf 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp @@ -56,13 +56,11 @@ namespace ExtUI { void onUserConfirmRequired(const char * const msg) { nextion.confirmationRequest(msg); } // For fancy LCDs include an icon ID, message, and translated button title - void onUserConfirmRequired(const int icon, const char * const cstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, const char * const cstr, FSTR_P const) { onUserConfirmRequired(cstr); - UNUSED(icon); UNUSED(fBtn); } - void onUserConfirmRequired(const int icon, FSTR_P const fstr, FSTR_P const fBtn) { + void onUserConfirmRequired(const int, FSTR_P const fstr, FSTR_P const) { onUserConfirmRequired(fstr); - UNUSED(icon); UNUSED(fBtn); } #if ENABLED(ADVANCED_PAUSE_FEATURE) From e3433ea5996a8e0b3e3c9f9673464d99ac23a812 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 30 Apr 2025 00:30:45 +0000 Subject: [PATCH 45/51] [cron] Bump distribution date (2025-04-30) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index da4a399ef0..31c1157635 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 "2025-04-29" +//#define STRING_DISTRIBUTION_DATE "2025-04-30" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index c4282ea03a..b823785698 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 "2025-04-29" + #define STRING_DISTRIBUTION_DATE "2025-04-30" #endif /** From 1c719fd10de836efa01d71bf0208ecc40f607f3e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 30 Apr 2025 10:21:13 -0500 Subject: [PATCH 46/51] =?UTF-8?q?=F0=9F=8E=A8=20Cosmetic=2004-29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp | 2 +- Marlin/src/lcd/menu/menu_main.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp index 8713bf8909..1989724370 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp @@ -123,7 +123,7 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) { #endif } else if (DIALOG_IS(TYPE_FINISH_PRINT)) { - uiCfg.print_state = IDLE; + uiCfg.print_state = IDLE; clear_cur_ui(); lv_draw_ready_print(); } diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 04bbc41074..401c59f5c0 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -351,11 +351,11 @@ void menu_main() { ACTION_ITEM(MSG_NO_MEDIA, nullptr); // [No Media] } else { - #if ALL(HAS_MULTI_VOLUME, SHOW_UNMOUNTED_DRIVES) + #if ENABLED(SHOW_UNMOUNTED_DRIVES) // [Select from SD/USB] (or Password First) - if (TERN0(SHOW_UNMOUNTED_DRIVES, card.isSDCardInserted())) + if (card.isSDCardInserted()) SUBMENU(MSG_MEDIA_MENU_SD, MEDIA_MENU_GATEWAY_SD); - if (TERN0(SHOW_UNMOUNTED_DRIVES, card.isFlashDriveInserted())) + if (card.isFlashDriveInserted()) SUBMENU(MSG_MEDIA_MENU_USB, MEDIA_MENU_GATEWAY_USB); #else #define M21(T) F("M21" TERN_(HAS_MULTI_VOLUME, T)) From 48cc310c588b8ab52cffdc8f86855a05a4b20122 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Thu, 1 May 2025 07:37:11 +1200 Subject: [PATCH 47/51] =?UTF-8?q?=F0=9F=94=A7=20More=20thorough=20TEMP=5FS?= =?UTF-8?q?ENSOR=5F*=20cleanup=20(#27826)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals-3-etc.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Marlin/src/inc/Conditionals-3-etc.h b/Marlin/src/inc/Conditionals-3-etc.h index e4dcdda58f..2456728554 100644 --- a/Marlin/src/inc/Conditionals-3-etc.h +++ b/Marlin/src/inc/Conditionals-3-etc.h @@ -42,30 +42,32 @@ // Clean up unused temperature sensors and sub-options -#if !TEMP_SENSOR_0 +#define UNUSED_TEMP_SENSOR(N) (!TEMP_SENSOR_##N || N >= HOTENDS) +#if UNUSED_TEMP_SENSOR(0) #undef TEMP_SENSOR_0 #endif -#if !TEMP_SENSOR_1 +#if UNUSED_TEMP_SENSOR(1) #undef TEMP_SENSOR_1 #endif -#if !TEMP_SENSOR_2 +#if UNUSED_TEMP_SENSOR(2) #undef TEMP_SENSOR_2 #endif -#if !TEMP_SENSOR_3 +#if UNUSED_TEMP_SENSOR(3) #undef TEMP_SENSOR_3 #endif -#if !TEMP_SENSOR_4 +#if UNUSED_TEMP_SENSOR(4) #undef TEMP_SENSOR_4 #endif -#if !TEMP_SENSOR_5 +#if UNUSED_TEMP_SENSOR(5) #undef TEMP_SENSOR_5 #endif -#if !TEMP_SENSOR_6 +#if UNUSED_TEMP_SENSOR(6) #undef TEMP_SENSOR_6 #endif -#if !TEMP_SENSOR_7 +#if UNUSED_TEMP_SENSOR(7) #undef TEMP_SENSOR_7 #endif +#undef UNUSED_TEMP_SENSOR #if !TEMP_SENSOR_BED #undef TEMP_SENSOR_BED From 4096beaf527e3dfa27f12cc7cfff6502f94ef2ca Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 1 May 2025 00:34:50 +0000 Subject: [PATCH 48/51] [cron] Bump distribution date (2025-05-01) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 31c1157635..a2ef14eecd 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 "2025-04-30" +//#define STRING_DISTRIBUTION_DATE "2025-05-01" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index b823785698..618bca9810 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 "2025-04-30" + #define STRING_DISTRIBUTION_DATE "2025-05-01" #endif /** From e16885c558e8c03b43f2127780a4ec15ee29dd1e Mon Sep 17 00:00:00 2001 From: staff1010 <132726146+staff1010@users.noreply.github.com> Date: Sat, 3 May 2025 00:13:26 +0800 Subject: [PATCH 49/51] =?UTF-8?q?=F0=9F=9A=B8=20Fix=20MKS=20UI=20G-code=20?= =?UTF-8?q?result=20display=20(#27825)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp | 25 +++++++--- Marlin/src/lcd/extui/mks_ui/draw_gcode.h | 1 + Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp | 2 +- .../src/lcd/extui/mks_ui/draw_move_motor.cpp | 24 +++++---- Marlin/src/lcd/extui/mks_ui/draw_ui.cpp | 8 +++ .../lcd/extui/mks_ui/draw_z_offset_wizard.cpp | 24 +++++---- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 49 +++++++------------ 7 files changed, 70 insertions(+), 63 deletions(-) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp b/Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp index 8a3366e01d..68c5cd22d4 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp @@ -34,6 +34,7 @@ static lv_obj_t *scr, *outL, *outV = 0; static int currentWritePos = 0; extern uint8_t public_buf[513]; extern "C" { extern char public_buf_m[100]; } +extern bool gcode_output_update_flag; enum { ID_GCODE_RETURN = 1, @@ -43,6 +44,8 @@ enum { static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; lv_clear_gcode(); + public_buf[0] = public_buf_m[0] = 0; // Clear output buffer + MYSERIAL1.setHook(); switch (obj->mks_obj_id) { case ID_GCODE_RETURN: lv_draw_more(); @@ -56,20 +59,22 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_show_gcode_output(void * that, const char * txt) { // Ignore echo of command - if (!memcmp(txt, "echo:", 5)) { - public_buf[0] = 0; // Clear output buffer + if (txt[0] == 'e' && txt[4] == ':') { // !memcmp_P(txt, PSTR("echo:"), 5) + public_buf[0] = public_buf_m[0] = 0; // Clear output buffer return; } // Avoid overflow if the answer is too large size_t len = strlen((const char*)public_buf), tlen = strlen(txt); - if (len + tlen + 1 < sizeof(public_buf)) { + if (len + tlen + 2 <= sizeof(public_buf)) { memcpy(public_buf + len, txt, tlen); public_buf[len + tlen] = '\n'; + public_buf[len + tlen + 1] = '\0'; } } void lv_serial_capt_hook(void * userPointer, uint8_t c) { + gcode_output_update_flag = false; if (c == '\n' || currentWritePos == sizeof(public_buf_m) - 1) { // End of line, probably end of command anyway public_buf_m[currentWritePos] = 0; lv_show_gcode_output(userPointer, public_buf_m); @@ -82,17 +87,21 @@ void lv_serial_capt_hook(void * userPointer, uint8_t c) { void lv_eom_hook(void *) { // Message is done, let's remove the hook now MYSERIAL1.setHook(); + // Update message display + gcode_output_update_flag = true; } void lv_draw_gcode(bool clear) { if (clear) { currentWritePos = 0; - public_buf[0] = 0; + public_buf[0] = public_buf_m[0] = 0; + MYSERIAL1.setHook(); + gcode_output_update_flag = false; } scr = lv_screen_create(GCODE_UI, more_menu.gcode); - lv_screen_menu_item(scr, more_menu.entergcode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_GCODE_COMMAND, 1); + lv_screen_menu_item(scr, more_menu.entergcode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_GCODE_COMMAND, 0); outL = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2, "Result:"); - outV = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, (const char*)public_buf); + outV = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 20, (const char*)public_buf); 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_GCODE_RETURN, true); } @@ -105,4 +114,8 @@ void lv_clear_gcode() { outV = 0; } +void disp_gcode_output() { + lv_label_set_text(outV, (const char*)public_buf); +} + #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/mks_ui/draw_gcode.h b/Marlin/src/lcd/extui/mks_ui/draw_gcode.h index df752e7cc9..0cb19fb1ad 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_gcode.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_gcode.h @@ -27,6 +27,7 @@ void lv_draw_gcode(bool clear = false); void lv_clear_gcode(); +void disp_gcode_output(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp b/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp index ec7e549c41..0d049a2f64 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp @@ -160,7 +160,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { goto_previous_ui(); break; case GCodeCommand: - if (ret_ta_txt[0] && !queue.ring_buffer.full(3)) { + if (ret_ta_txt[0]) { // Hook for the next bytes to arrive from the serial port MYSERIAL1.setHook(lv_serial_capt_hook, lv_eom_hook, 0); // Run the command as soon as possible diff --git a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp index 635421b4c3..aa9fbdcd95 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp @@ -59,19 +59,17 @@ void disp_cur_pos() { static void event_handler(lv_obj_t *obj, lv_event_t event) { char str_1[16]; if (event != LV_EVENT_RELEASED) return; - if (!queue.ring_buffer.full(3)) { - bool do_inject = true; - float dist = uiCfg.move_dist; - switch (obj->mks_obj_id) { - case ID_M_X_N: dist *= -1; case ID_M_X_P: cur_label = 'X'; break; - case ID_M_Y_N: dist *= -1; case ID_M_Y_P: cur_label = 'Y'; break; - case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break; - default: do_inject = false; - } - if (do_inject) { - sprintf_P(public_buf_l, PSTR("G91\nG1 %c%s F%d\nG90"), cur_label, dtostrf(dist, 1, 3, str_1), uiCfg.moveSpeed); - queue.inject(public_buf_l); - } + bool do_inject = true; + float dist = uiCfg.move_dist; + switch (obj->mks_obj_id) { + case ID_M_X_N: dist *= -1; case ID_M_X_P: cur_label = 'X'; break; + case ID_M_Y_N: dist *= -1; case ID_M_Y_P: cur_label = 'Y'; break; + case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break; + default: do_inject = false; + } + if (do_inject) { + sprintf_P(public_buf_l, PSTR("G91\nG1 %c%s F%d\nG90"), cur_label, dtostrf(dist, 1, 3, str_1), uiCfg.moveSpeed); + queue.inject(public_buf_l); } switch (obj->mks_obj_id) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 2e66db2c86..4278092472 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -71,6 +71,7 @@ uint32_t size = 809; uint16_t row; bool temps_update_flag; uint8_t printing_rate_update_flag; +bool gcode_output_update_flag; extern bool once_flag; extern uint8_t sel_id; @@ -864,6 +865,13 @@ void GUI_RefreshPage() { } break; + case GCODE_UI: + if (gcode_output_update_flag) { + gcode_output_update_flag = false; + disp_gcode_output(); + } + break; + default: break; } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp index 9d16c9dff2..cdd151322b 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp @@ -73,19 +73,17 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { char str_1[16]; if (event != LV_EVENT_RELEASED) return; //lv_clear_z_offset_wizard(); - if (!queue.ring_buffer.full(3)) { - bool do_inject = true; - float dist = uiCfg.move_dist; - switch (obj->mks_obj_id) { - case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break; - default: do_inject = false; - } - if (do_inject) { - sprintf_P(public_buf_l, PSTR("G91\nG1 %c%s F%d\nG90"), cur_label, dtostrf(dist, 1, 3, str_1), uiCfg.moveSpeed); - queue.inject(public_buf_l); - //calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; - disp_cur_wizard_pos(); - } + bool do_inject = true; + float dist = uiCfg.move_dist; + switch (obj->mks_obj_id) { + case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break; + default: do_inject = false; + } + if (do_inject) { + sprintf_P(public_buf_l, PSTR("G91\nG1 %c%s F%d\nG90"), cur_label, dtostrf(dist, 1, 3, str_1), uiCfg.moveSpeed); + queue.inject(public_buf_l); + //calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; + disp_cur_wizard_pos(); } switch (obj->mks_obj_id) { diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index 1bc1e043d9..e6adbcbc03 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -770,8 +770,9 @@ int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len) { } int send_to_wifi(uint8_t * const buf, const int len) { return package_to_wifi(WIFI_TRANS_INF, buf, len); } +int print_to_wifi(const char * const buf) { return package_to_wifi(WIFI_TRANS_INF, (uint8_t*)buf, strlen(buf)); } -inline void send_ok_to_wifi() { send_to_wifi((uint8_t *)"ok\r\n", strlen("ok\r\n")); } +inline void send_ok_to_wifi() { print_to_wifi("ok\r\n"); } void set_cur_file_sys(int fileType) { gCfgItems.fileSysType = fileType; } @@ -905,7 +906,7 @@ uint8_t exploreDisk(const char * const path, const uint8_t recu_level, const boo } strcat_P(Fstream, PSTR("\r\n")); - send_to_wifi((uint8_t*)Fstream, strlen(Fstream)); + print_to_wifi(Fstream); } return fileCnt; @@ -950,9 +951,9 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { int index = 0; if (spStr == nullptr) { gCfgItems.fileSysType = FILE_SYS_SD; - send_to_wifi((uint8_t *)(STR_BEGIN_FILE_LIST "\r\n"), strlen(STR_BEGIN_FILE_LIST "\r\n")); + print_to_wifi(STR_BEGIN_FILE_LIST "\r\n"); get_file_list("0:/", false); - send_to_wifi((uint8_t *)(STR_END_FILE_LIST "\r\n"), strlen(STR_END_FILE_LIST "\r\n")); + print_to_wifi(STR_END_FILE_LIST "\r\n"); send_ok_to_wifi(); break; } @@ -962,7 +963,7 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { if (gCfgItems.wifi_type == ESP_WIFI) { char * const path = (char *)tempBuf; if (strlen(&mStr[index]) < 80) { - send_to_wifi((uint8_t *)(STR_BEGIN_FILE_LIST "\r\n"), strlen(STR_BEGIN_FILE_LIST "\r\n")); + print_to_wifi(STR_BEGIN_FILE_LIST "\r\n"); if (strncmp(&mStr[index], "1:", 2) == 0) gCfgItems.fileSysType = FILE_SYS_SD; @@ -972,7 +973,7 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { strcpy(path, &mStr[index]); const bool with_longnames = strchr(mStr, 'L') != nullptr; get_file_list(path, with_longnames); - send_to_wifi((uint8_t *)(STR_END_FILE_LIST "\r\n"), strlen(STR_END_FILE_LIST "\r\n")); + print_to_wifi(STR_END_FILE_LIST "\r\n"); } send_ok_to_wifi(); } @@ -1033,9 +1034,9 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { card.openFileRead(cur_name); if (card.isFileOpen()) - send_to_wifi((uint8_t *)"File selected\r\n", strlen("File selected\r\n")); + print_to_wifi("File selected\r\n"); else { - send_to_wifi((uint8_t *)"file.open failed\r\n", strlen("file.open failed\r\n")); + print_to_wifi("file.open failed\r\n"); strcpy_P(list_file.file_name[sel_id], PSTR("notValid")); } send_ok_to_wifi(); @@ -1149,7 +1150,7 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { print_rate = uiCfg.totalSend; ZERO(tempBuf); sprintf_P((char *)tempBuf, PSTR("M27 %d\r\n"), print_rate); - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + print_to_wifi(tempBuf); } break; @@ -1182,7 +1183,7 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { ZERO(tempBuf); sprintf_P((char *)tempBuf, PSTR("Writing to file: %s\r\n"), (char *)file_writer.saveFileName); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + print_to_wifi(tempBuf); wifi_link_state = WIFI_WAIT_TRANS_START; } else { @@ -1246,7 +1247,7 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { ); } - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + print_to_wifi(tempBuf); queue.enqueue_one(F("M105")); break; @@ -1255,7 +1256,7 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { ZERO(tempBuf); sprintf_P((char *)tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + print_to_wifi(tempBuf); } break; @@ -1265,7 +1266,7 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return; sprintf_P((char *)tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + print_to_wifi(tempBuf); } break; @@ -1275,22 +1276,10 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { #define SENDPAUSE "M997 PAUSE\r\n" switch (uiCfg.print_state) { default: break; - case IDLE: - wifi_ret_ack(); - send_to_wifi((uint8_t *)SENDIDLE, strlen(SENDIDLE)); - break; - case WORKING: - wifi_ret_ack(); - send_to_wifi((uint8_t *)SENDPRINTING, strlen(SENDPRINTING)); - break; - case PAUSED: - wifi_ret_ack(); - send_to_wifi((uint8_t *)SENDPAUSE, strlen(SENDPAUSE)); - break; - case REPRINTING: - wifi_ret_ack(); - send_to_wifi((uint8_t *)SENDPAUSE, strlen(SENDPAUSE)); - break; + case IDLE: wifi_ret_ack(); print_to_wifi(SENDIDLE); break; + case WORKING: wifi_ret_ack(); print_to_wifi(SENDPRINTING); break; + case PAUSED: wifi_ret_ack(); print_to_wifi(SENDPAUSE); break; + case REPRINTING: wifi_ret_ack(); print_to_wifi(SENDPAUSE); break; } if (!uiCfg.command_send) get_wifi_list_command_send(); break; @@ -1307,7 +1296,7 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) { ZERO(tempBuf); send_ok_to_wifi(); #define SENDFW "FIRMWARE_NAME:Robin_nano\r\n" - send_to_wifi((uint8_t *)SENDFW, strlen(SENDFW)); + print_to_wifi(SENDFW); break; default: From b74c81d3e426899009a85827d834dbbe74579036 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 2 May 2025 11:58:45 -0500 Subject: [PATCH 50/51] =?UTF-8?q?=F0=9F=94=A7=20Bricolemon=20cleanup,=20up?= =?UTF-8?q?date=20(#27829)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/pins_postprocess.h | 22 ++-- .../src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h | 73 ++++++----- Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h | 123 ++++++++---------- Marlin/src/pins/samd/pins_MINITRONICS20.h | 10 +- 4 files changed, 111 insertions(+), 117 deletions(-) diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index 9e82d854f9..4d2455bd31 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -891,7 +891,7 @@ #endif #define AUTO_ASSIGNED_X2_DIAG 1 #endif -#endif +#endif // HAS_X2_STEPPER #ifndef X2_CS_PIN #define X2_CS_PIN -1 @@ -976,7 +976,7 @@ #endif #define AUTO_ASSIGNED_Y2_DIAG 1 #endif -#endif +#endif // HAS_Y2_STEPPER #ifndef Y2_CS_PIN #define Y2_CS_PIN -1 @@ -1061,7 +1061,7 @@ #endif #define AUTO_ASSIGNED_Z2_DIAG 1 #endif -#endif +#endif // NUM_Z_STEPPERS >= 2 #ifndef Z2_CS_PIN #define Z2_CS_PIN -1 @@ -1146,7 +1146,7 @@ #endif #define AUTO_ASSIGNED_Z3_DIAG 1 #endif -#endif +#endif // NUM_Z_STEPPERS >= 3 #ifndef Z3_CS_PIN #define Z3_CS_PIN -1 @@ -1231,7 +1231,7 @@ #endif #define AUTO_ASSIGNED_Z4_DIAG 1 #endif -#endif +#endif // NUM_Z_STEPPERS >= 4 #ifndef Z4_CS_PIN #define Z4_CS_PIN -1 @@ -1316,7 +1316,7 @@ #endif #define AUTO_ASSIGNED_I_DIAG 1 #endif -#endif +#endif // HAS_I_AXIS #ifndef I_CS_PIN #define I_CS_PIN -1 @@ -1401,7 +1401,7 @@ #endif #define AUTO_ASSIGNED_J_DIAG 1 #endif -#endif +#endif // HAS_J_AXIS #ifndef J_CS_PIN #define J_CS_PIN -1 @@ -1486,7 +1486,7 @@ #endif #define AUTO_ASSIGNED_K_DIAG 1 #endif -#endif +#endif // HAS_K_AXIS #ifndef K_CS_PIN #define K_CS_PIN -1 @@ -1571,7 +1571,7 @@ #endif #define AUTO_ASSIGNED_U_DIAG 1 #endif -#endif +#endif // HAS_U_AXIS #ifndef U_CS_PIN #define U_CS_PIN -1 @@ -1656,7 +1656,7 @@ #endif #define AUTO_ASSIGNED_V_DIAG 1 #endif -#endif +#endif // HAS_V_AXIS #ifndef V_CS_PIN #define V_CS_PIN -1 @@ -1734,7 +1734,7 @@ #endif #define AUTO_ASSIGNED_W_DIAG 1 #endif -#endif +#endif // HAS_W_AXIS #ifndef W_CS_PIN #define W_CS_PIN -1 diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h index 98ec48de80..f79a743c2a 100644 --- a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h @@ -22,13 +22,15 @@ #pragma once /** - * BRICOLEMON LITE Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * Bricolemon Lite Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * https://lemoncrest.com https://bricogeek.com + * * This board its a 3.3V LOGIC Board, following the ADAFRUIT example, all of the board is open source. * Schematic: Refer to the Bricolemon - * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon%20Lite/LC_BG_002_PCB_V1I4.step - * PinDemux: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/PinDEMUX.xlsx + * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon%20Lite/LC_BG_002_PCB_V1I4.step + * PinDemux: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/PinDEMUX.xlsx * - * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 + * NOTE: Requires SERIAL_PORT -1 */ #if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) @@ -36,37 +38,50 @@ #endif #ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "BRICOLEMON LITE V1.0" // Lemoncrest & BricoGeek collaboration. + #define BOARD_INFO_NAME "Bricolemon Lite v1.0" // Lemoncrest & BricoGeek collaboration. #endif -/** - * EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on. - */ -//#define FLASH_EEPROM_EMULATION -#define I2C_EEPROM // EEPROM on I2C-0 -#define MARLIN_EEPROM_SIZE 0x10000U // 64K (CAT24C512) - -// This is another option to emulate an EEPROM, but it's more efficient to not lose the data in the first place. -//#define SDCARD_EEPROM_EMULATION +// +// EEPROM Emulation: Works (with some bugs) already, but the board needs an I2C EEPROM memory soldered on. +// +#if NO_EEPROM_SELECTED + #define I2C_EEPROM // EEPROM on I2C-0 + //#define FLASH_EEPROM_EMULATION + //#define SDCARD_EEPROM_EMULATION + #if ENABLED(I2C_EEPROM) + #define MARLIN_EEPROM_SIZE 0x10000U // 64K (CAT24C512) + #if ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800U // 2K + #else + #define MARLIN_EEPROM_SIZE 0x800U // 2K + #endif + #undef NO_EEPROM_SELECTED +#endif // -// BLTOUCH PIN: This pin is the signal pin for the BLTOUCH sensor. +// Servos // -#define SERVO0_PIN 33 // BLTouch PWM +#define SERVO0_PIN 33 // BL_TOUCH + +// +// TMC StallGuard DIAG pins - Require soldered bridges! +// +#define X_DIAG_PIN 10 // X_STOP +#define Y_DIAG_PIN 11 // Y_STOP +#define Z_DIAG_PIN 12 // Z_STOP +#define E0_DIAG_PIN 32 // E_STOP // // Limit Switches // -#define X_STOP_PIN 10 -#define Y_STOP_PIN 11 -#define Z_STOP_PIN 12 +#define X_STOP_PIN X_DIAG_PIN +#define Y_STOP_PIN Y_DIAG_PIN +#define Z_STOP_PIN Z_DIAG_PIN // -// Z Probe (when not Z_MIN_PIN) +// Filament Runout Sensor // -#ifndef Z_MIN_PROBE_PIN - #define Z_MIN_PROBE_PIN 12 -#endif +#define FIL_RUNOUT_PIN 32 // E_STOP // // Steppers @@ -87,10 +102,6 @@ #define E0_DIR_PIN 25 #define E0_ENABLE_PIN 29 -// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O. -// For example, a switch to detect any kind of behavior, Power supply pin .... etc. -#define FIL_RUNOUT_PIN 32 - // // Temperature Sensors // @@ -579,16 +590,16 @@ // Default TMC slave addresses #ifndef X_SLAVE_ADDRESS - #define X_SLAVE_ADDRESS 0 + #define X_SLAVE_ADDRESS 0 #endif #ifndef Y_SLAVE_ADDRESS - #define Y_SLAVE_ADDRESS 1 + #define Y_SLAVE_ADDRESS 1 #endif #ifndef Z_SLAVE_ADDRESS - #define Z_SLAVE_ADDRESS 2 + #define Z_SLAVE_ADDRESS 2 #endif #ifndef E0_SLAVE_ADDRESS - #define E0_SLAVE_ADDRESS 3 + #define E0_SLAVE_ADDRESS 3 #endif static_assert(X_SLAVE_ADDRESS == 0, "X_SLAVE_ADDRESS must be 0 for BOARD_BRICOLEMON_LITE_V1_0."); static_assert(Y_SLAVE_ADDRESS == 1, "Y_SLAVE_ADDRESS must be 1 for BOARD_BRICOLEMON_LITE_V1_0."); diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h index 37f0b79f6b..8de6ac5b71 100644 --- a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h @@ -22,7 +22,8 @@ #pragma once /** - * BRICOLEMON Board. Based on ATSAMD51 (AGCM4), bootloader and credits by ADAFRUIT. + * Bricolemon Board. Based on ATSAMD51 (AGCM4), bootloader and credits by ADAFRUIT. + * https://lemoncrest.com https://bricogeek.com */ #if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) @@ -30,11 +31,11 @@ #endif #ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "BRICOLEMON V1.0" // Lemoncrest & BricoGeek collaboration. + #define BOARD_INFO_NAME "Bricolemon V1.0" // Lemoncrest & BricoGeek collaboration. #endif /** - * BRICOLEMON Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * Bricolemon Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. * This board its a 3.3V LOGIC Board, following the ADAFRUIT example, all of the board is open source. * Schematic: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/EsquemaBricolemon_REVB.pdf * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/BricolemonREVB.step @@ -43,41 +44,52 @@ * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 */ -/** - * EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on. - */ -//#define FLASH_EEPROM_EMULATION -#define I2C_EEPROM // EEPROM on I2C-0 -#define MARLIN_EEPROM_SIZE 0x10000U // 64K (CAT24C512) - -//This its another option to emulate an EEPROM, but its more efficient to dont loose the data the first One. -//#define SDCARD_EEPROM_EMULATION +// +// EEPROM Emulation: Works (with some bugs) already, but the board needs an I2C EEPROM memory soldered on. +// +#if NO_EEPROM_SELECTED + #define I2C_EEPROM // EEPROM on I2C-0 + //#define FLASH_EEPROM_EMULATION + //#define SDCARD_EEPROM_EMULATION + #if ENABLED(I2C_EEPROM) + #define MARLIN_EEPROM_SIZE 0x10000U // 64K (CAT24C512) + #if ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800U // 2K + #else + #define MARLIN_EEPROM_SIZE 0x800U // 2K + #endif + #undef NO_EEPROM_SELECTED +#endif // -// BLTouch +// Servos // -#define SERVO0_PIN 33 // BLTouch PWM +#define SERVO0_PIN 33 // BL_TOUCH // -// Limit Switches +// TMC StallGuard DIAG pins - Require soldered bridges! // -#define X_STOP_PIN 10 -#define Y_STOP_PIN 11 -#define Z_STOP_PIN 12 - -/** - * NOTE: Useful if extra TMC2209 are to be used as independent axes. - * We need to configure the new digital PIN, for this we could configure on the board the extra pin of this stepper, for example as a MIN_PIN/MAX_PIN. This pin is the D14. - */ -//#define Z2_STOP_PIN 14 -//#define X2_STOP_PIN 14 -//#define Y2_STOP_PIN 14 +#define X_DIAG_PIN 10 // X_STOP +#define Y_DIAG_PIN 11 // Y_STOP +#define Z_DIAG_PIN 12 // Z_STOP +#define E0_DIAG_PIN 48 // E0_STOP +#define E1_DIAG_PIN 14 // E1_STOP // -// Z Probe (when not Z_MIN_PIN) +// Limit Switches // -#ifndef Z_MIN_PROBE_PIN - #define Z_MIN_PROBE_PIN 12 +#define X_STOP_PIN X_DIAG_PIN +#define Y_STOP_PIN Y_DIAG_PIN +#define Z_STOP_PIN Z_DIAG_PIN + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 48 // E0_STOP +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN 14 // E1_STOP #endif // @@ -103,47 +115,18 @@ #define E1_DIR_PIN 46 #define E1_ENABLE_PIN 47 -// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O. -// For example, a switch to detect any kind of behavior, Power supply pin .... etc. -#define FIL_RUNOUT_PIN 32 - -// This board have the option to use an extra TMC2209 stepper, one of the use could be as a second extruder. -#if EXTRUDERS < 2 - // TODO: Corregir aquí que cuando tenemos dos extrusores o lo que sea, utiliza los endstop que le sobran, osea los max, no hay Z2_endstop - #if NUM_Z_STEPPERS > 1 - #define Z2_STOP_PIN 14 - #endif -#else - // If we want to configure the extra stepper as a Extruder, we should have undef all of the extra motors. - #undef X2_DRIVER_TYPE - #undef Y2_DRIVER_TYPE - #undef Z2_DRIVER_TYPE - #undef Z3_DRIVER_TYPE - #undef Z4_DRIVER_TYPE - - // Si tenemos más de un extrusor lo que hacemos es definir el nuevo extrusor así como sus pines - // Acordarse de definir el #define TEMP_SENSOR_1, ya que este contiene el tipo de sonda del extrusor E1 - - #define FIL_RUNOUT2_PIN 14 - -#endif - // -// Extruder / Bed -// - // Temperature Sensors +// #define TEMP_0_PIN 1 - -// You could use one of the ADC for a temp chamber if you don't use the second extruder, for example. -#if TEMP_SENSOR_CHAMBER > 0 - #define TEMP_CHAMBER_PIN 3 -#else - #define TEMP_1_PIN 3 -#endif - +#define TEMP_1_PIN 3 #define TEMP_BED_PIN 2 +// You could use one of the ADC for a chamber if you don't use the second extruder, for example. +#if TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN +#endif + // // Heaters / Fans // @@ -635,19 +618,19 @@ // Default TMC slave addresses #ifndef X_SLAVE_ADDRESS - #define X_SLAVE_ADDRESS 0 + #define X_SLAVE_ADDRESS 0 #endif #ifndef Y_SLAVE_ADDRESS - #define Y_SLAVE_ADDRESS 1 + #define Y_SLAVE_ADDRESS 1 #endif #ifndef Z_SLAVE_ADDRESS - #define Z_SLAVE_ADDRESS 2 + #define Z_SLAVE_ADDRESS 2 #endif #ifndef E0_SLAVE_ADDRESS - #define E0_SLAVE_ADDRESS 3 + #define E0_SLAVE_ADDRESS 3 #endif #ifndef E1_SLAVE_ADDRESS - #define E1_SLAVE_ADDRESS 0 + #define E1_SLAVE_ADDRESS 0 #endif static_assert(X_SLAVE_ADDRESS == 0, "X_SLAVE_ADDRESS must be 0 for BOARD_BRICOLEMON_V1_0."); static_assert(Y_SLAVE_ADDRESS == 1, "Y_SLAVE_ADDRESS must be 1 for BOARD_BRICOLEMON_V1_0."); diff --git a/Marlin/src/pins/samd/pins_MINITRONICS20.h b/Marlin/src/pins/samd/pins_MINITRONICS20.h index 0f61aea713..827cc57d1f 100644 --- a/Marlin/src/pins/samd/pins_MINITRONICS20.h +++ b/Marlin/src/pins/samd/pins_MINITRONICS20.h @@ -519,19 +519,19 @@ // Default TMC slave addresses #ifndef X_SLAVE_ADDRESS - #define X_SLAVE_ADDRESS 0 + #define X_SLAVE_ADDRESS 0 #endif #ifndef Y_SLAVE_ADDRESS - #define Y_SLAVE_ADDRESS 1 + #define Y_SLAVE_ADDRESS 1 #endif #ifndef Z_SLAVE_ADDRESS - #define Z_SLAVE_ADDRESS 2 + #define Z_SLAVE_ADDRESS 2 #endif #ifndef E0_SLAVE_ADDRESS - #define E0_SLAVE_ADDRESS 3 + #define E0_SLAVE_ADDRESS 3 #endif #ifndef E1_SLAVE_ADDRESS - #define E1_SLAVE_ADDRESS 0 + #define E1_SLAVE_ADDRESS 0 #endif static_assert(X_SLAVE_ADDRESS == 0, "X_SLAVE_ADDRESS must be 0 for BOARD_MINITRONICS20."); static_assert(Y_SLAVE_ADDRESS == 1, "Y_SLAVE_ADDRESS must be 1 for BOARD_MINITRONICS20."); From 019915b09750b10dae64a80d59e4fc30265d3b3a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 2 May 2025 18:08:56 +0000 Subject: [PATCH 51/51] [cron] Bump distribution date (2025-05-02) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index a2ef14eecd..58bd8e05ce 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 "2025-05-01" +//#define STRING_DISTRIBUTION_DATE "2025-05-02" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 618bca9810..8d83493ab4 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 "2025-05-01" + #define STRING_DISTRIBUTION_DATE "2025-05-02" #endif /**