From d1470d8abc650f4a966765a2084ce7e6a8ea98ec Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 14 Nov 2024 14:16:35 +0100 Subject: [PATCH 01/13] New first layer calibration - changed to relative mode to save buffer and code size - added NEW_FIRST_LAYER_CAL to perform 1st layer cal from front to back --- Firmware/first_lay_cal.cpp | 144 +++++++++++++----------- Firmware/messages.cpp | 1 + Firmware/messages.h | 1 + Firmware/ultralcd.cpp | 6 +- Firmware/variants/MK25-RAMBo10a.h | 1 + Firmware/variants/MK25-RAMBo13a.h | 1 + Firmware/variants/MK25S-RAMBo10a.h | 1 + Firmware/variants/MK25S-RAMBo13a.h | 1 + Firmware/variants/MK3-E3DREVO.h | 1 + Firmware/variants/MK3-E3DREVO_HF_60W.h | 1 + Firmware/variants/MK3.h | 1 + Firmware/variants/MK3S-E3DREVO.h | 1 + Firmware/variants/MK3S-E3DREVO_HF_60W.h | 1 + Firmware/variants/MK3S.h | 1 + 14 files changed, 92 insertions(+), 70 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 5e61f1f061..402ea8c461 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -11,6 +11,7 @@ #include "mmu2.h" #include #include +#include "temperature.h" //! @brief Count extrude length //! @@ -41,8 +42,18 @@ static void lay1cal_common_enqueue_loop(const char * const * cmd_sequence, const } } -static const char extrude_fmt[] PROGMEM = "G1 X%d Y%d E%-.5f"; -static const char zero_extrusion[] PROGMEM = "G92 E0"; +static const char extrude_fmt_X[] PROGMEM = "G1X%gE%g"; +static const char extrude_fmt_Y[] PROGMEM = "G1Y%gE%g"; +static const char zero_extrusion[] PROGMEM = "G92E0"; +#ifndef NEW_FIRST_LAYER_CAL +int8_t invert = 1; +const float short_length = 20; +#else +int8_t invert = -1; +const float short_length = 13; +#endif //NEW_FIRST_LAYER_CAL +const float square_width = 20; +const float long_length = 150; //! @brief Wait for preheat void lay1cal_wait_preheat() @@ -72,8 +83,8 @@ bool lay1cal_load_filament(uint8_t filament) if (MMU2::mmu2.Enabled()) { enquecommand_P(MSG_M83); - enquecommand_P(PSTR("G1 Y-3 F1000")); - enquecommand_P(PSTR("G1 Z0.4 F1000")); + enquecommand_P(PSTR("G1Y-3F1000")); + enquecommand_P(PSTR("G1Z0.4")); uint8_t currentTool = MMU2::mmu2.get_current_tool(); if(currentTool == filament ){ @@ -96,22 +107,19 @@ bool lay1cal_load_filament(uint8_t filament) //! @param extrusion_width the width of the extrusion layer void lay1cal_intro_line(bool extraPurgeNeeded, float layer_height, float extrusion_width) { - static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55 E29 F1073"; - static const char cmd_intro_mmu_4[] PROGMEM = "G1 X5 E29 F1800"; - static const char cmd_intro_mmu_5[] PROGMEM = "G1 X55 E8 F2000"; - static const char cmd_intro_mmu_6[] PROGMEM = "G1 Z0.3 F1000"; - static const char cmd_intro_mmu_8[] PROGMEM = "G1 X240 E25 F2200"; - static const char cmd_intro_mmu_9[] PROGMEM = "G1 Y-2 F1000"; - static const char cmd_intro_mmu_10[] PROGMEM = "G1 X55 E25 F1400"; - static const char cmd_intro_mmu_11[] PROGMEM = "G1 Z0.2 F1000"; - static const char cmd_intro_mmu_12[] PROGMEM = "G1 X5 E4 F1000"; - - static const char * const intro_mmu_cmd[] PROGMEM = + static const char cmd_intro_mmu_3[] PROGMEM = "G1X55E29F1073"; + static const char cmd_intro_mmu_4[] PROGMEM = "G1X5E29F1800"; + static const char cmd_intro_mmu_5[] PROGMEM = "G1X55E8F2000"; + static const char cmd_intro_mmu_6[] PROGMEM = "G1Z0.3F1000"; + static const char cmd_intro_mmu_8[] PROGMEM = "G1X240E25F2200"; + static const char cmd_intro_mmu_9[] PROGMEM = "G1Y-2F1000"; + static const char cmd_intro_mmu_10[] PROGMEM = "G1X200E8F1400"; + static const char cmd_intro_mmu_11[] PROGMEM = "G1Z0.2F1000"; + static const char * const cmd_intro_mmu[] PROGMEM = { // first 2 items are only relevant if filament was not loaded - i.e. extraPurgeNeeded == true cmd_intro_mmu_3, cmd_intro_mmu_4, - cmd_intro_mmu_5, cmd_intro_mmu_6, zero_extrusion, @@ -119,42 +127,41 @@ void lay1cal_intro_line(bool extraPurgeNeeded, float layer_height, float extrusi cmd_intro_mmu_9, cmd_intro_mmu_10, cmd_intro_mmu_11, - cmd_intro_mmu_12, }; if (MMU2::mmu2.Enabled()) { - for (uint8_t i = (extraPurgeNeeded ? 0 : 2); i < (sizeof(intro_mmu_cmd)/sizeof(intro_mmu_cmd[0])); ++i) + for (uint8_t i = (extraPurgeNeeded ? 0 : 2); i < (sizeof(cmd_intro_mmu)/sizeof(cmd_intro_mmu[0])); ++i) { - enquecommand_P(static_cast(pgm_read_ptr(&intro_mmu_cmd[i]))); + enquecommand_P(static_cast(pgm_read_ptr(&cmd_intro_mmu[i]))); } } else { - static const char fmt1[] PROGMEM = "G1 X%d E%-.3f F1000"; - enquecommandf_P(fmt1, 60, count_e(layer_height, extrusion_width * 4.f, 60)); - enquecommandf_P(fmt1, 100, count_e(layer_height, extrusion_width * 8.f, 40)); + enquecommandf_P(extrude_fmt_X, (float)60, count_e(layer_height, extrusion_width * 4.f, 60)); + enquecommandf_P(extrude_fmt_X, (float)202.5, count_e(layer_height, extrusion_width * 8.f, 142.5)); } } //! @brief Setup for printing meander void lay1cal_before_meander() { - static const char cmd_pre_meander_2[] PROGMEM = "G90"; //use absolute coordinates - static const char cmd_pre_meander_4[] PROGMEM = "G1 E-1.5 F2100"; - static const char cmd_pre_meander_5[] PROGMEM = "G1 Z5 F7200"; - static const char cmd_pre_meander_6[] PROGMEM = "M204 S1000"; //set acceleration - static const char cmd_pre_meander_7[] PROGMEM = "G1 F4000"; +#ifndef NEW_FIRST_LAYER_CAL + static const char cmd_pre_meander_4[] PROGMEM = "G1E-1.5F2100"; + static const char cmd_pre_meander_5[] PROGMEM = "G1Z5F7200"; +#endif //NEW_FIRST_LAYER_CAL + static const char cmd_pre_meander_6[] PROGMEM = "M204S1000"; //set acceleration static const char * const cmd_pre_meander[] PROGMEM = { zero_extrusion, - cmd_pre_meander_2, + MSG_G90, MSG_M83, // use relative distances for extrusion +#ifndef NEW_FIRST_LAYER_CAL cmd_pre_meander_4, cmd_pre_meander_5, +#endif //NEW_FIRST_LAYER_CAL cmd_pre_meander_6, - cmd_pre_meander_7, }; lay1cal_common_enqueue_loop(cmd_pre_meander, (sizeof(cmd_pre_meander)/sizeof(cmd_pre_meander[0]))); @@ -163,42 +170,49 @@ void lay1cal_before_meander() //! @brief Print meander start void lay1cal_meander_start(float layer_height, float extrusion_width) { - enquecommand_P(PSTR("G1 X50 Y155")); - - static const char fmt1[] PROGMEM = "G1 Z%-.3f F7200"; +#ifndef NEW_FIRST_LAYER_CAL + enquecommand_P(PSTR("G1X50Y155")); +#endif //_NEW_FIRST_LAYER_CAL + static const char fmt1[] PROGMEM = "G1Z%gF7200"; enquecommandf_P(fmt1, layer_height); - - enquecommand_P(PSTR("G1 F1080")); - - enquecommandf_P(extrude_fmt, 75, 155, count_e(layer_height, extrusion_width * 4.f, 25)); - enquecommandf_P(extrude_fmt, 100, 155, count_e(layer_height, extrusion_width * 2.f, 25)); - enquecommandf_P(extrude_fmt, 200, 155, count_e(layer_height, extrusion_width, 100)); - enquecommandf_P(extrude_fmt, 200, 135, count_e(layer_height, extrusion_width, 20)); + enquecommand_P(PSTR("G1F1080")); +#ifdef NEW_FIRST_LAYER_CAL + enquecommandf_P(extrude_fmt_Y, short_length, count_e(layer_height, extrusion_width, short_length)); +#endif //_NEW_FIRST_LAYER_CAL + + enquecommand_P(PSTR("G91")); +#ifndef NEW_FIRST_LAYER_CAL + enquecommandf_P(extrude_fmt_X, (float)25*invert, count_e(layer_height, extrusion_width * 4.f, 25)); + enquecommandf_P(extrude_fmt_X, (float)25*invert, count_e(layer_height, extrusion_width * 2.f, 25)); + enquecommandf_P(extrude_fmt_X, (float)100*invert, count_e(layer_height, extrusion_width, 100)); + enquecommandf_P(extrude_fmt_Y, (float)-20*invert, count_e(layer_height, extrusion_width, 20)); +#else + enquecommandf_P(extrude_fmt_X, long_length*invert, count_e(layer_height, extrusion_width, long_length)); + enquecommandf_P(extrude_fmt_Y, -short_length*invert, count_e(layer_height, extrusion_width, short_length)); +#endif //_NEW_FIRST_LAYER_CAL } //! @brief Print meander //! @param cmd_buffer character buffer needed to format gcodes void lay1cal_meander(float layer_height, float extrusion_width) { - const float short_length = 20; - float long_length = 150; const float long_extrusion = count_e(layer_height, extrusion_width, long_length); const float short_extrusion = count_e(layer_height, extrusion_width, short_length); - uint8_t y_pos = 135; - uint8_t x_pos = 50; + float x_pos = long_length; + for(uint8_t i = 0; i <= 4; ++i) { - enquecommandf_P(extrude_fmt, x_pos, y_pos, long_extrusion); + enquecommandf_P(extrude_fmt_X, -x_pos*invert, long_extrusion); - y_pos -= short_length; + x_pos = -x_pos; - enquecommandf_P(extrude_fmt, x_pos, y_pos, short_extrusion); - - x_pos += long_length; - - long_length = -long_length; + enquecommandf_P(extrude_fmt_Y, -short_length*invert, short_extrusion); } +#ifdef NEW_FIRST_LAYER_CAL + enquecommandf_P(extrude_fmt_X, -(long_length/2-square_width/2), long_extrusion); //~Middle of bed X125 + enquecommandf_P(extrude_fmt_Y, short_length, short_extrusion); //~Middle of bed Y105 +#endif //NEW_FIRST_LAYER_CAL } @@ -210,41 +224,37 @@ void lay1cal_meander(float layer_height, float extrusion_width) //! @param i iteration void lay1cal_square(uint8_t step, float layer_height, float extrusion_width) { - const float long_length = 20; - const float short_length = spacing(layer_height, extrusion_width); - const float long_extrusion = count_e(layer_height, extrusion_width, long_length); - const float short_extrusion = count_e(layer_height, extrusion_width, short_length); - static const char fmt1[] PROGMEM = "G1 X%d Y%-.2f E%-.3f"; + const float Y_spacing = spacing(layer_height, extrusion_width); + const float long_extrusion = count_e(layer_height, extrusion_width, square_width); + const float short_extrusion = count_e(layer_height, extrusion_width, Y_spacing); for (uint8_t i = step; i < step+4; ++i) { - enquecommandf_P(fmt1, 70, (35 - i*short_length * 2), long_extrusion); - enquecommandf_P(fmt1, 70, (35 - (2 * i + 1)*short_length), short_extrusion); - enquecommandf_P(fmt1, 50, (35 - (2 * i + 1)*short_length), long_extrusion); - enquecommandf_P(fmt1, 50, (35 - (i + 1)*short_length * 2), short_extrusion); + enquecommandf_P(extrude_fmt_X, square_width*invert, long_extrusion); + enquecommandf_P(extrude_fmt_Y, -Y_spacing*invert, short_extrusion); + enquecommandf_P(extrude_fmt_X, -square_width*invert, long_extrusion); + enquecommandf_P(extrude_fmt_Y, -Y_spacing*invert, short_extrusion); } } void lay1cal_finish(bool mmu_enabled) { - static const char cmd_cal_finish_1[] PROGMEM = "G1 E-0.075 F2100"; //retract - static const char cmd_cal_finish_2[] PROGMEM = "M104 S0"; // turn off temperature - static const char cmd_cal_finish_3[] PROGMEM = "M140 S0"; // turn off heatbed - static const char cmd_cal_finish_4[] PROGMEM = "G1 Z10 F1300"; //lift Z - static const char cmd_cal_finish_5[] PROGMEM = "G1 X10 Y180 F4000"; //Go to parking position + static const char cmd_cal_finish_2[] PROGMEM = "G1E-0.075F2100"; //retract + static const char cmd_cal_finish_3[] PROGMEM = "G1Z10F1300"; //lift Z + static const char cmd_cal_finish_4[] PROGMEM = "G1X10Y180F4000"; //Go to parking position static const char * const cmd_cal_finish[] PROGMEM = { MSG_M107, // turn off printer fan - cmd_cal_finish_1, cmd_cal_finish_2, cmd_cal_finish_3, - cmd_cal_finish_4, - cmd_cal_finish_5 + cmd_cal_finish_4 }; + enquecommand_P(MSG_G90); lay1cal_common_enqueue_loop(cmd_cal_finish, (sizeof(cmd_cal_finish)/sizeof(cmd_cal_finish[0]))); if (mmu_enabled) enquecommand_P(MSG_M702); //unload from nozzle + disable_heater(); enquecommand_P(MSG_M84);// disable motors } diff --git a/Firmware/messages.cpp b/Firmware/messages.cpp index 75303059b8..7a0d6cec3d 100644 --- a/Firmware/messages.cpp +++ b/Firmware/messages.cpp @@ -428,6 +428,7 @@ const char MSG_FILAMENT_RUNOUT_DETECTED[] PROGMEM_N1 = "Filament runout detected // Common G-gcodes const char G1_E_F2700[] PROGMEM_N1 = "G1 E%-.3f F2700"; const char G28W[] PROGMEM_N1 = "G28 W"; +const char MSG_G90[] PROGMEM_N1 = "G90"; const char MSG_M23[] PROGMEM_N1 = "M23 %s"; const char MSG_M24[] PROGMEM_N1 = "M24"; const char MSG_M83[] PROGMEM_N1 = "M83"; diff --git a/Firmware/messages.h b/Firmware/messages.h index 4d1e6c99e7..ed1fd857aa 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -430,6 +430,7 @@ extern const char MSG_FILAMENT_RUNOUT_DETECTED[]; // Common G-gcodes extern const char G1_E_F2700[]; extern const char G28W[]; +extern const char MSG_G90[]; extern const char MSG_M23[]; extern const char MSG_M24[]; extern const char MSG_M83[]; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index df78267ee3..1dd7c5a722 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -860,13 +860,13 @@ void lcd_commands() lay1cal_square(0, layer_height, extrusion_width); break; case 5: - lay1cal_square(4, layer_height, extrusion_width); + lay1cal_square(1, layer_height, extrusion_width); break; case 4: - lay1cal_square(8, layer_height, extrusion_width); + lay1cal_square(2, layer_height, extrusion_width); break; case 3: - lay1cal_square(12, layer_height, extrusion_width); + lay1cal_square(3, layer_height, extrusion_width); break; case 2: lay1cal_finish(MMU2::mmu2.Enabled()); diff --git a/Firmware/variants/MK25-RAMBo10a.h b/Firmware/variants/MK25-RAMBo10a.h index 4e02bf14f0..77cced0bed 100644 --- a/Firmware/variants/MK25-RAMBo10a.h +++ b/Firmware/variants/MK25-RAMBo10a.h @@ -24,6 +24,7 @@ #define HEATBED_V2 #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define TACH0PULLUP // Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) diff --git a/Firmware/variants/MK25-RAMBo13a.h b/Firmware/variants/MK25-RAMBo13a.h index 3b7a81408c..9f081885f5 100644 --- a/Firmware/variants/MK25-RAMBo13a.h +++ b/Firmware/variants/MK25-RAMBo13a.h @@ -24,6 +24,7 @@ #define HEATBED_V2 #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define TACH0PULLUP // Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) diff --git a/Firmware/variants/MK25S-RAMBo10a.h b/Firmware/variants/MK25S-RAMBo10a.h index 906ba6859c..b047cb00d3 100644 --- a/Firmware/variants/MK25S-RAMBo10a.h +++ b/Firmware/variants/MK25S-RAMBo10a.h @@ -24,6 +24,7 @@ #define HEATBED_V2 #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define TACH0PULLUP // Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) diff --git a/Firmware/variants/MK25S-RAMBo13a.h b/Firmware/variants/MK25S-RAMBo13a.h index bb3ad41af9..9ef7f3bd7b 100644 --- a/Firmware/variants/MK25S-RAMBo13a.h +++ b/Firmware/variants/MK25S-RAMBo13a.h @@ -24,6 +24,7 @@ #define HEATBED_V2 #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define TACH0PULLUP // Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) diff --git a/Firmware/variants/MK3-E3DREVO.h b/Firmware/variants/MK3-E3DREVO.h index 9efb587ddc..9232f84627 100644 --- a/Firmware/variants/MK3-E3DREVO.h +++ b/Firmware/variants/MK3-E3DREVO.h @@ -23,6 +23,7 @@ // Electronics #define MOTHERBOARD BOARD_EINSY_1_0a #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define HAS_SECOND_SERIAL_PORT diff --git a/Firmware/variants/MK3-E3DREVO_HF_60W.h b/Firmware/variants/MK3-E3DREVO_HF_60W.h index 5ec1bdb8db..ace4553d55 100644 --- a/Firmware/variants/MK3-E3DREVO_HF_60W.h +++ b/Firmware/variants/MK3-E3DREVO_HF_60W.h @@ -23,6 +23,7 @@ // Electronics #define MOTHERBOARD BOARD_EINSY_1_0a #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define HAS_SECOND_SERIAL_PORT diff --git a/Firmware/variants/MK3.h b/Firmware/variants/MK3.h index b9ab1ed3c0..8b0651f257 100644 --- a/Firmware/variants/MK3.h +++ b/Firmware/variants/MK3.h @@ -23,6 +23,7 @@ // Electronics #define MOTHERBOARD BOARD_EINSY_1_0a #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define HAS_SECOND_SERIAL_PORT diff --git a/Firmware/variants/MK3S-E3DREVO.h b/Firmware/variants/MK3S-E3DREVO.h index d426d7d7de..70aef3d4d2 100644 --- a/Firmware/variants/MK3S-E3DREVO.h +++ b/Firmware/variants/MK3S-E3DREVO.h @@ -22,6 +22,7 @@ // Electronics #define MOTHERBOARD BOARD_EINSY_1_0a #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define HAS_SECOND_SERIAL_PORT // PSU diff --git a/Firmware/variants/MK3S-E3DREVO_HF_60W.h b/Firmware/variants/MK3S-E3DREVO_HF_60W.h index de86f6c027..cf576d82da 100644 --- a/Firmware/variants/MK3S-E3DREVO_HF_60W.h +++ b/Firmware/variants/MK3S-E3DREVO_HF_60W.h @@ -22,6 +22,7 @@ // Electronics #define MOTHERBOARD BOARD_EINSY_1_0a #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define HAS_SECOND_SERIAL_PORT // PSU diff --git a/Firmware/variants/MK3S.h b/Firmware/variants/MK3S.h index 32ca987b02..6d2027671f 100644 --- a/Firmware/variants/MK3S.h +++ b/Firmware/variants/MK3S.h @@ -22,6 +22,7 @@ // Electronics #define MOTHERBOARD BOARD_EINSY_1_0a #define STEEL_SHEET +//#define NEW_FIRST_LAYER_CAL //from front to back #define HAS_SECOND_SERIAL_PORT // PSU From a0278b2844ccd10f290b9be6c2493a85b6f5dd4d Mon Sep 17 00:00:00 2001 From: gudnimg Date: Sun, 17 Nov 2024 16:58:55 +0000 Subject: [PATCH 02/13] Fix an issue where MMU unloads filament while its cooling down Change in memory: Flash: -6 bytes SRAM: 0 bytes --- Firmware/first_lay_cal.cpp | 39 +++++++++++++++++++++++--------------- Firmware/first_lay_cal.h | 2 +- Firmware/ultralcd.cpp | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 402ea8c461..d1ca5ee918 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -11,7 +11,6 @@ #include "mmu2.h" #include #include -#include "temperature.h" //! @brief Count extrude length //! @@ -38,7 +37,14 @@ static constexpr float spacing(float layer_height, float extrusion_width, float static void lay1cal_common_enqueue_loop(const char * const * cmd_sequence, const uint8_t steps) { for (uint8_t i = 0; i < steps; ++i) { - enquecommand_P(static_cast(pgm_read_ptr(cmd_sequence + i))); + void * pgm_ptr = pgm_read_ptr(cmd_sequence + i); + + // M702 is currently only used with MMU enabled + if (pgm_ptr == MSG_M702 && !MMU2::mmu2.Enabled()) { + continue; + } + + enquecommand_P(static_cast(pgm_ptr)); } } @@ -237,24 +243,27 @@ void lay1cal_square(uint8_t step, float layer_height, float extrusion_width) } } -void lay1cal_finish(bool mmu_enabled) +void lay1cal_finish() { - static const char cmd_cal_finish_2[] PROGMEM = "G1E-0.075F2100"; //retract - static const char cmd_cal_finish_3[] PROGMEM = "G1Z10F1300"; //lift Z - static const char cmd_cal_finish_4[] PROGMEM = "G1X10Y180F4000"; //Go to parking position + static const char cmd_cal_finish_1[] PROGMEM = "G1E-0.075F2100"; // Retract + static const char cmd_cal_finish_2[] PROGMEM = "M140S0"; // Turn off bed heater + static const char cmd_cal_finish_3[] PROGMEM = "M104S0"; // Turn off hotend heater + static const char cmd_cal_finish_4[] PROGMEM = "G1Z10F1300"; // Lift Z + static const char cmd_cal_finish_5[] PROGMEM = "G1X10Y180F4000"; // Go to parking position static const char * const cmd_cal_finish[] PROGMEM = { - MSG_M107, // turn off printer fan - cmd_cal_finish_2, - cmd_cal_finish_3, - cmd_cal_finish_4 + MSG_G90, // Set to Absolute Positioning + MSG_M107, // Turn off printer fan + cmd_cal_finish_1, // Retract + cmd_cal_finish_2, // Turn off bed heater + MSG_M702, // Unload filament (MMU only) + cmd_cal_finish_3, // Turn off hotend heater + cmd_cal_finish_4, // Lift Z + cmd_cal_finish_5, // Go to parking position + MSG_M84 // Disable stepper motors + }; - enquecommand_P(MSG_G90); lay1cal_common_enqueue_loop(cmd_cal_finish, (sizeof(cmd_cal_finish)/sizeof(cmd_cal_finish[0]))); - - if (mmu_enabled) enquecommand_P(MSG_M702); //unload from nozzle - disable_heater(); - enquecommand_P(MSG_M84);// disable motors } diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h index 1e2dd624a0..616938e4e4 100644 --- a/Firmware/first_lay_cal.h +++ b/Firmware/first_lay_cal.h @@ -13,6 +13,6 @@ void lay1cal_before_meander(); void lay1cal_meander_start(float layer_height, float extrusion_width); void lay1cal_meander(float layer_height, float extrusion_width); void lay1cal_square(uint8_t step, float layer_height, float extrusion_width); -void lay1cal_finish(bool mmu_enabled); +void lay1cal_finish(); #endif /* FIRMWARE_FIRST_LAY_CAL_H_ */ diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 1dd7c5a722..6191e6a84a 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -869,7 +869,7 @@ void lcd_commands() lay1cal_square(3, layer_height, extrusion_width); break; case 2: - lay1cal_finish(MMU2::mmu2.Enabled()); + lay1cal_finish(); break; case 1: lcd_setstatuspgm(MSG_WELCOME); From 0b5afa30920a5495ebc21c72d63b45722e896ad0 Mon Sep 17 00:00:00 2001 From: gudnimg Date: Sun, 17 Nov 2024 17:03:00 +0000 Subject: [PATCH 03/13] Unload the filament at parked position We don't want to unload while the nozzle is still smudged against the bed. --- Firmware/first_lay_cal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index d1ca5ee918..ff755ee50d 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -257,10 +257,10 @@ void lay1cal_finish() MSG_M107, // Turn off printer fan cmd_cal_finish_1, // Retract cmd_cal_finish_2, // Turn off bed heater - MSG_M702, // Unload filament (MMU only) - cmd_cal_finish_3, // Turn off hotend heater cmd_cal_finish_4, // Lift Z cmd_cal_finish_5, // Go to parking position + MSG_M702, // Unload filament (MMU only) + cmd_cal_finish_3, // Turn off hotend heater MSG_M84 // Disable stepper motors }; From 44f9b953c501b639e36368f9e2c0a3ca79964bfc Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 18 Nov 2024 09:51:02 +0100 Subject: [PATCH 04/13] remove unused step parameter in lay1cal sqaure --- Firmware/first_lay_cal.cpp | 7 +++---- Firmware/first_lay_cal.h | 2 +- Firmware/ultralcd.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index ff755ee50d..018750cd45 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -224,17 +224,16 @@ void lay1cal_meander(float layer_height, float extrusion_width) //! @brief Print square //! -//! This function needs to be called 4 times with step of 0,4,8,12 +//! This function enqueues 4 lines of the square, so it needs to be called multiple times //! //! @param cmd_buffer character buffer needed to format gcodes -//! @param i iteration -void lay1cal_square(uint8_t step, float layer_height, float extrusion_width) +void lay1cal_square(float layer_height, float extrusion_width) { const float Y_spacing = spacing(layer_height, extrusion_width); const float long_extrusion = count_e(layer_height, extrusion_width, square_width); const float short_extrusion = count_e(layer_height, extrusion_width, Y_spacing); - for (uint8_t i = step; i < step+4; ++i) + for (uint8_t i = 0; i < 4; i++) { enquecommandf_P(extrude_fmt_X, square_width*invert, long_extrusion); enquecommandf_P(extrude_fmt_Y, -Y_spacing*invert, short_extrusion); diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h index 616938e4e4..7a2b80f803 100644 --- a/Firmware/first_lay_cal.h +++ b/Firmware/first_lay_cal.h @@ -12,7 +12,7 @@ void lay1cal_intro_line(bool skipExtraPurge, float layer_height, float extrusion void lay1cal_before_meander(); void lay1cal_meander_start(float layer_height, float extrusion_width); void lay1cal_meander(float layer_height, float extrusion_width); -void lay1cal_square(uint8_t step, float layer_height, float extrusion_width); +void lay1cal_square(float layer_height, float extrusion_width); void lay1cal_finish(); #endif /* FIRMWARE_FIRST_LAY_CAL_H_ */ diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 6191e6a84a..cc232611cc 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -857,16 +857,16 @@ void lcd_commands() lay1cal_meander(layer_height, extrusion_width); break; case 6: - lay1cal_square(0, layer_height, extrusion_width); + lay1cal_square(layer_height, extrusion_width); break; case 5: - lay1cal_square(1, layer_height, extrusion_width); + lay1cal_square(layer_height, extrusion_width); break; case 4: - lay1cal_square(2, layer_height, extrusion_width); + lay1cal_square(layer_height, extrusion_width); break; case 3: - lay1cal_square(3, layer_height, extrusion_width); + lay1cal_square(layer_height, extrusion_width); break; case 2: lay1cal_finish(); From 1319af8a129e284ddf69564f2bd26095104f3ca8 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 18 Nov 2024 10:09:10 +0100 Subject: [PATCH 05/13] Ensure that a correct feedrate is used at all times --- Firmware/first_lay_cal.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 018750cd45..78b515d85b 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -51,6 +51,7 @@ static void lay1cal_common_enqueue_loop(const char * const * cmd_sequence, const static const char extrude_fmt_X[] PROGMEM = "G1X%gE%g"; static const char extrude_fmt_Y[] PROGMEM = "G1Y%gE%g"; static const char zero_extrusion[] PROGMEM = "G92E0"; +static const char feedrate_F1080[] PROGMEM = "G1F1080"; #ifndef NEW_FIRST_LAYER_CAL int8_t invert = 1; const float short_length = 20; @@ -120,7 +121,7 @@ void lay1cal_intro_line(bool extraPurgeNeeded, float layer_height, float extrusi static const char cmd_intro_mmu_8[] PROGMEM = "G1X240E25F2200"; static const char cmd_intro_mmu_9[] PROGMEM = "G1Y-2F1000"; static const char cmd_intro_mmu_10[] PROGMEM = "G1X200E8F1400"; - static const char cmd_intro_mmu_11[] PROGMEM = "G1Z0.2F1000"; + static const char cmd_intro_mmu_11[] PROGMEM = "G1Z0.2"; static const char * const cmd_intro_mmu[] PROGMEM = { // first 2 items are only relevant if filament was not loaded - i.e. extraPurgeNeeded == true @@ -144,6 +145,7 @@ void lay1cal_intro_line(bool extraPurgeNeeded, float layer_height, float extrusi } else { + enquecommand_P(feedrate_F1080); //fixed velocity for the intro line enquecommandf_P(extrude_fmt_X, (float)60, count_e(layer_height, extrusion_width * 4.f, 60)); enquecommandf_P(extrude_fmt_X, (float)202.5, count_e(layer_height, extrusion_width * 8.f, 142.5)); } @@ -179,9 +181,9 @@ void lay1cal_meander_start(float layer_height, float extrusion_width) #ifndef NEW_FIRST_LAYER_CAL enquecommand_P(PSTR("G1X50Y155")); #endif //_NEW_FIRST_LAYER_CAL - static const char fmt1[] PROGMEM = "G1Z%gF7200"; + static const char fmt1[] PROGMEM = "G1Z%g"; enquecommandf_P(fmt1, layer_height); - enquecommand_P(PSTR("G1F1080")); + enquecommand_P(feedrate_F1080); #ifdef NEW_FIRST_LAYER_CAL enquecommandf_P(extrude_fmt_Y, short_length, count_e(layer_height, extrusion_width, short_length)); #endif //_NEW_FIRST_LAYER_CAL From 658df9d04d50b13fdedf2390d997f145758c8397 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 18 Nov 2024 10:12:05 +0100 Subject: [PATCH 06/13] Extract G91 to messages.h/cpp --- Firmware/first_lay_cal.cpp | 2 +- Firmware/messages.cpp | 1 + Firmware/messages.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 78b515d85b..2997adb728 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -188,7 +188,7 @@ void lay1cal_meander_start(float layer_height, float extrusion_width) enquecommandf_P(extrude_fmt_Y, short_length, count_e(layer_height, extrusion_width, short_length)); #endif //_NEW_FIRST_LAYER_CAL - enquecommand_P(PSTR("G91")); + enquecommand_P(MSG_G91); //enable relative XYZ #ifndef NEW_FIRST_LAYER_CAL enquecommandf_P(extrude_fmt_X, (float)25*invert, count_e(layer_height, extrusion_width * 4.f, 25)); enquecommandf_P(extrude_fmt_X, (float)25*invert, count_e(layer_height, extrusion_width * 2.f, 25)); diff --git a/Firmware/messages.cpp b/Firmware/messages.cpp index 7a0d6cec3d..1c5a31c309 100644 --- a/Firmware/messages.cpp +++ b/Firmware/messages.cpp @@ -429,6 +429,7 @@ const char MSG_FILAMENT_RUNOUT_DETECTED[] PROGMEM_N1 = "Filament runout detected const char G1_E_F2700[] PROGMEM_N1 = "G1 E%-.3f F2700"; const char G28W[] PROGMEM_N1 = "G28 W"; const char MSG_G90[] PROGMEM_N1 = "G90"; +const char MSG_G91[] PROGMEM_N1 = "G91"; const char MSG_M23[] PROGMEM_N1 = "M23 %s"; const char MSG_M24[] PROGMEM_N1 = "M24"; const char MSG_M83[] PROGMEM_N1 = "M83"; diff --git a/Firmware/messages.h b/Firmware/messages.h index ed1fd857aa..8ce0568406 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -431,6 +431,7 @@ extern const char MSG_FILAMENT_RUNOUT_DETECTED[]; extern const char G1_E_F2700[]; extern const char G28W[]; extern const char MSG_G90[]; +extern const char MSG_G91[]; extern const char MSG_M23[]; extern const char MSG_M24[]; extern const char MSG_M83[]; From e84ade3542dc90890e5e2f74af76365b5215d683 Mon Sep 17 00:00:00 2001 From: gudnimg Date: Tue, 19 Nov 2024 17:39:52 +0000 Subject: [PATCH 07/13] optimisation: combine a few functions calls into one Change in memory: Flash: -34 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index cc232611cc..0faec8a907 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -857,14 +857,8 @@ void lcd_commands() lay1cal_meander(layer_height, extrusion_width); break; case 6: - lay1cal_square(layer_height, extrusion_width); - break; case 5: - lay1cal_square(layer_height, extrusion_width); - break; case 4: - lay1cal_square(layer_height, extrusion_width); - break; case 3: lay1cal_square(layer_height, extrusion_width); break; From 13d12c0ffa1a00c2a5636d6d807b543d43a4994f Mon Sep 17 00:00:00 2001 From: Alexandra Voinea Date: Wed, 20 Nov 2024 08:38:19 +0100 Subject: [PATCH 08/13] Get rid of float casts --- Firmware/first_lay_cal.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 2997adb728..943f80577b 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -146,8 +146,8 @@ void lay1cal_intro_line(bool extraPurgeNeeded, float layer_height, float extrusi else { enquecommand_P(feedrate_F1080); //fixed velocity for the intro line - enquecommandf_P(extrude_fmt_X, (float)60, count_e(layer_height, extrusion_width * 4.f, 60)); - enquecommandf_P(extrude_fmt_X, (float)202.5, count_e(layer_height, extrusion_width * 8.f, 142.5)); + enquecommandf_P(extrude_fmt_X, 60.f, count_e(layer_height, extrusion_width * 4.f, 60)); + enquecommandf_P(extrude_fmt_X, 202.5f, count_e(layer_height, extrusion_width * 8.f, 142.5)); } } @@ -190,10 +190,10 @@ void lay1cal_meander_start(float layer_height, float extrusion_width) enquecommand_P(MSG_G91); //enable relative XYZ #ifndef NEW_FIRST_LAYER_CAL - enquecommandf_P(extrude_fmt_X, (float)25*invert, count_e(layer_height, extrusion_width * 4.f, 25)); - enquecommandf_P(extrude_fmt_X, (float)25*invert, count_e(layer_height, extrusion_width * 2.f, 25)); - enquecommandf_P(extrude_fmt_X, (float)100*invert, count_e(layer_height, extrusion_width, 100)); - enquecommandf_P(extrude_fmt_Y, (float)-20*invert, count_e(layer_height, extrusion_width, 20)); + enquecommandf_P(extrude_fmt_X, 25.f*invert, count_e(layer_height, extrusion_width * 4.f, 25)); + enquecommandf_P(extrude_fmt_X, 25.f*invert, count_e(layer_height, extrusion_width * 2.f, 25)); + enquecommandf_P(extrude_fmt_X, 100.f*invert, count_e(layer_height, extrusion_width, 100)); + enquecommandf_P(extrude_fmt_Y, -20.f*invert, count_e(layer_height, extrusion_width, 20)); #else enquecommandf_P(extrude_fmt_X, long_length*invert, count_e(layer_height, extrusion_width, long_length)); enquecommandf_P(extrude_fmt_Y, -short_length*invert, count_e(layer_height, extrusion_width, short_length)); From 81d124affd763d2e5d4ca158f2126c8a5b007083 Mon Sep 17 00:00:00 2001 From: Alexandra Voinea Date: Wed, 20 Nov 2024 08:52:12 +0100 Subject: [PATCH 09/13] Minor nitpicks --- Firmware/first_lay_cal.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 943f80577b..926e611317 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -37,7 +37,7 @@ static constexpr float spacing(float layer_height, float extrusion_width, float static void lay1cal_common_enqueue_loop(const char * const * cmd_sequence, const uint8_t steps) { for (uint8_t i = 0; i < steps; ++i) { - void * pgm_ptr = pgm_read_ptr(cmd_sequence + i); + void * const pgm_ptr = pgm_read_ptr(cmd_sequence + i); // M702 is currently only used with MMU enabled if (pgm_ptr == MSG_M702 && !MMU2::mmu2.Enabled()) { @@ -53,14 +53,14 @@ static const char extrude_fmt_Y[] PROGMEM = "G1Y%gE%g"; static const char zero_extrusion[] PROGMEM = "G92E0"; static const char feedrate_F1080[] PROGMEM = "G1F1080"; #ifndef NEW_FIRST_LAYER_CAL -int8_t invert = 1; -const float short_length = 20; +static constexpr int8_t invert = 1; +static constexpr float short_length = 20; #else -int8_t invert = -1; -const float short_length = 13; +static constexpr int8_t invert = -1; +static constexpr float short_length = 13; #endif //NEW_FIRST_LAYER_CAL -const float square_width = 20; -const float long_length = 150; +static constexpr float square_width = 20; +static constexpr float long_length = 150; //! @brief Wait for preheat void lay1cal_wait_preheat() From 519724b53d2c41d02b5a844ad8cd8b6c23e40716 Mon Sep 17 00:00:00 2001 From: Alexandra Voinea Date: Wed, 20 Nov 2024 08:57:36 +0100 Subject: [PATCH 10/13] Ensure all meander moves are done using relative mode Without this the first vertical move of the new meander would be slightly longer than expected due to using absolute moves from a negative Y starting position --- Firmware/first_lay_cal.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 926e611317..7d0506383b 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -184,19 +184,16 @@ void lay1cal_meander_start(float layer_height, float extrusion_width) static const char fmt1[] PROGMEM = "G1Z%g"; enquecommandf_P(fmt1, layer_height); enquecommand_P(feedrate_F1080); + enquecommand_P(MSG_G91); //enable relative XYZ #ifdef NEW_FIRST_LAYER_CAL enquecommandf_P(extrude_fmt_Y, short_length, count_e(layer_height, extrusion_width, short_length)); -#endif //_NEW_FIRST_LAYER_CAL - - enquecommand_P(MSG_G91); //enable relative XYZ -#ifndef NEW_FIRST_LAYER_CAL + enquecommandf_P(extrude_fmt_X, long_length*invert, count_e(layer_height, extrusion_width, long_length)); + enquecommandf_P(extrude_fmt_Y, -short_length*invert, count_e(layer_height, extrusion_width, short_length)); +#else enquecommandf_P(extrude_fmt_X, 25.f*invert, count_e(layer_height, extrusion_width * 4.f, 25)); enquecommandf_P(extrude_fmt_X, 25.f*invert, count_e(layer_height, extrusion_width * 2.f, 25)); enquecommandf_P(extrude_fmt_X, 100.f*invert, count_e(layer_height, extrusion_width, 100)); enquecommandf_P(extrude_fmt_Y, -20.f*invert, count_e(layer_height, extrusion_width, 20)); -#else - enquecommandf_P(extrude_fmt_X, long_length*invert, count_e(layer_height, extrusion_width, long_length)); - enquecommandf_P(extrude_fmt_Y, -short_length*invert, count_e(layer_height, extrusion_width, short_length)); #endif //_NEW_FIRST_LAYER_CAL } From 24ce71edede3490f61e14e2ee2bbec34ea0dc7e9 Mon Sep 17 00:00:00 2001 From: Alexandra Voinea Date: Wed, 20 Nov 2024 09:11:18 +0100 Subject: [PATCH 11/13] Optimize meander moves --- Firmware/first_lay_cal.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 7d0506383b..0fad63b6d3 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -204,15 +204,10 @@ void lay1cal_meander(float layer_height, float extrusion_width) const float long_extrusion = count_e(layer_height, extrusion_width, long_length); const float short_extrusion = count_e(layer_height, extrusion_width, short_length); - float x_pos = long_length; - - for(uint8_t i = 0; i <= 4; ++i) + for(int8_t i = 0, xdir = -invert; i <= 4; i++, xdir = -xdir) { - enquecommandf_P(extrude_fmt_X, -x_pos*invert, long_extrusion); - - x_pos = -x_pos; - - enquecommandf_P(extrude_fmt_Y, -short_length*invert, short_extrusion); + enquecommandf_P(extrude_fmt_X, xdir * long_length, long_extrusion); + enquecommandf_P(extrude_fmt_Y, invert * -short_length, short_extrusion); } #ifdef NEW_FIRST_LAYER_CAL enquecommandf_P(extrude_fmt_X, -(long_length/2-square_width/2), long_extrusion); //~Middle of bed X125 From 7a47bf30be79c6b9e9c042dbd6384eccad28a592 Mon Sep 17 00:00:00 2001 From: Alexandra Voinea Date: Wed, 20 Nov 2024 09:28:21 +0100 Subject: [PATCH 12/13] Fix end of meander overextrusion with new pattern --- Firmware/first_lay_cal.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 0fad63b6d3..3c04819de9 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -210,7 +210,9 @@ void lay1cal_meander(float layer_height, float extrusion_width) enquecommandf_P(extrude_fmt_Y, invert * -short_length, short_extrusion); } #ifdef NEW_FIRST_LAYER_CAL - enquecommandf_P(extrude_fmt_X, -(long_length/2-square_width/2), long_extrusion); //~Middle of bed X125 + constexpr float mid_length = 0.5f * long_length - 0.5f * square_width; + const float mid_extrusion = count_e(layer_height, extrusion_width, mid_length); + enquecommandf_P(extrude_fmt_X, -mid_length, mid_extrusion); //~Middle of bed X125 enquecommandf_P(extrude_fmt_Y, short_length, short_extrusion); //~Middle of bed Y105 #endif //NEW_FIRST_LAYER_CAL From b67554eb01da40195c708d099bc9fd9de53c2263 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 20 Nov 2024 12:10:33 +0100 Subject: [PATCH 13/13] Switch back from `%g` to `.4f` Set short length so the square is printed in the middle of the bed Both purge lines with and without MMU end at X=202.5 to get the square in the middle of the bed --- Firmware/first_lay_cal.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 3c04819de9..7f23431c91 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -48,18 +48,19 @@ static void lay1cal_common_enqueue_loop(const char * const * cmd_sequence, const } } -static const char extrude_fmt_X[] PROGMEM = "G1X%gE%g"; -static const char extrude_fmt_Y[] PROGMEM = "G1Y%gE%g"; +static const char extrude_fmt_X[] PROGMEM = "G1X%.4fE%.4f"; +static const char extrude_fmt_Y[] PROGMEM = "G1Y%.4fE%.4f"; static const char zero_extrusion[] PROGMEM = "G92E0"; static const char feedrate_F1080[] PROGMEM = "G1F1080"; #ifndef NEW_FIRST_LAYER_CAL static constexpr int8_t invert = 1; static constexpr float short_length = 20; +static constexpr float square_width = short_length; #else static constexpr int8_t invert = -1; -static constexpr float short_length = 13; +static constexpr float short_length = 13.2812; //max_pos[1]/2 / meander * 2 +static constexpr float square_width = short_length*2; #endif //NEW_FIRST_LAYER_CAL -static constexpr float square_width = 20; static constexpr float long_length = 150; //! @brief Wait for preheat @@ -120,7 +121,7 @@ void lay1cal_intro_line(bool extraPurgeNeeded, float layer_height, float extrusi static const char cmd_intro_mmu_6[] PROGMEM = "G1Z0.3F1000"; static const char cmd_intro_mmu_8[] PROGMEM = "G1X240E25F2200"; static const char cmd_intro_mmu_9[] PROGMEM = "G1Y-2F1000"; - static const char cmd_intro_mmu_10[] PROGMEM = "G1X200E8F1400"; + static const char cmd_intro_mmu_10[] PROGMEM = "G1X202.5E8F1400"; static const char cmd_intro_mmu_11[] PROGMEM = "G1Z0.2"; static const char * const cmd_intro_mmu[] PROGMEM = { @@ -181,7 +182,7 @@ void lay1cal_meander_start(float layer_height, float extrusion_width) #ifndef NEW_FIRST_LAYER_CAL enquecommand_P(PSTR("G1X50Y155")); #endif //_NEW_FIRST_LAYER_CAL - static const char fmt1[] PROGMEM = "G1Z%g"; + static const char fmt1[] PROGMEM = "G1Z%.2f"; enquecommandf_P(fmt1, layer_height); enquecommand_P(feedrate_F1080); enquecommand_P(MSG_G91); //enable relative XYZ @@ -240,24 +241,23 @@ void lay1cal_square(float layer_height, float extrusion_width) void lay1cal_finish() { - static const char cmd_cal_finish_1[] PROGMEM = "G1E-0.075F2100"; // Retract - static const char cmd_cal_finish_2[] PROGMEM = "M140S0"; // Turn off bed heater - static const char cmd_cal_finish_3[] PROGMEM = "M104S0"; // Turn off hotend heater - static const char cmd_cal_finish_4[] PROGMEM = "G1Z10F1300"; // Lift Z - static const char cmd_cal_finish_5[] PROGMEM = "G1X10Y180F4000"; // Go to parking position + static const char cmd_cal_finish_3[] PROGMEM = "G1E-0.075F2100"; // Retract + static const char cmd_cal_finish_4[] PROGMEM = "M140S0"; // Turn off bed heater + static const char cmd_cal_finish_5[] PROGMEM = "G1Z10F1300"; // Lift Z + static const char cmd_cal_finish_6[] PROGMEM = "G1X10Y180F4000"; // Go to parking position + static const char cmd_cal_finish_8[] PROGMEM = "M104S0"; // Turn off hotend heater static const char * const cmd_cal_finish[] PROGMEM = { MSG_G90, // Set to Absolute Positioning MSG_M107, // Turn off printer fan - cmd_cal_finish_1, // Retract - cmd_cal_finish_2, // Turn off bed heater - cmd_cal_finish_4, // Lift Z - cmd_cal_finish_5, // Go to parking position + cmd_cal_finish_3, // Retract + cmd_cal_finish_4, // Turn off bed heater + cmd_cal_finish_5, // Lift Z + cmd_cal_finish_6, // Go to parking position MSG_M702, // Unload filament (MMU only) - cmd_cal_finish_3, // Turn off hotend heater + cmd_cal_finish_8, // Turn off hotend heater MSG_M84 // Disable stepper motors - }; lay1cal_common_enqueue_loop(cmd_cal_finish, (sizeof(cmd_cal_finish)/sizeof(cmd_cal_finish[0])));