Refactor. Put constants needed in functions inside fuctions to limit its scope.
This commit is contained in:
parent
2755a3733d
commit
7ac098a135
1 changed files with 108 additions and 109 deletions
|
@ -10,7 +10,9 @@
|
|||
#include "mmu.h"
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
|
||||
//! @brief Preheat
|
||||
void lay1cal_preheat()
|
||||
{
|
||||
static const char cmd_preheat_0[] PROGMEM = "M107";
|
||||
static const char cmd_preheat_1[] PROGMEM = "M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP);
|
||||
static const char cmd_preheat_2[] PROGMEM = "M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP);
|
||||
|
@ -19,7 +21,6 @@ static const char cmd_preheat_4[] PROGMEM = "M109 S" STRINGIFY(PLA_PREHEAT_HOTEN
|
|||
static const char cmd_preheat_5[] PROGMEM = "G28";
|
||||
static const char cmd_preheat_6[] PROGMEM = "G92 E0.0";
|
||||
|
||||
|
||||
static const char * const preheat_cmd[] PROGMEM =
|
||||
{
|
||||
cmd_preheat_0,
|
||||
|
@ -31,9 +32,6 @@ static const char * const preheat_cmd[] PROGMEM =
|
|||
cmd_preheat_6,
|
||||
};
|
||||
|
||||
//! @brief Preheat
|
||||
void lay1cal_preheat()
|
||||
{
|
||||
for (uint8_t i = 0; i < (sizeof(preheat_cmd)/sizeof(preheat_cmd[0])); ++i)
|
||||
{
|
||||
if (5 == i) enquecommand_P(_T(MSG_M117_V2_CALIBRATION));
|
||||
|
@ -42,6 +40,11 @@ void lay1cal_preheat()
|
|||
|
||||
}
|
||||
|
||||
//! @brief Print intro line
|
||||
//! @param cmd_buffer character buffer needed to format gcodes
|
||||
//! @param filament filament to use (applies for MMU only)
|
||||
void lay1cal_intro_line(char *cmd_buffer, uint8_t filament)
|
||||
{
|
||||
static const char cmd_intro_mmu_0[] PROGMEM = "M83";
|
||||
static const char cmd_intro_mmu_1[] PROGMEM = "G1 Y-3.0 F1000.0";
|
||||
static const char cmd_intro_mmu_2[] PROGMEM = "G1 Z0.4 F1000.0";
|
||||
|
@ -73,11 +76,6 @@ static const char * const intro_mmu_cmd[] PROGMEM =
|
|||
cmd_intro_mmu_12,
|
||||
};
|
||||
|
||||
//! @brief Print intro line
|
||||
//! @param cmd_buffer character buffer needed to format gcodes
|
||||
//! @param filament filament to use (applies for MMU only)
|
||||
void lay1cal_intro_line(char *cmd_buffer, uint8_t filament)
|
||||
{
|
||||
if (mmu_enabled)
|
||||
{
|
||||
for (uint8_t i = 0; i < (sizeof(intro_mmu_cmd)/sizeof(intro_mmu_cmd[0])); ++i)
|
||||
|
@ -97,6 +95,9 @@ void lay1cal_intro_line(char *cmd_buffer, uint8_t filament)
|
|||
}
|
||||
}
|
||||
|
||||
//! @brief Setup for printing meander
|
||||
void lay1cal_before_meander()
|
||||
{
|
||||
static const char cmd_pre_meander_0[] PROGMEM = "G92 E0.0";
|
||||
static const char cmd_pre_meander_1[] PROGMEM = "G21"; //set units to millimeters TODO unsupported command
|
||||
static const char cmd_pre_meander_2[] PROGMEM = "G90"; //use absolute coordinates
|
||||
|
@ -118,15 +119,33 @@ static const char * const cmd_pre_meander[] PROGMEM =
|
|||
cmd_pre_meander_7,
|
||||
};
|
||||
|
||||
//! @brief Setup for printing meander
|
||||
void lay1cal_before_meander()
|
||||
{
|
||||
for (uint8_t i = 0; i < (sizeof(cmd_pre_meander)/sizeof(cmd_pre_meander[0])); ++i)
|
||||
{
|
||||
enquecommand_P(static_cast<char*>(pgm_read_ptr(&cmd_pre_meander[i])));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! @brief Count extrude length
|
||||
//!
|
||||
//! @param layer_heigth layer heigth in mm
|
||||
//! @param extrusion_width extrusion width in mm
|
||||
//! @param extrusion_length extrusion length in mm
|
||||
//! @return filament length in mm which needs to be extruded to form line
|
||||
static constexpr float count_e(float layer_heigth, float extrusion_width, float extrusion_length)
|
||||
{
|
||||
return (extrusion_length * layer_heigth * extrusion_width / (M_PI * pow(1.75, 2) / 4));
|
||||
}
|
||||
|
||||
static const float width = 0.4; //!< line width
|
||||
static const float length = 20 - width; //!< line length
|
||||
static const float heigth = 0.2; //!< layer height TODO This is wrong, as current Z height is 0.15 mm
|
||||
static const float extr = count_e(heigth, width, length); //!< E axis movement needed to print line
|
||||
|
||||
//! @brief Print meander
|
||||
//! @param cmd_buffer character buffer needed to format gcodes
|
||||
void lay1cal_meander(char *cmd_buffer)
|
||||
{
|
||||
static const char cmd_meander_0[] PROGMEM = "G1 X50 Y155";
|
||||
static const char cmd_meander_1[] PROGMEM = "G1 Z0.150 F7200.000";
|
||||
static const char cmd_meander_2[] PROGMEM = "G1 F1080";
|
||||
|
@ -164,26 +183,6 @@ static const char * const cmd_meander[] PROGMEM =
|
|||
cmd_meander_15,
|
||||
};
|
||||
|
||||
//! @brief Count extrude length
|
||||
//!
|
||||
//! @param layer_heigth layer heigth in mm
|
||||
//! @param extrusion_width extrusion width in mm
|
||||
//! @param extrusion_length extrusion length in mm
|
||||
//! @return filament length in mm which needs to be extruded to form line
|
||||
static constexpr float count_e(float layer_heigth, float extrusion_width, float extrusion_length)
|
||||
{
|
||||
return (extrusion_length * layer_heigth * extrusion_width / (M_PI * pow(1.75, 2) / 4));
|
||||
}
|
||||
|
||||
static const float width = 0.4; //!< line width
|
||||
static const float length = 20 - width; //!< line length
|
||||
static const float heigth = 0.2; //!< layer height TODO This is wrong, as current Z height is 0.15 mm
|
||||
static const float extr = count_e(heigth, width, length); //!< E axis movement needed to print line
|
||||
|
||||
//! @brief Print meander
|
||||
//! @param cmd_buffer character buffer needed to format gcodes
|
||||
void lay1cal_meander(char *cmd_buffer)
|
||||
{
|
||||
for (uint8_t i = 0; i < (sizeof(cmd_meander)/sizeof(cmd_meander[0])); ++i)
|
||||
{
|
||||
enquecommand_P(static_cast<char*>(pgm_read_ptr(&cmd_meander[i])));
|
||||
|
|
Loading…
Add table
Reference in a new issue