|
|
|
|
@ -37,12 +37,31 @@ 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<char*>(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()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enquecommand_P(static_cast<char*>(pgm_ptr));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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%.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.2812; //max_pos[1]/2 / meander * 2
|
|
|
|
|
static constexpr float square_width = short_length*2;
|
|
|
|
|
#endif //NEW_FIRST_LAYER_CAL
|
|
|
|
|
static constexpr float long_length = 150;
|
|
|
|
|
|
|
|
|
|
//! @brief Wait for preheat
|
|
|
|
|
void lay1cal_wait_preheat()
|
|
|
|
|
@ -72,8 +91,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 +115,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 = "G1X202.5E8F1400";
|
|
|
|
|
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
|
|
|
|
|
cmd_intro_mmu_3,
|
|
|
|
|
cmd_intro_mmu_4,
|
|
|
|
|
|
|
|
|
|
cmd_intro_mmu_5,
|
|
|
|
|
cmd_intro_mmu_6,
|
|
|
|
|
zero_extrusion,
|
|
|
|
|
@ -119,42 +135,42 @@ 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<char*>(pgm_read_ptr(&intro_mmu_cmd[i])));
|
|
|
|
|
enquecommand_P(static_cast<char*>(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));
|
|
|
|
|
enquecommand_P(feedrate_F1080); //fixed velocity for the intro line
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! @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,88 +179,86 @@ 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%.2f";
|
|
|
|
|
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(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));
|
|
|
|
|
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));
|
|
|
|
|
#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;
|
|
|
|
|
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_pos, y_pos, long_extrusion);
|
|
|
|
|
|
|
|
|
|
y_pos -= short_length;
|
|
|
|
|
|
|
|
|
|
enquecommandf_P(extrude_fmt, x_pos, y_pos, short_extrusion);
|
|
|
|
|
|
|
|
|
|
x_pos += long_length;
|
|
|
|
|
|
|
|
|
|
long_length = -long_length;
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! @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 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)
|
|
|
|
|
for (uint8_t i = 0; i < 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)
|
|
|
|
|
void lay1cal_finish()
|
|
|
|
|
{
|
|
|
|
|
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_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_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
|
|
|
|
|
MSG_G90, // Set to Absolute Positioning
|
|
|
|
|
MSG_M107, // Turn off printer fan
|
|
|
|
|
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_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])));
|
|
|
|
|
|
|
|
|
|
if (mmu_enabled) enquecommand_P(MSG_M702); //unload from nozzle
|
|
|
|
|
enquecommand_P(MSG_M84);// disable motors
|
|
|
|
|
}
|
|
|
|
|
|