diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 720391cf304e..6afced520c00 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1513,7 +1513,7 @@ * * Tune and Adjust * - Probe Offsets can be tuned at runtime with 'M851', LCD menus, babystepping, etc. - * - PROBE_OFFSET_WIZARD (configuration_adv.h) can be used for setting the Z offset. + * - PROBE_OFFSET_WIZARD (Configuration_adv.h) can be used for setting the Z offset. * * Assuming the typical work area orientation: * - Probe to RIGHT of the Nozzle has a Positive X offset diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 31a5fba9e374..206218ac210a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -4228,13 +4228,17 @@ #endif /** - * WiFi Support (Espressif ESP32 WiFi) + * Native ESP32 board with WiFi or add-on ESP32 WiFi-101 module */ -//#define WIFISUPPORT // Marlin embedded WiFi management +//#define WIFISUPPORT // Marlin embedded WiFi management. Not needed for simple WiFi serial port. //#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib) -#if ANY(WIFISUPPORT, ESP3D_WIFISUPPORT) - //#define WEBSUPPORT // Start a webserver (which may include auto-discovery) +/** + * Extras for an ESP32-based motherboard with WIFISUPPORT + * These options don't apply to add-on WiFi modules based on ESP32 WiFi101. + */ +#if ENABLED(WIFISUPPORT) + //#define WEBSUPPORT // Start a webserver (which may include auto-discovery) using SPIFFS //#define OTASUPPORT // Support over-the-air firmware updates //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host diff --git a/Marlin/Version.h b/Marlin/Version.h index e727c1601b7c..c272eeb5d15a 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 "2023-08-05" +//#define STRING_DISTRIBUTION_DATE "2023-08-14" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp b/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp index 025e5a3bb60d..42630a6ce5ca 100644 --- a/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp +++ b/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp @@ -70,7 +70,7 @@ #include "../../shared/HAL_SPI.h" #ifndef LCD_SPI_SPEED - #define LCD_SPI_SPEED SPI_QUARTER_SPEED + #define LCD_SPI_SPEED SPI_HALF_SPEED #endif void u8g_SetPIOutput(u8g_t *u8g, uint8_t pin_index) { @@ -85,7 +85,6 @@ void u8g_SetPILevel(u8g_t *u8g, uint8_t pin_index, uint8_t level) { uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { - static SPISettings lcdSPIConfig; switch (msg) { case U8G_COM_MSG_STOP: @@ -99,7 +98,6 @@ uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val u8g_SetPILevel(u8g, U8G_PI_CS, LOW); spiBegin(); - lcdSPIConfig = SPISettings(900000, MSBFIRST, SPI_MODE0); u8g->pin_list[U8G_PI_A0_STATE] = 0; break; @@ -117,7 +115,7 @@ uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val break; case U8G_COM_MSG_WRITE_BYTE: - SPI.beginTransaction(lcdSPIConfig); + spiBeginTransaction(LCD_SPI_SPEED, MSBFIRST, SPI_MODE0); if (u8g->pin_list[U8G_PI_A0_STATE] == 0) { // command SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2; @@ -132,7 +130,7 @@ uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val break; case U8G_COM_MSG_WRITE_SEQ: - SPI.beginTransaction(lcdSPIConfig); + spiBeginTransaction(LCD_SPI_SPEED, MSBFIRST, SPI_MODE0); if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) { // command SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2; diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp index a40bec9d644d..f03f533a7195 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -33,6 +33,12 @@ #define BLOCK_SIZE 512 #define PRODUCT_ID 0x29 +#ifndef SD_MULTIBLOCK_RETRY_CNT + #define SD_MULTIBLOCK_RETRY_CNT 1 +#elif SD_MULTIBLOCK_RETRY_CNT < 1 + #error "SD_MULTIBLOCK_RETRY_CNT must be greater than or equal to 1." +#endif + class Sd2CardUSBMscHandler : public USBMscHandler { public: DiskIODriver* diskIODriver() { @@ -58,19 +64,29 @@ class Sd2CardUSBMscHandler : public USBMscHandler { // single block if (blkLen == 1) { hal.watchdog_refresh(); - sd2card->writeBlock(blkAddr, pBuf); - return true; + return sd2card->writeBlock(blkAddr, pBuf); } // multi block optimization - sd2card->writeStart(blkAddr, blkLen); - while (blkLen--) { - hal.watchdog_refresh(); - sd2card->writeData(pBuf); - pBuf += BLOCK_SIZE; + bool done = false; + for (uint16_t rcount = SD_MULTIBLOCK_RETRY_CNT; !done && rcount--;) { + uint8_t *cBuf = pBuf; + sd2card->writeStart(blkAddr); + bool okay = true; // Assume success + for (uint32 i = blkLen; i--;) { + hal.watchdog_refresh(); + if (!sd2card->writeData(cBuf)) { // Write. Did it fail? + sd2card->writeStop(); // writeStop for new writeStart + okay = false; // Failed, so retry + break; // Go to while... below + } + cBuf += BLOCK_SIZE; + } + done = okay; // Done if no error occurred } - sd2card->writeStop(); - return true; + + if (done) sd2card->writeStop(); + return done; } bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) { @@ -78,24 +94,32 @@ class Sd2CardUSBMscHandler : public USBMscHandler { // single block if (blkLen == 1) { hal.watchdog_refresh(); - sd2card->readBlock(blkAddr, pBuf); - return true; + return sd2card->readBlock(blkAddr, pBuf); } // multi block optimization - sd2card->readStart(blkAddr); - while (blkLen--) { - hal.watchdog_refresh(); - sd2card->readData(pBuf); - pBuf += BLOCK_SIZE; + bool done = false; + for (uint16_t rcount = SD_MULTIBLOCK_RETRY_CNT; !done && rcount--;) { + uint8_t *cBuf = pBuf; + sd2card->readStart(blkAddr); + bool okay = true; // Assume success + for (uint32 i = blkLen; i--;) { + hal.watchdog_refresh(); + if (!sd2card->readData(cBuf)) { // Read. Did it fail? + sd2card->readStop(); // readStop for new readStart + okay = false; // Failed, so retry + break; // Go to while... below + } + cBuf += BLOCK_SIZE; + } + done = okay; // Done if no error occurred } - sd2card->readStop(); - return true; - } - bool IsReady() { - return diskIODriver()->isReady(); + if (done) sd2card->readStop(); + return done; } + + bool IsReady() { return diskIODriver()->isReady(); } }; Sd2CardUSBMscHandler usbMscHandler; diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index e72607e2a14c..5e404fc85041 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -318,9 +318,9 @@ // #define BOARD_BTT_EBB42_V1_1 4000 // BigTreeTech EBB42 V1.1 (STM32G0B1CB) -#define BOARD_BTT_SKR_MINI_E3_V3_0 4001 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RE) +#define BOARD_BTT_SKR_MINI_E3_V3_0 4001 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B0RE / STM32G0B1RE) #define BOARD_BTT_MANTA_E3_EZ_V1_0 4002 // BigTreeTech Manta E3 EZ V1.0 (STM32G0B1RE) -#define BOARD_BTT_MANTA_M4P_V1_0 4003 // BigTreeTech Manta M4P V1.0 (STM32G0B1RE) +#define BOARD_BTT_MANTA_M4P_V1_0 4003 // BigTreeTech Manta M4P V1.0 (STM32G0B0RE) #define BOARD_BTT_MANTA_M5P_V1_0 4004 // BigTreeTech Manta M5P V1.0 (STM32G0B1RE) #define BOARD_BTT_MANTA_M8P_V1_0 4005 // BigTreeTech Manta M8P V1.0 (STM32G0B1VE) #define BOARD_BTT_MANTA_M8P_V1_1 4006 // BigTreeTech Manta M8P V1.1 (STM32G0B1VE) diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.cpp b/Marlin/src/feature/bedlevel/bdl/bdl.cpp index 14989a07d344..5345bb78c590 100644 --- a/Marlin/src/feature/bedlevel/bdl/bdl.cpp +++ b/Marlin/src/feature/bedlevel/bdl/bdl.cpp @@ -78,8 +78,8 @@ bool BDS_Leveling::check(const uint16_t data, const bool raw_data/*=false*/, con return true; // error } if (raw_data == true) { - if (hicheck && (data & 0x3FF) > 550) - SERIAL_ECHOLNPGM("BD Sensor mounted too high!"); + if (hicheck && (data & 0x3FF) > 400) + SERIAL_ECHOLNPGM("Bad BD Sensor height! Recommended distance 0.5-2.0mm"); else if (!good_data(data)) SERIAL_ECHOLNPGM("Invalid data, please calibrate."); else @@ -109,7 +109,8 @@ void BDS_Leveling::process() { static float zpos = 0.0f; const millis_t ms = millis(); if (ELAPSED(ms, next_check_ms)) { // timed out (or first run) - next_check_ms = ms + (config_state < BDS_IDLE ? 200 : 50); // check at 5Hz or 20Hz + // Check at 1KHz, 5Hz, or 20Hz + next_check_ms = ms + (config_state == BDS_HOMING_Z ? 1 : (config_state < BDS_IDLE ? 200 : 50)); uint16_t tmp = 0; const float cur_z = planner.get_axis_position_mm(Z_AXIS) - pos_zero_offset; @@ -127,16 +128,14 @@ void BDS_Leveling::process() { babystep.set_mm(Z_AXIS, cur_z - z_sensor); DEBUG_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z); } - else { - babystep.set_mm(Z_AXIS, 0); //if (old_cur_z <= cur_z) Z_DIR_WRITE(HIGH); - //stepper.apply_directions(); // TODO: Remove this line as probably not needed - } + else + babystep.set_mm(Z_AXIS, 0); } #endif old_cur_z = cur_z; old_buf_z = current_position.z; - endstops.bdp_state_update(z_sensor <= 0.01f); + endstops.bdp_state_update(z_sensor <= BD_SENSOR_HOME_Z_POSITION); #if HAS_STATUS_MESSAGE static float old_z_sensor = 0; @@ -149,8 +148,10 @@ void BDS_Leveling::process() { } #endif } - else - stepper.apply_directions(); + else if (config_state == BDS_HOMING_Z) { + SERIAL_ECHOLNPGM("Read:", tmp); + kill(F("BDsensor connect Err!")); + } DEBUG_ECHOLNPGM("BD:", tmp & 0x3FF, " Z:", cur_z, "|", current_position.z); if (TERN0(DEBUG_OUT_BD, BD_I2C_SENSOR.BD_Check_OddEven(tmp) == 0)) DEBUG_ECHOLNPGM("CRC error"); @@ -233,11 +234,13 @@ void BDS_Leveling::process() { sprintf_P(tmp_1, PSTR("G1Z%d.%d"), int(zpos), int(zpos * 10) % 10); gcode.process_subcommands_now(tmp_1); SERIAL_ECHO(tmp_1); SERIAL_ECHOLNPGM(", Z:", current_position.z); - for (float tmp_k = 0; abs(zpos - tmp_k) > 0.004f;) { + uint16_t failcount = 300; + for (float tmp_k = 0; abs(zpos - tmp_k) > 0.006f && failcount--;) { tmp_k = planner.get_axis_position_mm(Z_AXIS) - pos_zero_offset; safe_delay(10); + if (!failcount--) break; } - safe_delay(zpos <= 0.4f ? 600 : 100); + safe_delay(600); tmp = uint16_t((zpos + 0.00001f) * 10); BD_I2C_SENSOR.BD_i2c_write(tmp); SERIAL_ECHOLNPGM("w:", tmp, ", Z:", zpos); diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.h b/Marlin/src/feature/bedlevel/bdl/bdl.h index b3037bc1c277..ed91d7081b67 100644 --- a/Marlin/src/feature/bedlevel/bdl/bdl.h +++ b/Marlin/src/feature/bedlevel/bdl/bdl.h @@ -23,6 +23,10 @@ #include +#ifndef BD_SENSOR_HOME_Z_POSITION + #define BD_SENSOR_HOME_Z_POSITION 0.5 +#endif + enum BDS_State : int8_t { BDS_IDLE, BDS_VERSION = -1, diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 6f5187cc9f39..ed4363acbc0a 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -786,14 +786,18 @@ void unified_bed_leveling::shift_mesh_height() { } #endif - best = do_furthest + #ifndef HUGE_VALF + #define HUGE_VALF (10e100F) + #endif + + best = do_furthest // Points with valid data or HUGE_VALF are skipped ? find_furthest_invalid_mesh_point() : find_closest_mesh_point_of_type(INVALID, nearby, true); if (best.pos.x >= 0) { // mesh point found and is reachable by probe TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_POINT_START)); const float measured_z = probe.probe_at_point(best.meshpos(), stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); - z_values[best.pos.x][best.pos.y] = measured_z; + z_values[best.pos.x][best.pos.y] = isnan(measured_z) ? HUGE_VALF : measured_z; // Mark invalid point already probed with HUGE_VALF to omit it in the next loop #if ENABLED(EXTENSIBLE_UI) ExtUI::onMeshUpdate(best.pos, ExtUI::G29_POINT_FINISH); ExtUI::onMeshUpdate(best.pos, measured_z); @@ -803,6 +807,8 @@ void unified_bed_leveling::shift_mesh_height() { } while (best.pos.x >= 0 && --count); + GRID_LOOP(x, y) if (z_values[x][y] == HUGE_VALF) z_values[x][y] = NAN; // Restore NAN for HUGE_VALF marks + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_FINISH)); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 5ecb6af66c58..d6d648c12560 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -748,6 +748,7 @@ G29_TYPE GcodeSuite::G29() { } //if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM_P(axis == Y_AXIS ? PSTR("Y=") : PSTR("X=", pos); + safe_delay(4); abl.measured_z = current_position.z - bdl.read(); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("x_cur ", planner.get_axis_position_mm(X_AXIS), " z ", abl.measured_z); diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 10f5afca2db4..23753e077fdc 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -84,7 +84,7 @@ void ac_setup(const bool reset_bed) { #endif } -void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) { +void ac_cleanup() { TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height)); TERN_(HAS_BED_PROBE, probe.stow()); restore_feedrate_and_scaling(); @@ -97,7 +97,7 @@ void print_signed_float(FSTR_P const prefix, const_float_t f) { } /** - * - Print the delta settings + * - Print the delta settings */ static void print_calibration_settings(const bool end_stops, const bool tower_angles) { SERIAL_ECHOPGM(".Height:", delta_height); @@ -123,7 +123,7 @@ static void print_calibration_settings(const bool end_stops, const bool tower_an } /** - * - Print the probe results + * - Print the probe results */ static void print_calibration_results(const float z_pt[NPP + 1], const bool tower_points, const bool opposite_points) { SERIAL_ECHOPGM(". "); @@ -147,7 +147,7 @@ static void print_calibration_results(const float z_pt[NPP + 1], const bool towe } /** - * - Calculate the standard deviation from the zero plane + * - Calculate the standard deviation from the zero plane */ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool _1p_cal, const bool _4p_cal, const bool _4p_opp) { if (!_0p_cal) { @@ -165,7 +165,7 @@ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool } /** - * - Probe a point + * - Probe a point */ static float calibration_probe(const xy_pos_t &xy, const bool stow, const bool probe_at_offset) { #if HAS_BED_PROBE @@ -177,7 +177,7 @@ static float calibration_probe(const xy_pos_t &xy, const bool stow, const bool p } /** - * - Probe a grid + * - Probe a grid */ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_points, const float dcr, const bool towers_set, const bool stow_after_each, const bool probe_at_offset) { const bool _0p_calibration = probe_points == 0, @@ -501,7 +501,7 @@ void GcodeSuite::G33() { zero_std_dev_old = zero_std_dev; if (!probe_calibration_points(z_at_pt, probe_points, dcr, towers_set, stow_after_each, probe_at_offset)) { SERIAL_ECHOLNPGM("Correct delta settings with M665 and M666"); - return ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index)); + return ac_cleanup(); } zero_std_dev = std_dev_points(z_at_pt, _0p_calibration, _1p_calibration, _4p_calibration, _4p_opposite_points); @@ -678,7 +678,7 @@ void GcodeSuite::G33() { } while (((zero_std_dev < test_precision && iterations < 31) || iterations <= force_iterations) && zero_std_dev > calibration_precision); - ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index)); + ac_cleanup(); TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); #if HAS_DELTA_SENSORLESS_PROBING diff --git a/Marlin/src/gcode/control/M3-M5.cpp b/Marlin/src/gcode/control/M3-M5.cpp index 5d5d44e8bfe8..ec24cf8a6585 100644 --- a/Marlin/src/gcode/control/M3-M5.cpp +++ b/Marlin/src/gcode/control/M3-M5.cpp @@ -32,21 +32,18 @@ * Laser: * M3 - Laser ON/Power (Ramped power) * M4 - Laser ON/Power (Ramped power) - * M5 - Set power output to 0 (leaving inline mode unchanged). * * M3I - Enable continuous inline power to be processed by the planner, with power * calculated and set in the planner blocks, processed inline during stepping. - * Within inline mode M3 S-Values will set the power for the next moves e.g. G1 X10 Y10 powers on with the last S-Value. + * In inline mode M3 S-Values will set the power for the next moves. + * (e.g., G1 X10 Y10 powers on with the last S-Value.) * M3I must be set before using planner-synced M3 inline S-Values (LASER_POWER_SYNC). * * M4I - Set dynamic mode which calculates laser power OCR based on the current feedrate. * - * M5I - Clear inline mode and set power to 0. - * * Spindle: * M3 - Spindle ON (Clockwise) * M4 - Spindle ON (Counter-clockwise) - * M5 - Spindle OFF * * Parameters: * S - Set power. S0 will turn the spindle/laser off. @@ -92,19 +89,15 @@ void GcodeSuite::M3_M4(const bool is_M4) { #endif auto get_s_power = [] { - float u; if (parser.seenval('S')) { const float v = parser.value_float(); - u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v)); + cutter.menuPower = cutter.unitPower = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v)); } else if (cutter.cutter_mode == CUTTER_MODE_STANDARD) - u = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); - - cutter.menuPower = cutter.unitPower = u; + cutter.menuPower = cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); // PWM not implied, power converted to OCR from unit definition and on/off if not PWM. - cutter.power = TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0); - return u; + cutter.power = TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(cutter.unitPower), cutter.unitPower > 0 ? 255 : 0); }; if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { // Laser power in inline mode @@ -138,6 +131,13 @@ void GcodeSuite::M3_M4(const bool is_M4) { /** * M5 - Cutter OFF (when moves are complete) + * + * Laser: + * M5 - Set power output to 0 (leaving inline mode unchanged). + * M5I - Clear inline mode and set power to 0. + * + * Spindle: + * M5 - Spindle OFF */ void GcodeSuite::M5() { planner.synchronize(); diff --git a/Marlin/src/gcode/lcd/M300.cpp b/Marlin/src/gcode/lcd/M300.cpp index 7ee811f0bdce..2658b52a7ce4 100644 --- a/Marlin/src/gcode/lcd/M300.cpp +++ b/Marlin/src/gcode/lcd/M300.cpp @@ -34,8 +34,19 @@ * * S - (Hz) The frequency of the tone. 0 for silence. * P - (ms) The duration of the tone. + * + * With SOUND_MENU_ITEM: + * E<0|1> - Mute or enable sound */ void GcodeSuite::M300() { + + #if ENABLED(SOUND_MENU_ITEM) + if (parser.seen('E')) { + ui.sound_on = parser.value_bool(); + return; + } + #endif + const uint16_t frequency = parser.ushortval('S', 260); uint16_t duration = parser.ushortval('P', 1000); diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 4b56204db570..cfc3b20cd501 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3810,12 +3810,20 @@ static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive." /** * Sanity check WiFi options */ -#if ENABLED(ESP3D_WIFISUPPORT) && DISABLED(ARDUINO_ARCH_ESP32) - #error "ESP3D_WIFISUPPORT requires an ESP32 MOTHERBOARD." -#elif ENABLED(WEBSUPPORT) && NONE(ARDUINO_ARCH_ESP32, WIFISUPPORT) - #error "WEBSUPPORT requires WIFISUPPORT and an ESP32 MOTHERBOARD." -#elif ALL(ESP3D_WIFISUPPORT, WIFISUPPORT) - #error "Enable only one of ESP3D_WIFISUPPORT or WIFISUPPORT." +#if ALL(WIFISUPPORT, ESP3D_WIFISUPPORT) + #error "Enable only one of WIFISUPPORT or ESP3D_WIFISUPPORT." +#elif ENABLED(ESP3D_WIFISUPPORT) && DISABLED(ARDUINO_ARCH_ESP32) + #error "ESP3D_WIFISUPPORT requires an ESP32 motherboard." +#elif ALL(ARDUINO_ARCH_ESP32, WIFISUPPORT) + #if !(defined(WIFI_SSID) && defined(WIFI_PWD)) + #error "ESP32 motherboard with WIFISUPPORT requires WIFI_SSID and WIFI_PWD." + #endif +#elif ENABLED(WIFI_CUSTOM_COMMAND) + #error "WIFI_CUSTOM_COMMAND requires an ESP32 motherboard and WIFISUPPORT." +#elif ENABLED(OTASUPPORT) + #error "OTASUPPORT requires an ESP32 motherboard and WIFISUPPORT." +#elif defined(WIFI_SSID) || defined(WIFI_PWD) + #error "WIFI_SSID and WIFI_PWD only apply to ESP32 motherboard with WIFISUPPORT." #endif /** diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 710c0cdcd7f9..d9518b4ee222 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 "2023-08-05" + #define STRING_DISTRIBUTION_DATE "2023-08-14" #endif /** diff --git a/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h index 28ca26134e16..dc40aba04628 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h @@ -31,12 +31,12 @@ extern u8g_dev_t u8g_dev_st7565_64128n_HAL_2x_hw_spi; class U8GLIB_64128N_2X_HAL : public U8GLIB { public: U8GLIB_64128N_2X_HAL() : U8GLIB() { } - U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } - U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(cs, a0, reset); } - void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { + U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); } - void init(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { + void init(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); } }; @@ -47,12 +47,12 @@ extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi; class U8GLIB_ST7920_128X64_4X_HAL : public U8GLIB { public: U8GLIB_ST7920_128X64_4X_HAL() : U8GLIB() { } - U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, reset); } - U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset = U8G_PIN_NONE) { init(cs, reset); } - void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { + U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, reset); } + U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset=U8G_PIN_NONE) { init(cs, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE } - void init(pin_t cs, pin_t reset = U8G_PIN_NONE) { + void init(pin_t cs, pin_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_hw_spi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE } }; @@ -66,8 +66,8 @@ extern u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi; class U8GLIB_ST7920_128X64_RRD : public U8GLIB { public: U8GLIB_ST7920_128X64_RRD() : U8GLIB() { } - U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, reset); } - void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { + U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_st7920_128x64_rrd_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE } }; @@ -99,8 +99,8 @@ extern u8g_dev_t u8g_dev_tft_320x240_upscale_from_128x64; class U8GLIB_TFT_320X240_UPSCALE_FROM_128X64 : public U8GLIB { public: U8GLIB_TFT_320X240_UPSCALE_FROM_128X64() : U8GLIB() { } - U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) { init(cs, rs, reset); } - void init(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset); } + U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset=U8G_PIN_NONE) { init(cs, rs, reset); } + void init(uint8_t cs, uint8_t rs, uint8_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset); } }; @@ -109,12 +109,12 @@ extern u8g_dev_t u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, u8g_dev_uc1701_mini1286 class U8GLIB_MINI12864_2X_HAL : public U8GLIB { public: U8GLIB_MINI12864_2X_HAL() : U8GLIB() { } - U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } - U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { init(cs, a0, reset); } - void init(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { + U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } + void init(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, sck, mosi, cs, a0, reset); } - void init(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { + void init(uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset); } }; @@ -125,12 +125,12 @@ extern u8g_dev_t u8g_dev_ssd1309_hw_spi; class U8GLIB_SSD1309_128X64_HAL : public U8GLIB { public: U8GLIB_SSD1309_128X64_HAL() : U8GLIB() { } - U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } - U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(cs, a0, reset); } - void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { + U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); } - void init(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { + void init(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); } }; diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index cfba12acff1b..6df641315895 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -41,11 +41,9 @@ #define U8G_COM_HAL_HW_SPI_FN u8g_com_samd51_hw_spi_fn #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd51_st7920_hw_spi_fn - #elif defined(__SAMD21__) uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd21_st7920_hw_spi_fn #elif defined(__STM32F1__) diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.h b/Marlin/src/lcd/dogm/marlinui_DOGM.h index 414508b1294c..d23df6e2a370 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.h +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.h @@ -36,11 +36,15 @@ // RepRapWorld Graphical LCD - #if !HAS_MEDIA && (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN) - #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL + #if HAS_MEDIA + #ifdef __SAMD21__ + #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL + #else + #define U8G_CLASS U8GLIB_ST7920_128X64_4X + #endif #define U8G_PARAM LCD_PINS_RS - #elif HAS_MEDIA && __SAMD21__ - #define U8G_CLASS U8GLIB_ST7920_128X64_4X + #elif (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN) + #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL #define U8G_PARAM LCD_PINS_RS #else #define U8G_CLASS U8GLIB_ST7920_128X64_4X @@ -61,7 +65,7 @@ #else #define U8G_CLASS U8GLIB_ST7920_128X64_RRD // Adjust stripes with PAGE_HEIGHT in ultralcd_st7920_u8glib_rrd.h #endif - #define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS // AVR version ignores these pin settings + #define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS // AVR version ignores these pin settings // HAL version uses these pin settings #endif diff --git a/Marlin/src/lcd/dogm/status/chamber.h b/Marlin/src/lcd/dogm/status/chamber.h index 787a90884ae8..9b8cc7a0a063 100644 --- a/Marlin/src/lcd/dogm/status/chamber.h +++ b/Marlin/src/lcd/dogm/status/chamber.h @@ -41,32 +41,32 @@ #ifdef STATUS_CHAMBER_ANIM const unsigned char status_chamber_bmp[] PROGMEM = { - B00011111,B11111111,B11111000, - B00010000,B00000000,B00001000, - B00010000,B00000000,B00001000, - B00010000,B00000000,B00001000, - B00010000,B00000000,B00001000, - B00010000,B00000000,B00001000, - B00010000,B00000000,B00001000, - B00010000,B00000000,B00001000, - B00010000,B00000000,B00001000, - B00010000,B00000000,B00001000, - B00011111,B11111111,B11111000, - B00011111,B11111111,B11111000 + B00001111,B11111111,B11111000, + B00001000,B00000000,B00001000, + B00001000,B00000000,B00001000, + B00001000,B00000000,B00001000, + B00001000,B00000000,B00001000, + B00001000,B00000000,B00001000, + B00001000,B00000000,B00001000, + B00001000,B00000000,B00001000, + B00001000,B00000000,B00001000, + B00001000,B00000000,B00001000, + B00001111,B11111111,B11111000, + B00001111,B11111111,B11111000 }; const unsigned char status_chamber_on_bmp[] PROGMEM = { - B00011111,B11111111,B11111000, - B00010000,B00000000,B00001000, - B00010000,B10000100,B00001000, - B00010000,B01000010,B00001000, - B00010000,B01000010,B00001000, - B00010000,B10000100,B00001000, - B00010001,B00001000,B00001000, - B00010001,B00001000,B00001000, - B00010000,B10000100,B00001000, - B00010000,B00000000,B00001000, - B00011111,B11111111,B11111000, - B00011111,B11111111,B11111000 + B00001111,B11111111,B11111000, + B00001000,B00000000,B00001000, + B00001000,B10000100,B00001000, + B00001000,B01000010,B00001000, + B00001000,B01000010,B00001000, + B00001000,B10000100,B00001000, + B00001001,B00001000,B00001000, + B00001001,B00001000,B00001000, + B00001000,B10000100,B00001000, + B00001000,B00000000,B00001000, + B00001111,B11111111,B11111000, + B00001111,B11111111,B11111000 }; #else diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index ebfb10c8c040..27e5b38bd0a3 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -422,7 +422,7 @@ void MarlinUI::draw_status_message(const bool blink) { const dwin_coord_t by = (row * MENU_LINE_HEIGHT) + MENU_FONT_HEIGHT + EXTRA_ROW_HEIGHT / 2; dwinDrawString(true, font16x32, COLOR_YELLOW, COLOR_BG_BLACK, (LCD_PIXEL_WIDTH - vallen * 16) / 2, by, S(dwin_string.string())); - if (ui.can_show_slider()) { + if (ui.can_show_slider() && maxEditValue > 0) { const dwin_coord_t slider_length = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_LANDSCAPE, 120, 20), slider_height = 16, diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index ea86812d0eb7..9fdc33e5f202 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -824,6 +824,8 @@ namespace LanguageNarrow_en { LSTR MSG_FTM_MASS_BASED = _UxGT("Mass-based"); LSTR MSG_FTM_BASE_FREQ_N = _UxGT("@ Base Freq."); LSTR MSG_FTM_DFREQ_K_N = _UxGT("@ Dyn. Freq."); + LSTR MSG_FTM_ZETA = _UxGT("Damping"); + LSTR MSG_FTM_VTOL = _UxGT("Vib. Level"); LSTR MSG_LEVEL_X_AXIS = _UxGT("Level X Axis"); LSTR MSG_AUTO_CALIBRATE = _UxGT("Auto Calibrate"); diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index beb9342fb9b8..981c51a6b056 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -139,8 +139,8 @@ void _lcd_level_bed_moving() { if (ui.should_draw()) { MString<9> msg; - msg.setf(F("%i / %u"), int(manual_probe_index + 1), total_probe_points); - MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT), &msg); + msg.setf(F(" %i / %u"), int(manual_probe_index + 1), total_probe_points); + MenuItem_static::draw(LCD_HEIGHT / 2, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT), SS_CENTER, msg); } ui.refresh(LCDVIEW_CALL_NO_REDRAW); if (!ui.wait_for_move) ui.goto_screen(_lcd_level_bed_get_z); diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 67fcbdd8511e..ae6e87af6585 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -318,10 +318,9 @@ void menu_move() { #include "../../module/ft_motion.h" #include "../../gcode/gcode.h" - void _M493_S(const ftMotionMode_t s) { - char cmd[10]; - sprintf_P(cmd, PSTR("M493S%i"), int(s)); - gcode.process_subcommands_now(cmd); + void ftm_menu_setShaping(const ftMotionMode_t s) { + fxdTiCtrl.cfg.mode = s; + fxdTiCtrl.refreshShapingN(); ui.go_back(); } @@ -331,17 +330,17 @@ void menu_move() { START_MENU(); BACK_ITEM(MSG_FIXED_TIME_MOTION); - if (mode != ftMotionMode_DISABLED) ACTION_ITEM(MSG_LCD_OFF, []{ _M493_S(ftMotionMode_DISABLED); }); - if (mode != ftMotionMode_ENABLED) ACTION_ITEM(MSG_LCD_ON, []{ _M493_S(ftMotionMode_ENABLED); }); + if (mode != ftMotionMode_DISABLED) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_setShaping(ftMotionMode_DISABLED); }); + if (mode != ftMotionMode_ENABLED) ACTION_ITEM(MSG_LCD_ON, []{ ftm_menu_setShaping(ftMotionMode_ENABLED); }); #if HAS_X_AXIS - if (mode != ftMotionMode_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ _M493_S(ftMotionMode_ZV); }); - if (mode != ftMotionMode_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ _M493_S(ftMotionMode_ZVD); }); - if (mode != ftMotionMode_EI) ACTION_ITEM(MSG_FTM_EI, []{ _M493_S(ftMotionMode_EI); }); - if (mode != ftMotionMode_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ _M493_S(ftMotionMode_2HEI); }); - if (mode != ftMotionMode_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ _M493_S(ftMotionMode_3HEI); }); - if (mode != ftMotionMode_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ _M493_S(ftMotionMode_MZV); }); - //if (mode != ftMotionMode_ULENDO_FBS) ACTION_ITEM(MSG_FTM_ULENDO_FBS, []{ _M493_S(ftMotionMode_ULENDO_FBS); }); - //if (mode != ftMotionMode_DISCTF) ACTION_ITEM(MSG_FTM_DISCTF, []{ _M493_S(ftMotionMode_DISCTF); }); + if (mode != ftMotionMode_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_setShaping(ftMotionMode_ZV); }); + if (mode != ftMotionMode_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_setShaping(ftMotionMode_ZVD); }); + if (mode != ftMotionMode_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_setShaping(ftMotionMode_EI); }); + if (mode != ftMotionMode_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_setShaping(ftMotionMode_2HEI); }); + if (mode != ftMotionMode_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_setShaping(ftMotionMode_3HEI); }); + if (mode != ftMotionMode_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_setShaping(ftMotionMode_MZV); }); + //if (mode != ftMotionMode_ULENDO_FBS) ACTION_ITEM(MSG_FTM_ULENDO_FBS, []{ ftm_menu_setShaping(ftMotionMode_ULENDO_FBS); }); + //if (mode != ftMotionMode_DISCTF) ACTION_ITEM(MSG_FTM_DISCTF, []{ ftm_menu_setShaping(ftMotionMode_DISCTF); }); #endif END_MENU(); @@ -349,25 +348,18 @@ void menu_move() { #if HAS_DYNAMIC_FREQ - void _M493_D(const dynFreqMode_t d) { - char cmd[10]; - sprintf_P(cmd, PSTR("M493D%i"), int(d)); - gcode.process_subcommands_now(cmd); - ui.go_back(); - } - inline void menu_ftm_dyn_mode() { const dynFreqMode_t dmode = fxdTiCtrl.cfg.dynFreqMode; START_MENU(); BACK_ITEM(MSG_FIXED_TIME_MOTION); - if (dmode != dynFreqMode_DISABLED) ACTION_ITEM(MSG_LCD_OFF, []{ _M493_D(dynFreqMode_DISABLED); }); + if (dmode != dynFreqMode_DISABLED) ACTION_ITEM(MSG_LCD_OFF, []{ fxdTiCtrl.cfg.dynFreqMode = dynFreqMode_DISABLED; ui.go_back(); }); #if HAS_DYNAMIC_FREQ_MM - if (dmode != dynFreqMode_Z_BASED) ACTION_ITEM(MSG_FTM_Z_BASED, []{ _M493_D(dynFreqMode_Z_BASED); }); + if (dmode != dynFreqMode_Z_BASED) ACTION_ITEM(MSG_FTM_Z_BASED, []{ fxdTiCtrl.cfg.dynFreqMode = dynFreqMode_Z_BASED; ui.go_back(); }); #endif #if HAS_DYNAMIC_FREQ_G - if (dmode != dynFreqMode_MASS_BASED) ACTION_ITEM(MSG_FTM_MASS_BASED, []{ _M493_D(dynFreqMode_MASS_BASED); }); + if (dmode != dynFreqMode_MASS_BASED) ACTION_ITEM(MSG_FTM_MASS_BASED, []{ fxdTiCtrl.cfg.dynFreqMode = dynFreqMode_MASS_BASED; ui.go_back(); }); #endif END_MENU(); @@ -409,25 +401,33 @@ void menu_move() { SUBMENU(MSG_FTM_MODE, menu_ftm_mode); MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(ftmode); MENU_ITEM_ADDON_END(); - #if HAS_X_AXIS - EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_FTM_BASE_FREQ_N, &c.baseFreq[X_AXIS], FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2, fxdTiCtrl.refreshShapingN); - #endif - #if HAS_Y_AXIS - EDIT_ITEM_FAST_N(float42_52, Y_AXIS, MSG_FTM_BASE_FREQ_N, &c.baseFreq[Y_AXIS], FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2, fxdTiCtrl.refreshShapingN); - #endif + if (c.modeHasShaper()) { + #if HAS_X_AXIS + EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_FTM_BASE_FREQ_N, &c.baseFreq[X_AXIS], FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2, fxdTiCtrl.refreshShapingN); + #endif + #if HAS_Y_AXIS + EDIT_ITEM_FAST_N(float42_52, Y_AXIS, MSG_FTM_BASE_FREQ_N, &c.baseFreq[Y_AXIS], FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2, fxdTiCtrl.refreshShapingN); + #endif - #if HAS_DYNAMIC_FREQ - if (c.modeHasShaper()) { + EDIT_ITEM_FAST(float42_52, MSG_FTM_ZETA, &c.zeta, 0.0f, 1.0f, fxdTiCtrl.refreshShapingN); + + if (WITHIN(c.mode, ftMotionMode_EI, ftMotionMode_3HEI)) + EDIT_ITEM_FAST(float42_52, MSG_FTM_VTOL, &c.vtol, 0.0f, 1.0f, fxdTiCtrl.refreshShapingN); + + #if HAS_DYNAMIC_FREQ SUBMENU(MSG_FTM_DYN_MODE, menu_ftm_dyn_mode); MENU_ITEM_ADDON_START_RJ(11); lcd_put_u8str(dmode); MENU_ITEM_ADDON_END(); - #if HAS_X_AXIS - EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_FTM_DFREQ_K_N, &c.dynFreqK[X_AXIS], 0.0f, 20.0f); - #endif - #if HAS_Y_AXIS - EDIT_ITEM_FAST_N(float42_52, Y_AXIS, MSG_FTM_DFREQ_K_N, &c.dynFreqK[Y_AXIS], 0.0f, 20.0f); - #endif - } - #endif + if (c.dynFreqMode != dynFreqMode_DISABLED) { + #if HAS_X_AXIS + EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_FTM_DFREQ_K_N, &c.dynFreqK[X_AXIS], 0.0f, 20.0f); + #endif + #if HAS_Y_AXIS + EDIT_ITEM_FAST_N(float42_52, Y_AXIS, MSG_FTM_DFREQ_K_N, &c.dynFreqK[Y_AXIS], 0.0f, 20.0f); + #endif + } + #endif + } + #if HAS_EXTRUDERS EDIT_ITEM(bool, MSG_LINEAR_ADVANCE, &c.linearAdvEna); EDIT_ITEM(float42_52, MSG_ADVANCE_K, &c.linearAdvK, 0, 10); diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp index 6162a5e30d3b..f5ceec8f12f1 100644 --- a/Marlin/src/lcd/menu/menu_x_twist.cpp +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -113,8 +113,8 @@ void xatc_wizard_menu() { void xatc_wizard_moving() { if (ui.should_draw()) { MString<9> msg; - msg.setf(F("%i / %u"), manual_probe_index + 1, XATC_MAX_POINTS); - MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT), &msg); + msg.setf(F(" %i / %u"), manual_probe_index + 1, XATC_MAX_POINTS); + MenuItem_static::draw(LCD_HEIGHT / 2, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT), SS_CENTER, msg); } ui.refresh(LCDVIEW_CALL_NO_REDRAW); if (!ui.wait_for_move) ui.goto_screen(xatc_wizard_menu); diff --git a/Marlin/src/lcd/tft/ui_color_ui.cpp b/Marlin/src/lcd/tft/ui_color_ui.cpp index 85d310ca42ea..cefbd05d1953 100644 --- a/Marlin/src/lcd/tft/ui_color_ui.cpp +++ b/Marlin/src/lcd/tft/ui_color_ui.cpp @@ -429,7 +429,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va } #endif - if (ui.can_show_slider()) { + if (ui.can_show_slider() && maxEditValue > 0) { tft.canvas((TFT_WIDTH - SLIDER_W) / 2, SLIDER_Y, SLIDER_W, 16); tft.set_background(COLOR_BACKGROUND); diff --git a/Marlin/src/module/ft_motion.cpp b/Marlin/src/module/ft_motion.cpp index 6fe8e936e0e5..385d81622e8c 100644 --- a/Marlin/src/module/ft_motion.cpp +++ b/Marlin/src/module/ft_motion.cpp @@ -276,7 +276,7 @@ void FxdTiCtrl::loop() { // Refresh the gains used by shaping functions. // To be called on init or mode or zeta change. - void FxdTiCtrl::Shaping::updateShapingA(const_float_t zeta/*=FTM_SHAPING_ZETA*/, const_float_t vtol/*=FTM_SHAPING_V_TOL*/) { + void FxdTiCtrl::Shaping::updateShapingA(const_float_t zeta/*=cfg.zeta*/, const_float_t vtol/*=cfg.vtol*/) { const float K = exp(-zeta * M_PI / sqrt(1.0f - sq(zeta))), K2 = sq(K); @@ -345,7 +345,7 @@ void FxdTiCtrl::loop() { #endif } - void FxdTiCtrl::updateShapingA(const_float_t zeta/*=FTM_SHAPING_ZETA*/, const_float_t vtol/*=FTM_SHAPING_V_TOL*/) { + void FxdTiCtrl::updateShapingA(const_float_t zeta/*=cfg.zeta*/, const_float_t vtol/*=cfg.vtol*/) { shaping.updateShapingA(zeta, vtol); } @@ -382,7 +382,7 @@ void FxdTiCtrl::loop() { } } - void FxdTiCtrl::updateShapingN(const_float_t xf OPTARG(HAS_Y_AXIS, const_float_t yf), const_float_t zeta/*=FTM_SHAPING_ZETA*/) { + void FxdTiCtrl::updateShapingN(const_float_t xf OPTARG(HAS_Y_AXIS, const_float_t yf), const_float_t zeta/*=cfg.zeta*/) { const float df = sqrt(1.0f - sq(zeta)); shaping.x.updateShapingN(xf, df); TERN_(HAS_Y_AXIS, shaping.y.updateShapingN(yf, df)); diff --git a/Marlin/src/module/ft_motion.h b/Marlin/src/module/ft_motion.h index 2186ecb710a8..d607ac103038 100644 --- a/Marlin/src/module/ft_motion.h +++ b/Marlin/src/module/ft_motion.h @@ -48,6 +48,9 @@ typedef struct FTConfig { { FTM_SHAPING_DEFAULT_X_FREQ OPTARG(HAS_Y_AXIS, FTM_SHAPING_DEFAULT_Y_FREQ) }; #endif + float zeta = FTM_SHAPING_ZETA; // Damping factor + float vtol = FTM_SHAPING_V_TOL; // Vibration Level + #if HAS_DYNAMIC_FREQ dynFreqMode_t dynFreqMode = FTM_DEFAULT_DYNFREQ_MODE; // Dynamic frequency mode configuration. float dynFreqK[1 + ENABLED(HAS_Y_AXIS)] = { 0.0f }; // Scaling / gain for dynamic frequency. [Hz/mm] or [Hz/g] @@ -74,6 +77,9 @@ class FxdTiCtrl { TERN_(HAS_X_AXIS, cfg.baseFreq[X_AXIS] = FTM_SHAPING_DEFAULT_X_FREQ); TERN_(HAS_Y_AXIS, cfg.baseFreq[Y_AXIS] = FTM_SHAPING_DEFAULT_Y_FREQ); + cfg.zeta = FTM_SHAPING_ZETA; + cfg.vtol = FTM_SHAPING_V_TOL; + #if HAS_DYNAMIC_FREQ cfg.dynFreqMode = FTM_DEFAULT_DYNFREQ_MODE; cfg.dynFreqK[X_AXIS] = TERN_(HAS_Y_AXIS, cfg.dynFreqK[Y_AXIS]) = 0.0f; @@ -112,11 +118,11 @@ class FxdTiCtrl { #if HAS_X_AXIS // Refresh the gains used by shaping functions. // To be called on init or mode or zeta change. - static void updateShapingA(const_float_t zeta=FTM_SHAPING_ZETA, const_float_t vtol=FTM_SHAPING_V_TOL); + static void updateShapingA(const_float_t zeta=cfg.zeta, const_float_t vtol=cfg.vtol); // Refresh the indices used by shaping functions. // To be called when frequencies change. - static void updateShapingN(const_float_t xf OPTARG(HAS_Y_AXIS, const_float_t yf), const_float_t zeta=FTM_SHAPING_ZETA); + static void updateShapingN(const_float_t xf OPTARG(HAS_Y_AXIS, const_float_t yf), const_float_t zeta=cfg.zeta); static void refreshShapingN() { updateShapingN(cfg.baseFreq[X_AXIS] OPTARG(HAS_Y_AXIS, cfg.baseFreq[Y_AXIS])); } @@ -181,7 +187,7 @@ class FxdTiCtrl { axis_shaping_t y; #endif - void updateShapingA(const_float_t zeta=FTM_SHAPING_ZETA, const_float_t vtol=FTM_SHAPING_V_TOL); + void updateShapingA(const_float_t zeta=cfg.zeta, const_float_t vtol=cfg.vtol); } shaping_t; diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 80729df759da..272b16c9ac0f 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -2479,7 +2479,12 @@ void set_axis_is_at_home(const AxisEnum axis) { #if HAS_BED_PROBE && Z_HOME_TO_MIN if (axis == Z_AXIS) { #if HOMING_Z_WITH_PROBE - current_position.z -= probe.offset.z; + #if ENABLED(BD_SENSOR) + safe_delay(100); + current_position.z = bdl.read(); + #else + current_position.z -= probe.offset.z; + #endif if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z homed with PROBE" TERN_(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, " (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)") " ***\n> (M851 Z", probe.offset.z, ")"); #else if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z homed to ENDSTOP ***"); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 68fcfd00e0a2..989965d6d884 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -980,6 +980,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai #if ENABLED(BD_SENSOR) + safe_delay(4); return current_position.z - bdl.read(); // Difference between Z-home-relative Z and sensor reading #else // !BD_SENSOR diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index c7e35c575457..6139ebe12004 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3080,7 +3080,9 @@ void Temperature::init() { #if HAS_THERMAL_PROTECTION #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + #if __has_cpp_attribute(fallthrough) + #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + #endif Temperature::tr_state_machine_t Temperature::tr_state_machine[NR_HEATER_RUNAWAY]; // = { { TRInactive, 0 } }; @@ -3978,7 +3980,9 @@ void Temperature::isr() { switch (adc_sensor_state) { #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + #if __has_cpp_attribute(fallthrough) + #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + #endif case SensorsReady: { // All sensors have been read. Stay in this state for a few diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index b823f480d732..fe356520d8f7 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -739,11 +739,11 @@ #elif MB(BTT_SKR_V2_0_REV_B) #include "stm32f4/pins_BTT_SKR_V2_0_REV_B.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB env:BIGTREE_SKR_2_USB_debug env:BIGTREE_SKR_2_F429 env:BIGTREE_SKR_2_F429_USB env:BIGTREE_SKR_2_F429_USB_debug #elif MB(BTT_OCTOPUS_V1_0) - #include "stm32f4/pins_BTT_OCTOPUS_V1_0.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_USB + #include "stm32f4/pins_BTT_OCTOPUS_V1_0.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_usb_flash_drive #elif MB(BTT_OCTOPUS_V1_1) - #include "stm32f4/pins_BTT_OCTOPUS_V1_1.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_USB env:STM32F429ZG_btt env:STM32F429ZG_btt_USB env:STM32F407ZE_btt env:STM32F407ZE_btt_USB + #include "stm32f4/pins_BTT_OCTOPUS_V1_1.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_usb_flash_drive env:STM32F429ZG_btt env:STM32F429ZG_btt_usb_flash_drive env:STM32F407ZE_btt env:STM32F407ZE_btt_usb_flash_drive #elif MB(BTT_OCTOPUS_PRO_V1_0) - #include "stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_USB env:STM32F429ZG_btt env:STM32F429ZG_btt_USB env:STM32H723ZE_btt + #include "stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_usb_flash_drive env:STM32F429ZG_btt env:STM32F429ZG_btt_usb_flash_drive env:STM32H723ZE_btt #elif MB(LERDGE_K) #include "stm32f4/pins_LERDGE_K.h" // STM32F4 env:LERDGEK env:LERDGEK_usb_flash_drive #elif MB(LERDGE_S) diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index 7deebd4776a2..25fc35e6ab93 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -40,6 +40,37 @@ #include "../MarlinCore.h" +#if DISABLED(SD_NO_DEFAULT_TIMEOUT) + #ifndef SD_INIT_TIMEOUT + #define SD_INIT_TIMEOUT 2000u // (ms) Init timeout + #elif SD_INIT_TIMEOUT < 0 + #error "SD_INIT_TIMEOUT must be greater than or equal to 0." + #endif + #ifndef SD_ERASE_TIMEOUT + #define SD_ERASE_TIMEOUT 10000u // (ms) Erase timeout + #elif SD_ERASE_TIMEOUT < 0 + #error "SD_ERASE_TIMEOUT must be greater than or equal to 0." + #endif + #ifndef SD_READ_TIMEOUT + #define SD_READ_TIMEOUT 300u // (ms) Read timeout + #elif SD_READ_TIMEOUT < 0 + #error "SD_READ_TIMEOUT must be greater than or equal to 0." + #endif + #ifndef SD_WRITE_TIMEOUT + #define SD_WRITE_TIMEOUT 600u // (ms) Write timeout + #elif SD_WRITE_TIMEOUT < 0 + #error "SD_WRITE_TIMEOUT must be greater than or equal to 0." + #endif +#endif // SD_NO_DEFAULT_TIMEOUT + +#if ENABLED(SD_CHECK_AND_RETRY) + #ifndef SD_RETRY_COUNT + #define SD_RETRY_COUNT 3 + #elif SD_RETRY_COUNT < 1 + #error "SD_RETRY_COUNT must be greater than or equal to 1." + #endif +#endif + #if ENABLED(SD_CHECK_AND_RETRY) static bool crcSupported = true; @@ -97,15 +128,16 @@ uint8_t DiskIODriver_SPI_SD::cardCommand(const uint8_t cmd, const uint32_t arg) // Select card chipSelect(); - // Wait up to 300 ms if busy - waitNotBusy(SD_WRITE_TIMEOUT); + #if SD_WRITE_TIMEOUT + waitNotBusy(SD_WRITE_TIMEOUT); // Wait up to 600 ms (by default) if busy + #endif uint8_t *pa = (uint8_t *)(&arg); #if ENABLED(SD_CHECK_AND_RETRY) // Form message - uint8_t d[6] = {(uint8_t) (cmd | 0x40), pa[3], pa[2], pa[1], pa[0] }; + uint8_t d[6] = { uint8_t(cmd | 0x40), pa[3], pa[2], pa[1], pa[0] }; // Add crc d[5] = CRC7(d, 5); @@ -186,33 +218,42 @@ void DiskIODriver_SPI_SD::chipSelect() { bool DiskIODriver_SPI_SD::erase(uint32_t firstBlock, uint32_t lastBlock) { if (ENABLED(SDCARD_READONLY)) return false; - csd_t csd; - if (!readCSD(&csd)) goto FAIL; - - // check for single block erase - if (!csd.v1.erase_blk_en) { - // erase size mask - uint8_t m = (csd.v1.sector_size_high << 1) | csd.v1.sector_size_low; - if ((firstBlock & m) != 0 || ((lastBlock + 1) & m) != 0) { - // error card can't erase specified area - error(SD_CARD_ERROR_ERASE_SINGLE_BLOCK); - goto FAIL; + bool success = false; + do { + + csd_t csd; + if (!readCSD(&csd)) break; + + // check for single block erase + if (!csd.v1.erase_blk_en) { + // erase size mask + uint8_t m = (csd.v1.sector_size_high << 1) | csd.v1.sector_size_low; + if ((firstBlock & m) || ((lastBlock + 1) & m)) { + // error card can't erase specified area + error(SD_CARD_ERROR_ERASE_SINGLE_BLOCK); + break; + } } - } - if (type_ != SD_CARD_TYPE_SDHC) { firstBlock <<= 9; lastBlock <<= 9; } - if (cardCommand(CMD32, firstBlock) || cardCommand(CMD33, lastBlock) || cardCommand(CMD38, 0)) { - error(SD_CARD_ERROR_ERASE); - goto FAIL; - } - if (!waitNotBusy(SD_ERASE_TIMEOUT)) { - error(SD_CARD_ERROR_ERASE_TIMEOUT); - goto FAIL; - } - chipDeselect(); - return true; - FAIL: + if (type_ != SD_CARD_TYPE_SDHC) { firstBlock <<= 9; lastBlock <<= 9; } + if (cardCommand(CMD32, firstBlock) || cardCommand(CMD33, lastBlock) || cardCommand(CMD38, 0)) { + error(SD_CARD_ERROR_ERASE); + break; + } + #if SD_ERASE_TIMEOUT + if (!waitNotBusy(SD_ERASE_TIMEOUT)) { + error(SD_CARD_ERROR_ERASE_TIMEOUT); + break; + } + #else + while (spiRec() != 0xFF) {} + #endif + + success = true; + + } while (0); + chipDeselect(); - return false; + return success; } /** @@ -245,8 +286,15 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi errorCode_ = type_ = 0; chipSelectPin_ = chipSelectPin; + // 16-bit init start time allows over a minute - const millis_t init_timeout = millis() + SD_INIT_TIMEOUT; + #if SD_INIT_TIMEOUT + const millis_t init_timeout = millis() + SD_INIT_TIMEOUT; + #define INIT_TIMEOUT() ELAPSED(millis(), init_timeout) + #else + #define INIT_TIMEOUT() false + #endif + uint32_t arg; hal.watchdog_refresh(); // In case init takes too long @@ -274,7 +322,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi // Command to go idle in SPI mode while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) { - if (ELAPSED(millis(), init_timeout)) { + if (INIT_TIMEOUT()) { error(SD_CARD_ERROR_CMD0); goto FAIL; } @@ -300,7 +348,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi break; } - if (ELAPSED(millis(), init_timeout)) { + if (INIT_TIMEOUT()) { error(SD_CARD_ERROR_CMD8); goto FAIL; } @@ -312,11 +360,12 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi arg = type() == SD_CARD_TYPE_SD2 ? 0x40000000 : 0; while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) { // Check for timeout - if (ELAPSED(millis(), init_timeout)) { + if (INIT_TIMEOUT()) { error(SD_CARD_ERROR_ACMD41); goto FAIL; } } + // If SD2 read OCR register to check for SDHC card if (type() == SD_CARD_TYPE_SD2) { if (cardCommand(CMD58, 0)) { @@ -327,6 +376,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi // Discard rest of ocr - contains allowed voltage range for (uint8_t i = 0; i < 3; ++i) spiRec(); } + chipDeselect(); ready = true; @@ -353,7 +403,7 @@ bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t * const dst) { if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; // Use address if not SDHC card #if ENABLED(SD_CHECK_AND_RETRY) - uint8_t retryCnt = 3; + uint8_t retryCnt = SD_RETRY_COUNT; for (;;) { if (cardCommand(CMD17, blockNumber)) error(SD_CARD_ERROR_CMD17); @@ -458,9 +508,15 @@ bool DiskIODriver_SPI_SD::readData(uint8_t * const dst) { bool DiskIODriver_SPI_SD::readData(uint8_t * const dst, const uint16_t count) { bool success = false; - const millis_t read_timeout = millis() + SD_READ_TIMEOUT; + #if SD_READ_TIMEOUT + const millis_t read_timeout = millis() + SD_READ_TIMEOUT; + #define READ_TIMEOUT() ELAPSED(millis(), read_timeout) + #else + #define READ_TIMEOUT() false + #endif + while ((status_ = spiRec()) == 0xFF) { // Wait for start block token - if (ELAPSED(millis(), read_timeout)) { + if (READ_TIMEOUT()) { error(SD_CARD_ERROR_READ_TIMEOUT); goto FAIL; } @@ -469,7 +525,7 @@ bool DiskIODriver_SPI_SD::readData(uint8_t * const dst, const uint16_t count) { if (status_ == DATA_START_BLOCK) { spiRead(dst, count); // Transfer data - const uint16_t recvCrc = (spiRec() << 8) | spiRec(); + const uint16_t recvCrc = ((uint16_t)spiRec() << 8) | (uint16_t)spiRec(); #if ENABLED(SD_CHECK_AND_RETRY) success = !crcSupported || recvCrc == CRC_CCITT(dst, count); if (!success) error(SD_CARD_ERROR_READ_CRC); @@ -574,20 +630,23 @@ bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t * const return 0 == SDHC_CardWriteBlock(src, blockNumber); #endif - bool success = false; - if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; // Use address if not SDHC card - if (!cardCommand(CMD24, blockNumber)) { - if (writeData(DATA_START_BLOCK, src)) { - if (waitNotBusy(SD_WRITE_TIMEOUT)) { // Wait for flashing to complete - success = !(cardCommand(CMD13, 0) || spiRec()); // Response is r2 so get and check two bytes for nonzero - if (!success) error(SD_CARD_ERROR_WRITE_PROGRAMMING); - } - else - error(SD_CARD_ERROR_WRITE_TIMEOUT); + if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; // Use address if not SDHC card + bool success = !cardCommand(CMD24, blockNumber); + if (!success) { + error(SD_CARD_ERROR_CMD24); + } + else if (writeData(DATA_START_BLOCK, src)) { + #if SD_WRITE_TIMEOUT + success = waitNotBusy(SD_WRITE_TIMEOUT); // Wait for flashing to complete + if (!success) error(SD_CARD_ERROR_WRITE_TIMEOUT); + #else + while (spiRec() != 0xFF) {} + #endif + if (success) { + success = !(cardCommand(CMD13, 0) || spiRec()); // Response is r2 so get and check two bytes for nonzero + if (!success) error(SD_CARD_ERROR_WRITE_PROGRAMMING); } } - else - error(SD_CARD_ERROR_CMD24); chipDeselect(); return success; @@ -601,13 +660,25 @@ bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t * const bool DiskIODriver_SPI_SD::writeData(const uint8_t * const src) { if (ENABLED(SDCARD_READONLY)) return false; - bool success = true; chipSelect(); - // Wait for previous write to finish - if (!waitNotBusy(SD_WRITE_TIMEOUT) || !writeData(WRITE_MULTIPLE_TOKEN, src)) { - error(SD_CARD_ERROR_WRITE_MULTIPLE); - success = false; - } + + bool success = false; + do { + + // Wait for previous write to finish + #if SD_WRITE_TIMEOUT + if (!waitNotBusy(SD_WRITE_TIMEOUT)) { + error(SD_CARD_ERROR_WRITE_MULTIPLE); + break; + } + #else + while (spiRec() != 0xFF) {} + #endif + + success = writeData(WRITE_MULTIPLE_TOKEN, src); + + } while (0); + chipDeselect(); return success; } @@ -665,14 +736,31 @@ bool DiskIODriver_SPI_SD::writeStart(uint32_t blockNumber, const uint32_t eraseC bool DiskIODriver_SPI_SD::writeStop() { if (ENABLED(SDCARD_READONLY)) return false; - bool success = false; chipSelect(); - if (waitNotBusy(SD_WRITE_TIMEOUT)) { + + bool success = false; + do { + + #if SD_WRITE_TIMEOUT + if (!waitNotBusy(SD_WRITE_TIMEOUT)) { + error(SD_CARD_ERROR_STOP_TRAN); + break; + } + #else + while (spiRec() != 0xFF) {} + #endif + spiSend(STOP_TRAN_TOKEN); - success = waitNotBusy(SD_WRITE_TIMEOUT); - } - else - error(SD_CARD_ERROR_STOP_TRAN); + + #if SD_WRITE_TIMEOUT + if (!waitNotBusy(SD_WRITE_TIMEOUT)) break; + #else + while (spiRec() != 0xFF) {} + #endif + + success = true; + + } while (0); chipDeselect(); return success; diff --git a/Marlin/src/sd/Sd2Card.h b/Marlin/src/sd/Sd2Card.h index 49569af5121f..dd021364e033 100644 --- a/Marlin/src/sd/Sd2Card.h +++ b/Marlin/src/sd/Sd2Card.h @@ -39,11 +39,6 @@ #include -uint16_t const SD_INIT_TIMEOUT = 2000, // (ms) Init timeout - SD_ERASE_TIMEOUT = 10000, // (ms) Erase timeout - SD_READ_TIMEOUT = 300, // (ms) Read timeout - SD_WRITE_TIMEOUT = 600; // (ms) Write timeout - // SD card errors typedef enum : uint8_t { SD_CARD_ERROR_CMD0 = 0x01, // Timeout error for command CMD0 (initialize card in SPI mode) diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 46312bca82fb..7180b675d7fc 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -708,7 +708,7 @@ bool SdBaseFile::open(SdBaseFile * const dirFile, const uint8_t dname[11] } // Get LFN sequence number lfnSequenceNumber = pvFat->sequenceNumber & 0x1F; - if WITHIN(lfnSequenceNumber, 1, reqEntriesNum) { + if (WITHIN(lfnSequenceNumber, 1, reqEntriesNum)) { // Check checksum for all other entries with the starting checksum fetched before if (lfnChecksum == pvFat->checksum) { // Set chunk of LFN from VFAT entry into lfnName diff --git a/buildroot/tests/esp32 b/buildroot/tests/esp32 index a0f79107cf2f..2229b950c6ea 100755 --- a/buildroot/tests/esp32 +++ b/buildroot/tests/esp32 @@ -12,8 +12,8 @@ set -e restore_configs opt_set MOTHERBOARD BOARD_ESPRESSIF_ESP32 TX_BUFFER_SIZE 64 \ WIFI_SSID '"ssid"' WIFI_PWD '"password"' -opt_enable WIFISUPPORT WEBSUPPORT GCODE_MACROS BAUD_RATE_GCODE M115_GEOMETRY_REPORT REPETIER_GCODE_M360 -exec_test $1 $2 "ESP32 with WIFISUPPORT and WEBSUPPORT" "$3" +opt_enable WIFISUPPORT WEBSUPPORT OTASUPPORT GCODE_MACROS BAUD_RATE_GCODE M115_GEOMETRY_REPORT REPETIER_GCODE_M360 +exec_test $1 $2 "ESP32 with WIFISUPPORT and WEBSUPPORT and OTASUPPORT" "$3" # # Build with TMC drivers using hardware serial diff --git a/buildroot/tests/mks_tinybee b/buildroot/tests/mks_tinybee index 0351946d0aea..d3b258051bc0 100755 --- a/buildroot/tests/mks_tinybee +++ b/buildroot/tests/mks_tinybee @@ -10,11 +10,9 @@ set -e # Build with ESP3D WiFi, OTA and custom WIFI commands support # restore_configs -opt_set MOTHERBOARD BOARD_MKS_TINYBEE TX_BUFFER_SIZE 64 \ - WIFI_SSID '"ssid"' WIFI_PWD '"password"' \ - SERIAL_PORT_2 -1 BAUDRATE_2 250000 -opt_enable ESP3D_WIFISUPPORT WEBSUPPORT OTASUPPORT WIFI_CUSTOM_COMMAND -exec_test $1 "$2" "MKS TinyBee with ESP3D_WIFISUPPORT" "$3" +opt_set MOTHERBOARD BOARD_MKS_TINYBEE TX_BUFFER_SIZE 64 SERIAL_PORT_2 -1 BAUDRATE_2 250000 +opt_enable ESP3D_WIFISUPPORT +exec_test $1 $2 "MKS TinyBee with ESP3D_WIFISUPPORT" "$3" # # Build with LCD, SD support and Speaker support diff --git a/ini/renamed.ini b/ini/renamed.ini index 91ac55f5b251..84f6acd7fab9 100644 --- a/ini/renamed.ini +++ b/ini/renamed.ini @@ -63,19 +63,19 @@ extends = renamed [env:BIGTREE_OCTOPUS_V1] ;=> STM32F446ZE_btt extends = renamed -[env:BIGTREE_OCTOPUS_V1_USB] ;=> STM32F446ZE_btt_USB +[env:BIGTREE_OCTOPUS_V1_USB] ;=> STM32F446ZE_btt_usb_flash_drive extends = renamed [env:BIGTREE_OCTOPUS_PRO_V1_F429] ;=> STM32F429ZG_btt extends = renamed -[env:BIGTREE_OCTOPUS_PRO_V1_F429_USB] ;=> STM32F429ZG_btt_USB +[env:BIGTREE_OCTOPUS_PRO_V1_F429_USB] ;=> STM32F429ZG_btt_usb_flash_drive extends = renamed [env:BIGTREE_OCTOPUS_V1_F407] ;=> STM32F407ZE_btt extends = renamed -[env:BIGTREE_OCTOPUS_V1_F407_USB] ;=> STM32F407ZE_btt_USB +[env:BIGTREE_OCTOPUS_V1_F407_USB] ;=> STM32F407ZE_btt_usb_flash_drive extends = renamed [env:STM32H723Vx_btt] ;=> STM32H723VG_btt @@ -86,3 +86,12 @@ extends = renamed [env:STM32H743Vx_btt] ;=> STM32H743VI_btt extends = renamed + +[env:STM32F446ZE_btt_USB] ;=> STM32F446ZE_btt_usb_flash_drive +extends = renamed + +[env:STM32F429ZG_btt_USB] ;=> STM32F429ZG_btt_usb_flash_drive +extends = renamed + +[env:STM32F407ZE_btt_USB] ;=> STM32F407ZE_btt_usb_flash_drive +extends = renamed diff --git a/ini/samd21.ini b/ini/samd21.ini index 969ce3b9571e..f2acf829ff83 100644 --- a/ini/samd21.ini +++ b/ini/samd21.ini @@ -16,7 +16,7 @@ platform = atmelsam board = minitronics20 build_flags = ${common.build_flags} -std=gnu++17 - -DUSBCON -DUSBD_USE_CDC -D__SAMD21__ -DARDUINO_SAMD_MINITRONICS20 -Wno-deprecated-declarations -DU8G_HAL_LINKS -DDEBUG + -DUSBCON -DUSBD_USE_CDC -D__SAMD21__ -DARDUINO_SAMD_MINITRONICS20 -Wno-deprecated-declarations -DDEBUG -IMarlin/src/HAL/SAMD21/u8g build_unflags = -std=gnu++11 build_src_filter = ${common.default_src_filter} + diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 0a8453f3076f..b9d9198e3255 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -95,7 +95,7 @@ upload_protocol = serial # BigTreeTech SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) # # STM32F103RC_btt_maple ............. RCT6 with 256K -# STM32F103RC_btt_USB_maple ......... RCT6 with 256K (USB mass storage) +# STM32F103RC_btt_USB_maple ......... RCT6 with 256K with USB Media Share Support # [env:STM32F103RC_btt_maple] extends = env:STM32F103RC_maple @@ -146,7 +146,7 @@ board_build.ldscript = crealityPro.ld # BigTreeTech SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # # STM32F103RE_btt_maple ............. RET6 -# STM32F103RE_btt_USB_maple ......... RET6 (USB mass storage) +# STM32F103RE_btt_USB_maple ......... RET6 with USB Media Share Support # [env:STM32F103RE_btt_maple] extends = env:STM32F103RE_maple diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 08686a1fb475..2eab5d6f46e2 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -54,7 +54,7 @@ monitor_speed = 115200 # BigTreeTech SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) # # STM32F103RC_btt ............. RCT6 with 256K -# STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) +# STM32F103RC_btt_USB ......... RCT6 with 256K with USB Media Share Support # [env:STM32F103RC_btt] extends = common_STM32F103RC_variant @@ -206,7 +206,7 @@ build_flags = ${stm32_variant.build_flags} # BigTreeTech SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # # STM32F103RE_btt ............. RET6 -# STM32F103RE_btt_USB ......... RET6 (USB mass storage) +# STM32F103RE_btt_USB ......... RET6 with USB Media Share Support # [env:STM32F103RE_btt] extends = stm32_variant @@ -302,7 +302,8 @@ build_unflags = ${mks_robin_nano_v1v2_common.build_unflags} -DUSBC [env:mks_robin_mini] extends = STM32F103VE_robin board_build.encrypt_mks = Robin_mini.bin -build_unflags = ${STM32F103VE_robin.build_unflags} -DSS_TIMER=4 +build_unflags = ${STM32F103VE_robin.build_unflags} -DSS_TIMER=4 -DTIMER_SERVO=TIM2 +build_flags = ${STM32F103VE_robin.build_flags} -DTIMER_SERVO=TIM1 # # MKS Robin E3p (STM32F103VET6) diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 8708a6dbcacd..bb594b97f909 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -283,7 +283,7 @@ build_flags = ${stm32_variant.build_flags} # # BigTreeTech Octopus V1.0/1.1 / Octopus Pro V1.0 (STM32F446ZET6 ARM Cortex-M4) with USB Flash Drive Support # -[env:STM32F446ZE_btt_USB] +[env:STM32F446ZE_btt_usb_flash_drive] extends = env:STM32F446ZE_btt platform_packages = ${stm_flash_drive.platform_packages} build_unflags = -DUSBD_USE_CDC @@ -309,7 +309,7 @@ build_flags = ${stm32_variant.build_flags} # # BigTreeTech Octopus V1.1 / Octopus Pro V1.0 (STM32F429ZGT6 ARM Cortex-M4) with USB Flash Drive Support # -[env:STM32F429ZG_btt_USB] +[env:STM32F429ZG_btt_usb_flash_drive] extends = env:STM32F429ZG_btt platform_packages = ${stm_flash_drive.platform_packages} build_unflags = -DUSBD_USE_CDC @@ -331,7 +331,7 @@ build_flags = ${stm32_variant.build_flags} # # BigTreeTech Octopus / Octopus Pro (STM32F407ZET6 ARM Cortex-M4) with USB Flash Drive Support # -[env:STM32F407ZE_btt_USB] +[env:STM32F407ZE_btt_usb_flash_drive] extends = env:STM32F407ZE_btt platform_packages = ${stm_flash_drive.platform_packages} build_unflags = -DUSBD_USE_CDC diff --git a/ini/stm32g0.ini b/ini/stm32g0.ini index f67002fa5c3c..fa6e5cba74ce 100644 --- a/ini/stm32g0.ini +++ b/ini/stm32g0.ini @@ -43,7 +43,7 @@ upload_protocol = dfu upload_command = dfu-util -a 0 -s 0x08000000:leave -D "$SOURCE" # -# BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RET6 ARM Cortex-M0+) +# BigTreeTech SKR Mini E3 V3.0 (STM32G0B0RET6 / STM32G0B1RET6 ARM Cortex-M0+) # [env:STM32G0B1RE_btt] extends = stm32_variant @@ -62,7 +62,7 @@ upload_protocol = stlink debug_tool = stlink # -# BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RET6 ARM Cortex-M0+) +# BigTreeTech SKR Mini E3 V3.0 (STM32G0B0RET6 / STM32G0B1RET6 ARM Cortex-M0+) # Custom upload to SD via Marlin with Binary Protocol # Requires Marlin with BINARY_FILE_TRANSFER already installed on the target board. # If CUSTOM_FIRMWARE_UPLOAD is also installed, Marlin will reboot the board to install the firmware. @@ -76,7 +76,8 @@ extra_scripts = ${env:STM32G0B1RE_btt.extra_scripts} upload_protocol = custom # -# BigTreeTech Manta E3 EZ V1.0 / Manta M4P V1.0 / Manta M5P V1.0 (STM32G0B1RET6 ARM Cortex-M0+) +# BigTreeTech Manta M4P V1.0 (STM32G0B0RET6 ARM Cortex-M0+) +# BigTreeTech Manta E3 EZ V1.0 / Manta M5P V1.0 (STM32G0B1RET6 ARM Cortex-M0+) # [env:STM32G0B1RE_manta_btt] extends = env:STM32G0B1RE_btt @@ -84,7 +85,8 @@ build_flags = ${env:STM32G0B1RE_btt.build_flags} -DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8 -DENABLE_HWSERIAL3 # -# BigTreeTech Manta E3 EZ V1.0 / Manta M4P V1.0 / Manta M5P V1.0 (STM32G0B1RET6 ARM Cortex-M0+) +# BigTreeTech Manta M4P V1.0 (STM32G0B0RET6 ARM Cortex-M0+) +# BigTreeTech Manta E3 EZ V1.0 / Manta M5P V1.0 (STM32G0B1RET6 ARM Cortex-M0+) # Custom upload to SD via Marlin with Binary Protocol # Requires Marlin with BINARY_FILE_TRANSFER already installed on the target board. # If CUSTOM_FIRMWARE_UPLOAD is also installed, Marlin will reboot the board to install the firmware.