From bca884bf72b7c785caf4b1e039e2a092238fcde8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 2 Feb 2015 04:41:31 -0800 Subject: [PATCH 1/4] Realized it's not a bug, but cleanup code anyway --- Marlin/Marlin_main.cpp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 247b186e7c..fc9908c0bb 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2893,26 +2893,24 @@ Sigma_Exit: float area = .0; if(code_seen('D')) { - float diameter = (float)code_value(); - if (diameter == 0.0) { - // setting any extruder filament size disables volumetric on the assumption that - // slicers either generate in extruder values as cubic mm or as as filament feeds - // for all extruders - volumetric_enabled = false; - } else { - filament_size[tmp_extruder] = (float)code_value(); + float diameter = code_value(); + // setting any extruder filament size disables volumetric on the assumption that + // slicers either generate in extruder values as cubic mm or as as filament feeds + // for all extruders + volumetric_enabled = (diameter != 0.0); + if (volumetric_enabled) { + filament_size[tmp_extruder] = diameter; // make sure all extruders have some sane value for the filament size - filament_size[0] = (filament_size[0] == 0.0 ? DEFAULT_NOMINAL_FILAMENT_DIA : filament_size[0]); -#if EXTRUDERS > 1 - filament_size[1] = (filament_size[1] == 0.0 ? DEFAULT_NOMINAL_FILAMENT_DIA : filament_size[1]); -#if EXTRUDERS > 2 - filament_size[2] = (filament_size[2] == 0.0 ? DEFAULT_NOMINAL_FILAMENT_DIA : filament_size[2]); -#if EXTRUDERS > 3 - filament_size[3] = (filament_size[3] == 0.0 ? DEFAULT_NOMINAL_FILAMENT_DIA : filament_size[3]); -#endif //EXTRUDERS > 3 -#endif //EXTRUDERS > 2 -#endif //EXTRUDERS > 1 - volumetric_enabled = true; + if (! filament_size[0]) filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA; + #if EXTRUDERS > 1 + if (! filament_size[1]) filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA; + #if EXTRUDERS > 2 + if (! filament_size[2]) filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA; + #if EXTRUDERS > 3 + if (! filament_size[3]) filament_size[3] = DEFAULT_NOMINAL_FILAMENT_DIA; + #endif + #endif + #endif } } else { //reserved for setting filament diameter via UFID or filament measuring device From 4a146d584b077dfdeff59162e7215a0cf9447b1b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 2 Feb 2015 05:16:17 -0800 Subject: [PATCH 2/4] Loop, since the pending feature can use an array --- Marlin/Marlin_main.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index fc9908c0bb..ab44c1c23c 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2901,16 +2901,8 @@ Sigma_Exit: if (volumetric_enabled) { filament_size[tmp_extruder] = diameter; // make sure all extruders have some sane value for the filament size - if (! filament_size[0]) filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA; - #if EXTRUDERS > 1 - if (! filament_size[1]) filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA; - #if EXTRUDERS > 2 - if (! filament_size[2]) filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA; - #if EXTRUDERS > 3 - if (! filament_size[3]) filament_size[3] = DEFAULT_NOMINAL_FILAMENT_DIA; - #endif - #endif - #endif + for (int i=EXTRUDERS; i--;) + if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA; } } else { //reserved for setting filament diameter via UFID or filament measuring device From bd387068bba0d996cae198e7aa417ff210bb4dba Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 2 Feb 2015 05:27:27 -0800 Subject: [PATCH 3/4] Apply loops for extruders elsewhere also --- Marlin/Marlin_main.cpp | 43 ++++++------------------------------------ 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ab44c1c23c..81b2796a82 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3021,33 +3021,11 @@ Sigma_Exit: int t= code_value() ; switch(t) { - case 0: - { - autoretract_enabled=false; - retracted[0]=false; -#if EXTRUDERS > 1 - retracted[1]=false; -#endif -#if EXTRUDERS > 2 - retracted[2]=false; -#endif -#if EXTRUDERS > 3 - retracted[3]=false; -#endif - }break; - case 1: + case 0: + case 1: { - autoretract_enabled=true; - retracted[0]=false; -#if EXTRUDERS > 1 - retracted[1]=false; -#endif -#if EXTRUDERS > 2 - retracted[2]=false; -#endif -#if EXTRUDERS > 3 - retracted[3]=false; -#endif + autoretract_enabled = (t == 1); + for (int i=EXTRUDERS; i--;) retracted[i] = false; }break; default: SERIAL_ECHO_START; @@ -4686,15 +4664,6 @@ float calculate_volumetric_multiplier(float diameter) { } void calculate_volumetric_multipliers() { - volumetric_multiplier[0] = calculate_volumetric_multiplier(filament_size[0]); -#if EXTRUDERS > 1 - volumetric_multiplier[1] = calculate_volumetric_multiplier(filament_size[1]); -#if EXTRUDERS > 2 - volumetric_multiplier[2] = calculate_volumetric_multiplier(filament_size[2]); -#if EXTRUDERS > 3 - volumetric_multiplier[3] = calculate_volumetric_multiplier(filament_size[3]); -#endif //EXTRUDERS > 3 -#endif //EXTRUDERS > 2 -#endif //EXTRUDERS > 1 + for (int i=EXTRUDERS; i--;) + volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]); } - From 9dc5de61669e9d0850b72d80e1d53765457109a7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 2 Feb 2015 05:55:55 -0800 Subject: [PATCH 4/4] Hide code that makes veteran geeks go "aha!" --- Marlin/Marlin_main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 81b2796a82..cff7ee6bf2 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2901,7 +2901,7 @@ Sigma_Exit: if (volumetric_enabled) { filament_size[tmp_extruder] = diameter; // make sure all extruders have some sane value for the filament size - for (int i=EXTRUDERS; i--;) + for (int i=0; i