Commit 9ba19359 authored by MagoKimbra's avatar MagoKimbra

Add purge code

parent 8575259d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## G Codes ## G Codes
* G0 -> G1 * G0 -> G1
* G1 - Coordinated Movement X Y Z E F(feedrate) * G1 - Coordinated Movement X Y Z E F(feedrate) P(Purge)
* G2 - CW ARC * G2 - CW ARC
* G3 - CCW ARC * G3 - CCW ARC
* G4 - Dwell S[seconds] or P[milliseconds], delay in Second or Millisecond * G4 - Dwell S[seconds] or P[milliseconds], delay in Second or Millisecond
...@@ -83,7 +83,8 @@ ...@@ -83,7 +83,8 @@
* M209 - S[1=true/0=false] enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction. * M209 - S[1=true/0=false] enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
* M218 - set hotend offset (in mm): T[extruder_number] X[offset_on_X] Y[offset_on_Y] * M218 - set hotend offset (in mm): T[extruder_number] X[offset_on_X] Y[offset_on_Y]
* M220 - S[factor in percent] - set speed factor override percentage * M220 - S[factor in percent] - set speed factor override percentage
* M221 - S[factor in percent] - set extrude factor override percentage * M221 - T<extruder> S<factor in percent> - set extrude factor override percentage
* M222 - T<extruder> S<factor in percent> - set density extrude factor percentage for purge
* M240 - Trigger a camera to take a photograph * M240 - Trigger a camera to take a photograph
* M280 - Position an RC Servo P[index] S[angle/microseconds], ommit S to report back current angle * M280 - Position an RC Servo P[index] S[angle/microseconds], ommit S to report back current angle
* M300 - Play beep sound S[frequency Hz] P[duration ms] * M300 - Play beep sound S[frequency Hz] P[duration ms]
......
### Version 4.2.4 ### Version 4.2.4
* Added Abort on endstop hit feature * Added Abort on endstop hit feature
* Added Purge command G1 P<valor>
* Added M222 T<extruder> S<factor in percent> set density extrude factor percentage for purge
### Version 4.2.3 ### Version 4.2.3
* Added Filament tot printed in stats * Added Filament tot printed in stats
......
...@@ -188,6 +188,7 @@ ...@@ -188,6 +188,7 @@
* M218 - Set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y> * M218 - Set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
* M220 - Set speed factor override percentage: S<factor in percent> * M220 - Set speed factor override percentage: S<factor in percent>
* M221 - Set extrude factor override percentage: S<factor in percent> * M221 - Set extrude factor override percentage: S<factor in percent>
* M222 - Set density extrusion percentage: S<factor in percent>
* M226 - Wait until the specified pin reaches the state required: P<pin number> S<pin state> * M226 - Wait until the specified pin reaches the state required: P<pin number> S<pin state>
* M240 - Trigger a camera to take a photograph * M240 - Trigger a camera to take a photograph
* M250 - Set LCD contrast C<contrast value> (value 0..63) * M250 - Set LCD contrast C<contrast value> (value 0..63)
...@@ -275,6 +276,7 @@ bool axis_relative_modes[] = AXIS_RELATIVE_MODES; ...@@ -275,6 +276,7 @@ bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
int feedrate_multiplier = 100; //100->1 200->2 int feedrate_multiplier = 100; //100->1 200->2
int saved_feedrate_multiplier; int saved_feedrate_multiplier;
int extruder_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(100); int extruder_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(100);
int density_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(100);
bool volumetric_enabled = false; bool volumetric_enabled = false;
float filament_size[EXTRUDERS] = ARRAY_BY_EXTRUDERS(DEFAULT_NOMINAL_FILAMENT_DIA); float filament_size[EXTRUDERS] = ARRAY_BY_EXTRUDERS(DEFAULT_NOMINAL_FILAMENT_DIA);
float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(1.0); float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(1.0);
...@@ -283,6 +285,7 @@ float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; ...@@ -283,6 +285,7 @@ float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
uint8_t active_extruder = 0; uint8_t active_extruder = 0;
uint8_t previous_extruder = 0;
uint8_t active_driver = 0; uint8_t active_driver = 0;
int fanSpeed = 0; int fanSpeed = 0;
...@@ -3011,6 +3014,7 @@ void gcode_get_destination() { ...@@ -3011,6 +3014,7 @@ void gcode_get_destination() {
#if ENABLED(IDLE_OOZING_PREVENT) #if ENABLED(IDLE_OOZING_PREVENT)
if(code_seen(axis_codes[E_AXIS])) IDLE_OOZING_retract(false); if(code_seen(axis_codes[E_AXIS])) IDLE_OOZING_retract(false);
#endif #endif
for (int i = 0; i < NUM_AXIS; i++) { for (int i = 0; i < NUM_AXIS; i++) {
if (code_seen(axis_codes[i])) { if (code_seen(axis_codes[i])) {
destination[i] = code_value() + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0); destination[i] = code_value() + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
...@@ -3019,11 +3023,16 @@ void gcode_get_destination() { ...@@ -3019,11 +3023,16 @@ void gcode_get_destination() {
destination[i] = current_position[i]; destination[i] = current_position[i];
} }
} }
if (code_seen('F')) { if (code_seen('F')) {
float next_feedrate = code_value(); float next_feedrate = code_value();
if (next_feedrate > 0.0) feedrate = next_feedrate; if (next_feedrate > 0.0) feedrate = next_feedrate;
} }
if (code_seen('P')) {
destination[E_AXIS] = (code_value() * density_multiplier[previous_extruder] / 100) + current_position[E_AXIS];
}
printer_usage_filament += (destination[E_AXIS] - current_position[E_AXIS]); printer_usage_filament += (destination[E_AXIS] - current_position[E_AXIS]);
#if ENABLED(NEXTION_GFX) #if ENABLED(NEXTION_GFX)
...@@ -5838,6 +5847,22 @@ inline void gcode_M221() { ...@@ -5838,6 +5847,22 @@ inline void gcode_M221() {
} }
} }
/**
* M222: Set density extrusion percentage (M222 T0 S95)
*/
inline void gcode_M222() {
if (code_seen('S')) {
int sval = code_value();
if (code_seen('T')) {
if (setTargetedHotend(222)) return;
density_multiplier[target_extruder] = sval;
}
else {
density_multiplier[active_extruder] = sval;
}
}
}
/** /**
* M226: Wait until the specified pin reaches the state required (M226 P<pin> S<state>) * M226: Wait until the specified pin reaches the state required (M226 P<pin> S<state>)
*/ */
...@@ -7051,9 +7076,10 @@ inline void gcode_T(uint8_t tmp_extruder) { ...@@ -7051,9 +7076,10 @@ inline void gcode_T(uint8_t tmp_extruder) {
break; break;
} }
#endif // E0E1_CHOICE_PIN E0E2_CHOICE_PIN E1E3_CHOICE_PIN #endif // E0E1_CHOICE_PIN E0E2_CHOICE_PIN E1E3_CHOICE_PIN
previous_extruder = active_extruder;
active_extruder = target_extruder; active_extruder = target_extruder;
ECHO_LMV(DB, SERIAL_ACTIVE_DRIVER, active_driver); ECHO_LMV(DB, SERIAL_ACTIVE_DRIVER, (int)active_driver);
ECHO_LMV(DB, SERIAL_ACTIVE_EXTRUDER, active_extruder); ECHO_LMV(DB, SERIAL_ACTIVE_EXTRUDER, (int)active_extruder);
#elif ENABLED(NPR2) #elif ENABLED(NPR2)
long csteps; long csteps;
st_synchronize(); // Finish all movement st_synchronize(); // Finish all movement
...@@ -7065,6 +7091,7 @@ inline void gcode_T(uint8_t tmp_extruder) { ...@@ -7065,6 +7091,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
} }
if (csteps < 0) colorstep(-csteps, false); if (csteps < 0) colorstep(-csteps, false);
if (csteps > 0) colorstep(csteps, true); if (csteps > 0) colorstep(csteps, true);
previous_extruder = active_extruder;
old_color = active_extruder = target_extruder; old_color = active_extruder = target_extruder;
active_driver = 0; active_driver = 0;
ECHO_LMV(DB, SERIAL_ACTIVE_COLOR, (int)active_extruder); ECHO_LMV(DB, SERIAL_ACTIVE_COLOR, (int)active_extruder);
...@@ -7079,14 +7106,16 @@ inline void gcode_T(uint8_t tmp_extruder) { ...@@ -7079,14 +7106,16 @@ inline void gcode_T(uint8_t tmp_extruder) {
} }
delay_ms(DONDOLO_SERVO_DELAY); delay_ms(DONDOLO_SERVO_DELAY);
servo[DONDOLO_SERVO_INDEX].detach(); servo[DONDOLO_SERVO_INDEX].detach();
previous_extruder = active_extruder;
active_extruder = target_extruder; active_extruder = target_extruder;
active_driver = 0; active_driver = 0;
set_stepper_direction(true); set_stepper_direction(true);
ECHO_LMV(DB, SERIAL_ACTIVE_DRIVER, active_driver); ECHO_LMV(DB, SERIAL_ACTIVE_DRIVER, (int)active_driver);
ECHO_LMV(DB, SERIAL_ACTIVE_EXTRUDER, active_extruder); ECHO_LMV(DB, SERIAL_ACTIVE_EXTRUDER, (int)active_extruder);
#else #else
previous_extruder = active_extruder;
active_driver = active_extruder = target_extruder; active_driver = active_extruder = target_extruder;
ECHO_LMV(DB, SERIAL_ACTIVE_EXTRUDER, active_extruder); ECHO_LMV(DB, SERIAL_ACTIVE_EXTRUDER, (int)active_extruder);
#endif // end MKR4 || NPR2 || DONDOLO #endif // end MKR4 || NPR2 || DONDOLO
#endif // end no DUAL_X_CARRIAGE #endif // end no DUAL_X_CARRIAGE
...@@ -7415,8 +7444,10 @@ void process_next_command() { ...@@ -7415,8 +7444,10 @@ void process_next_command() {
case 220: // M220 S<factor in percent>- set speed factor override percentage case 220: // M220 S<factor in percent>- set speed factor override percentage
gcode_M220(); break; gcode_M220(); break;
case 221: // M221 S<factor in percent>- set extrude factor override percentage case 221: // M221 T<extruder> S<factor in percent>- set extrude factor override percentage
gcode_M221(); break; gcode_M221(); break;
case 222: // M222 T<extruder> S<factor in percent>- set Density extrude factor override percentage
gcode_M222(); break;
case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
gcode_M226(); break; gcode_M226(); break;
......
...@@ -94,6 +94,7 @@ extern bool axis_relative_modes[]; ...@@ -94,6 +94,7 @@ extern bool axis_relative_modes[];
extern int feedrate_multiplier; extern int feedrate_multiplier;
extern bool volumetric_enabled; extern bool volumetric_enabled;
extern int extruder_multiplier[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually extern int extruder_multiplier[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
extern int density_multiplier[EXTRUDERS]; // sets density multiply factor (in percent) for each extruder individually
extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder. extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
extern float current_position[NUM_AXIS]; extern float current_position[NUM_AXIS];
...@@ -210,6 +211,7 @@ extern millis_t print_job_stop_ms; ...@@ -210,6 +211,7 @@ extern millis_t print_job_stop_ms;
// Handling multiple extruders pins // Handling multiple extruders pins
extern uint8_t active_extruder; extern uint8_t active_extruder;
extern uint8_t previous_extruder;
extern uint8_t active_driver; extern uint8_t active_driver;
#if ENABLED(DIGIPOT_I2C) #if ENABLED(DIGIPOT_I2C)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment