Commit 2e716a35 authored by MagoKimbra's avatar MagoKimbra

Same fix

parent 947ed498
......@@ -405,12 +405,16 @@
***********************************************************************
* *
* 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 *
* proportion to the mix. *
* *
***********************************************************************/
//#define COLOR_MIXING_EXTRUDER
// Use the Virtual Tool method with M163 and M164
#define MIXING_VIRTUAL_TOOLS 16
/***********************************************************************/
......@@ -1077,7 +1081,7 @@
#define SHOW_BOOTSCREEN
#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 LCD_SCREEN_ROT_90 //Rotate screen orientation for graphics display by 90 degree clockwise
......
......@@ -115,6 +115,9 @@
* M140 - Set bed target temp
* 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.
* 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
* 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>-
......@@ -131,7 +134,6 @@
* M220 - Set speed 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>
* 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>
* M240 - Trigger a camera to take a photograph
* M250 - Set LCD contrast C<contrast value> (value 0..63)
......
......@@ -246,7 +246,10 @@ double printer_usage_filament;
#endif
#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
#if ENABLED(SDSUPPORT)
......@@ -669,6 +672,18 @@ void setup() {
setup_statled();
#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)
RFID_ON = RFID522.init();
if (RFID_ON)
......@@ -2532,26 +2547,34 @@ static void clean_up_after_endstop_move() {
#endif //DELTA
#if ENABLED(COLOR_MIXING_EXTRUDER)
// 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";
void normalize_mix() {
float mix_total = 0.0;
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) {
float v = code_seen(mixing_codes[i]) ? code_value() : mixing_factor[i];
mixing_factor[i] = v;
float v = mixing_factor[i];
if (v < 0) v = mixing_factor[i] = 0;
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) {
ECHO_EM("Warning: Mix factors must add up to 1.0. Scaling.");
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;
}
}
}
// 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
#if ENABLED(IDLE_OOZING_PREVENT)
......@@ -5264,7 +5287,6 @@ inline void gcode_M122() {
*/
inline void gcode_M129() { EtoPPressure = 0; }
#endif
#endif //BARICUDA
/**
......@@ -5276,7 +5298,6 @@ inline void gcode_M140() {
}
#if ENABLED(ULTIPANEL) && TEMP_SENSOR_0 != 0
/**
* M145: Set the heatup state for a material in the LCD menu
* S<material> (0=PLA, 1=ABS, 2=GUM)
......@@ -5355,7 +5376,6 @@ inline void gcode_M140() {
}
}
}
#endif
#if ENABLED(BLINKM)
......@@ -5372,6 +5392,55 @@ inline void gcode_M140() {
#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)
/**
* M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating
......@@ -5538,7 +5607,6 @@ inline void gcode_M206() {
}
#if ENABLED(FWRETRACT)
/**
* M207: Set firmware retraction values
*
......@@ -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>)
*/
......@@ -5807,9 +5858,7 @@ inline void gcode_M226() {
#endif // HAS(BUZZER)
#if ENABLED(PIDTEMP)
/**
* M301: Set PID parameters P I D (and optionally C, L)
*
......@@ -5855,7 +5904,6 @@ inline void gcode_M226() {
#endif // PIDTEMP
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
void set_extrude_min_temp(float temp) { extrude_min_temp = temp; }
/**
......@@ -5864,7 +5912,6 @@ inline void gcode_M226() {
inline void gcode_M302() {
set_extrude_min_temp(code_seen('S') ? code_value() : 0);
}
#endif // PREVENT_DANGEROUS_EXTRUDE
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)
......@@ -6657,11 +6704,23 @@ inline void gcode_M999() {
* F[mm/min] Set the movement feedrate
*/
inline void gcode_T(uint8_t tmp_extruder) {
if (tmp_extruder >= EXTRUDERS) {
ECHO_SMV(DB, "T", (int)tmp_extruder);
ECHO_EM(" " SERIAL_INVALID_EXTRUDER);
bool good_extruder = false;
#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;
#if ENABLED(DONDOLO)
......@@ -6944,6 +7003,12 @@ inline void gcode_T(uint8_t tmp_extruder) {
#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() {
gcode_M150(); break;
#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)
case 190: // M190 - Wait for bed heater to reach target.
gcode_M190(); break;
......@@ -7248,12 +7324,6 @@ void process_next_command() {
gcode_M221(); break;
case 222: // M222 T<extruder> S<factor in percent> - set density extrude factor percentage for purge
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
gcode_M226(); break;
......
......@@ -253,7 +253,7 @@
/**
* DRIVER_EXTRUDERS
*/
#if DISABLED(MKR4) && DISABLED(NPR2) && DISABLED(DONDOLO)
#if DISABLED(MKR4) && DISABLED(NPR2) && DISABLED(DONDOLO) && DISABLED(COLOR_MIXING_EXTRUDER)
#undef DRIVER_EXTRUDERS
#define DRIVER_EXTRUDERS EXTRUDERS // This defines the number of Driver extruder
#endif
......
......@@ -271,6 +271,18 @@
#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 DISABLED(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