Commit 697bf4bc authored by MagoKimbra's avatar MagoKimbra

Merge remote-tracking branch 'refs/remotes/origin/master' into dev

parents 3eb34342 2e716a35
...@@ -405,12 +405,16 @@ ...@@ -405,12 +405,16 @@
*********************************************************************** ***********************************************************************
* * * *
* Extends G0/G1 with mixing factors ABCDHI for up to 6 steppers. * * Extends G0/G1 with mixing factors ABCDHI for up to 6 steppers. *
* Adds a new code, M223, to set the current mix factors. * * Adds a new code, M165, to set the current mix factors. *
* Optional support for Repetier Host M163, M164, and virtual tools. *
* Extends the stepping routines to move multiple steppers in * * Extends the stepping routines to move multiple steppers in *
* proportion to the mix. * * proportion to the mix. *
* * * *
***********************************************************************/ ***********************************************************************/
//#define COLOR_MIXING_EXTRUDER //#define COLOR_MIXING_EXTRUDER
// Use the Virtual Tool method with M163 and M164
#define MIXING_VIRTUAL_TOOLS 16
/***********************************************************************/ /***********************************************************************/
...@@ -1077,7 +1081,7 @@ ...@@ -1077,7 +1081,7 @@
#define SHOW_BOOTSCREEN #define SHOW_BOOTSCREEN
#define STRING_SPLASH_LINE1 "v" SHORT_BUILD_VERSION // will be shown during bootup in line 1 #define STRING_SPLASH_LINE1 "v" SHORT_BUILD_VERSION // will be shown during bootup in line 1
//#define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE // will be shown during bootup in line 2 #define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE // will be shown during bootup in line 2
#define SPLASH_SCREEN_DURATION 5000 // SPLASH SCREEN duration in millisecond #define SPLASH_SCREEN_DURATION 5000 // SPLASH SCREEN duration in millisecond
//#define LCD_SCREEN_ROT_90 //Rotate screen orientation for graphics display by 90 degree clockwise //#define LCD_SCREEN_ROT_90 //Rotate screen orientation for graphics display by 90 degree clockwise
......
...@@ -115,6 +115,9 @@ ...@@ -115,6 +115,9 @@
* M140 - Set bed target temp * M140 - Set bed target temp
* M145 - Set the heatup state H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS) * M145 - Set the heatup state H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
* M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. * M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work.
* M163 - Set a single proportion for a mixing extruder. Requires COLOR_MIXING_EXTRUDER.
* M164 - Save the mix as a virtual extruder. Requires COLOR_MIXING_EXTRUDER and MIXING_VIRTUAL_TOOLS.
* M165 - Set the proportions for a mixing extruder. Use parameters ABCDHI to set the mixing factors. Requires COLOR_MIXING_EXTRUDER.
* M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating * M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
* Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling * Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
* M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).:D<millimeters>- * M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).:D<millimeters>-
...@@ -131,7 +134,6 @@ ...@@ -131,7 +134,6 @@
* 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 for purge: S<factor in percent> * M222 - Set density extrusion percentage for purge: S<factor in percent>
* M223 - Set the mix factors for a mixing extruder: <ABCDHI>
* 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)
......
...@@ -246,7 +246,10 @@ double printer_usage_filament; ...@@ -246,7 +246,10 @@ double printer_usage_filament;
#endif #endif
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
float mixing_factor[DRIVER_EXTRUDERS] = { 1.0 / DRIVER_EXTRUDERS }; float mixing_factor[DRIVER_EXTRUDERS];
#if MIXING_VIRTUAL_TOOLS > 1
float mixing_virtual_tool_mix[MIXING_VIRTUAL_TOOLS][DRIVER_EXTRUDERS];
#endif
#endif #endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
...@@ -669,6 +672,18 @@ void setup() { ...@@ -669,6 +672,18 @@ void setup() {
setup_statled(); setup_statled();
#endif #endif
#if ENABLED(MIXING_EXTRUDER_FEATURE) && MIXING_VIRTUAL_TOOLS > 1
// Initialize mixing to 100% color 1
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) {
mixing_factor[i] = (i == 0) ? 1 : 0;
}
for (int8_t t = 0; t < MIXING_VIRTUAL_TOOLS; t++) {
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) {
mixing_virtual_tool_mix[t][i] = mixing_factor[i];
}
}
#endif
#if ENABLED(RFID_MODULE) #if ENABLED(RFID_MODULE)
RFID_ON = RFID522.init(); RFID_ON = RFID522.init();
if (RFID_ON) if (RFID_ON)
...@@ -2532,26 +2547,34 @@ static void clean_up_after_endstop_move() { ...@@ -2532,26 +2547,34 @@ static void clean_up_after_endstop_move() {
#endif //DELTA #endif //DELTA
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
// Get mixing parameters from the GCode void normalize_mix() {
// Factors that are left out are set to 0
// The total "must" be 1.0 (but it will be normalized)
void gcode_get_mix() {
const char* mixing_codes = "ABCDHI";
float mix_total = 0.0; float mix_total = 0.0;
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) { for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) {
float v = code_seen(mixing_codes[i]) ? code_value() : mixing_factor[i]; float v = mixing_factor[i];
mixing_factor[i] = v; if (v < 0) v = mixing_factor[i] = 0;
mix_total += v; mix_total += v;
} }
// Scale values if they don't add up to ~1.0 // Scale all values if they don't add up to ~1.0
if (mix_total < 0.9999 || mix_total > 1.0001) { if (mix_total < 0.9999 || mix_total > 1.0001) {
ECHO_EM("Warning: Mix factors must add up to 1.0. Scaling."); ECHO_EM("Warning: Mix factors must add up to 1.0. Scaling.");
float mix_scale = 1.0 / mix_total; float mix_scale = 1.0 / mix_total;
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) {
mixing_factor[i] *= mix_scale; mixing_factor[i] *= mix_scale;
} }
} }
}
// Get mixing parameters from the GCode
// Factors that are left out are set to 0
// The total "must" be 1.0 (but it will be normalized)
void gcode_get_mix() {
const char* mixing_codes = "ABCDHI";
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) {
mixing_factor[i] = code_seen(mixing_codes[i]) ? code_value() : 0;
}
normalize_mix();
}
#endif #endif
#if ENABLED(IDLE_OOZING_PREVENT) #if ENABLED(IDLE_OOZING_PREVENT)
...@@ -5264,7 +5287,6 @@ inline void gcode_M122() { ...@@ -5264,7 +5287,6 @@ inline void gcode_M122() {
*/ */
inline void gcode_M129() { EtoPPressure = 0; } inline void gcode_M129() { EtoPPressure = 0; }
#endif #endif
#endif //BARICUDA #endif //BARICUDA
/** /**
...@@ -5276,7 +5298,6 @@ inline void gcode_M140() { ...@@ -5276,7 +5298,6 @@ inline void gcode_M140() {
} }
#if ENABLED(ULTIPANEL) && TEMP_SENSOR_0 != 0 #if ENABLED(ULTIPANEL) && TEMP_SENSOR_0 != 0
/** /**
* M145: Set the heatup state for a material in the LCD menu * M145: Set the heatup state for a material in the LCD menu
* S<material> (0=PLA, 1=ABS, 2=GUM) * S<material> (0=PLA, 1=ABS, 2=GUM)
...@@ -5355,7 +5376,6 @@ inline void gcode_M140() { ...@@ -5355,7 +5376,6 @@ inline void gcode_M140() {
} }
} }
} }
#endif #endif
#if ENABLED(BLINKM) #if ENABLED(BLINKM)
...@@ -5372,6 +5392,55 @@ inline void gcode_M140() { ...@@ -5372,6 +5392,55 @@ inline void gcode_M140() {
#endif // BLINKM #endif // BLINKM
#if ENABLED(COLOR_MIXING_EXTRUDER)
/**
* M163: Set a single mix factor for a mixing extruder
* This is called "weight" by some systems.
*
* S[index] The channel index to set
* P[float] The mix value
*
*/
inline void gcode_M163() {
int mix_index = code_seen('S') ? code_value_short() : 0;
float mix_value = code_seen('P') ? code_value() : 0.0;
if (mix_index < DRIVER_EXTRUDERS) mixing_factor[mix_index] = mix_value;
}
#if MIXING_VIRTUAL_TOOLS > 1
/**
* M164: Store the current mix factors as a virtual tools.
*
* S[index] The virtual tools to store
*
*/
inline void gcode_M164() {
int tool_index = code_seen('S') ? code_value_short() : 0;
if (tool_index < MIXING_VIRTUAL_TOOLS) {
normalize_mix();
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) {
mixing_virtual_tool_mix[tool_index][i] = mixing_factor[i];
}
}
}
#endif
/**
* M165: Set multiple mix factors for a mixing extruder.
* Factors that are left out will be set to 0.
* All factors together must add up to 1.0.
*
* A[factor] Mix factor for extruder stepper 1
* B[factor] Mix factor for extruder stepper 2
* C[factor] Mix factor for extruder stepper 3
* D[factor] Mix factor for extruder stepper 4
* H[factor] Mix factor for extruder stepper 5
* I[factor] Mix factor for extruder stepper 6
*
*/
inline void gcode_M165() { gcode_get_mix(); }
#endif // COLOR_MIXING_EXTRUDER
#if HAS(TEMP_BED) #if HAS(TEMP_BED)
/** /**
* M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating * M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating
...@@ -5538,7 +5607,6 @@ inline void gcode_M206() { ...@@ -5538,7 +5607,6 @@ inline void gcode_M206() {
} }
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
/** /**
* M207: Set firmware retraction values * M207: Set firmware retraction values
* *
...@@ -5646,23 +5714,6 @@ inline void gcode_M222() { ...@@ -5646,23 +5714,6 @@ inline void gcode_M222() {
} }
} }
#if ENABLED(COLOR_MIXING_EXTRUDER)
/**
* M223: Set the mix factors for a mixing extruder.
* Factors that are left out will be set to 0.
* All factors together must add up to 1.0.
*
* A[factor] Mix factor for extruder stepper 1
* B[factor] Mix factor for extruder stepper 2
* C[factor] Mix factor for extruder stepper 3
* D[factor] Mix factor for extruder stepper 4
* H[factor] Mix factor for extruder stepper 5
* I[factor] Mix factor for extruder stepper 6
*
*/
inline void gcode_M223() { gcode_get_mix(); }
#endif
/** /**
* 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>)
*/ */
...@@ -5807,9 +5858,7 @@ inline void gcode_M226() { ...@@ -5807,9 +5858,7 @@ inline void gcode_M226() {
#endif // HAS(BUZZER) #endif // HAS(BUZZER)
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
/** /**
* M301: Set PID parameters P I D (and optionally C, L) * M301: Set PID parameters P I D (and optionally C, L)
* *
...@@ -5855,7 +5904,6 @@ inline void gcode_M226() { ...@@ -5855,7 +5904,6 @@ inline void gcode_M226() {
#endif // PIDTEMP #endif // PIDTEMP
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE) #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
void set_extrude_min_temp(float temp) { extrude_min_temp = temp; } void set_extrude_min_temp(float temp) { extrude_min_temp = temp; }
/** /**
...@@ -5864,7 +5912,6 @@ inline void gcode_M226() { ...@@ -5864,7 +5912,6 @@ inline void gcode_M226() {
inline void gcode_M302() { inline void gcode_M302() {
set_extrude_min_temp(code_seen('S') ? code_value() : 0); set_extrude_min_temp(code_seen('S') ? code_value() : 0);
} }
#endif // PREVENT_DANGEROUS_EXTRUDE #endif // PREVENT_DANGEROUS_EXTRUDE
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)
...@@ -6657,11 +6704,23 @@ inline void gcode_M999() { ...@@ -6657,11 +6704,23 @@ inline void gcode_M999() {
* F[mm/min] Set the movement feedrate * F[mm/min] Set the movement feedrate
*/ */
inline void gcode_T(uint8_t tmp_extruder) { inline void gcode_T(uint8_t tmp_extruder) {
if (tmp_extruder >= EXTRUDERS) { bool good_extruder = false;
ECHO_SMV(DB, "T", (int)tmp_extruder);
ECHO_EM(" " SERIAL_INVALID_EXTRUDER); #if ENABLED(COLOR_MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
// T0-T15: Switch virtual tool by changing the mix
if (tmp_extruder < MIXING_VIRTUAL_TOOLS) {
good_extruder = true;
for (int8_t j = 0; j < DRIVER_EXTRUDERS; j++) {
mixing_factor[j] = mixing_virtual_tool_mix[tmp_extruder][j];
} }
else { ECHO_LMV(DB, SERIAL_ACTIVE_COLOR, (int)tmp_extruder);
}
#else // !COLOR_MIXING_EXTRUDER && MIXING_VIRTUAL_TOOLS
if (tmp_extruder < EXTRUDERS) {
good_extruder = true;
target_extruder = tmp_extruder; target_extruder = tmp_extruder;
#if ENABLED(DONDOLO) #if ENABLED(DONDOLO)
...@@ -6944,6 +7003,12 @@ inline void gcode_T(uint8_t tmp_extruder) { ...@@ -6944,6 +7003,12 @@ inline void gcode_T(uint8_t tmp_extruder) {
#endif // EXTRUDERS > 1 #endif // EXTRUDERS > 1
} }
#endif // !COLOR_MIXING_EXTRUDER
if (!good_extruder) {
ECHO_SMV(DB, "T", (int)tmp_extruder);
ECHO_EM(" " SERIAL_INVALID_EXTRUDER);
}
} }
/** /**
...@@ -7205,6 +7270,17 @@ void process_next_command() { ...@@ -7205,6 +7270,17 @@ void process_next_command() {
gcode_M150(); break; gcode_M150(); break;
#endif //BLINKM #endif //BLINKM
#if ENABLED(COLOR_MIXING_EXTRUDER)
case 163: // M163 S<int> P<float> set weight for a mixing extruder
gcode_M163(); break;
#if MIXING_VIRTUAL_TOOLS > 1
case 164: // M164 S<int> save current mix as a virtual tools
gcode_M164(); break;
#endif
case 165: // M165 [ABCDHI]<float> set multiple mix weights
gcode_M165(); break;
#endif
#if HAS(TEMP_BED) #if HAS(TEMP_BED)
case 190: // M190 - Wait for bed heater to reach target. case 190: // M190 - Wait for bed heater to reach target.
gcode_M190(); break; gcode_M190(); break;
...@@ -7248,12 +7324,6 @@ void process_next_command() { ...@@ -7248,12 +7324,6 @@ void process_next_command() {
gcode_M221(); break; gcode_M221(); break;
case 222: // M222 T<extruder> S<factor in percent> - set density extrude factor percentage for purge case 222: // M222 T<extruder> S<factor in percent> - set density extrude factor percentage for purge
gcode_M222(); break; gcode_M222(); break;
#if ENABLED(COLOR_MIXING_EXTRUDER)
case 223: // M223 Set the mix factors for a mixing extruder
gcode_M223(); break;
#endif
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;
......
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
/** /**
* DRIVER_EXTRUDERS * DRIVER_EXTRUDERS
*/ */
#if DISABLED(MKR4) && DISABLED(NPR2) && DISABLED(DONDOLO) #if DISABLED(MKR4) && DISABLED(NPR2) && DISABLED(DONDOLO) && DISABLED(COLOR_MIXING_EXTRUDER)
#undef DRIVER_EXTRUDERS #undef DRIVER_EXTRUDERS
#define DRIVER_EXTRUDERS EXTRUDERS // This defines the number of Driver extruder #define DRIVER_EXTRUDERS EXTRUDERS // This defines the number of Driver extruder
#endif #endif
......
...@@ -271,6 +271,18 @@ ...@@ -271,6 +271,18 @@
#endif #endif
#endif #endif
#if ENABLED(COLOR_MIXING_EXTRUDER)
#if EXTRUDERS > 1
#error COLOR_MIXING_EXTRUDER supports plus one extruder.
#endif
#if DRIVER_EXTRUDERS < 2
#error You must set DRIVER_EXTRUDERS >= 2 for a mixing extruder.
#endif
#if ENABLED(FILAMENT_SENSOR)
#error COLOR_MIXING_EXTRUDER is incompatible with FILAMENT_SENSOR. Comment out this line to use it anyway.
#endif
#endif
#if ENABLED(NPR2) #if ENABLED(NPR2)
#if DISABLED(COLOR_STEP) #if DISABLED(COLOR_STEP)
#error DEPENDENCY ERROR: Missing setting COLOR_STEP #error DEPENDENCY ERROR: Missing setting COLOR_STEP
......
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