From fc3af0533a2f51cddb179531e4f57a1b1a5fd6ea Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 5 Mar 2018 21:31:31 +0100 Subject: [PATCH] Fix of calculate_extrusion_multipliers(). This is a fix of a bug made in the previous commit. --- Firmware/ConfigurationStore.cpp | 2 +- Firmware/Marlin_main.cpp | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 253452fe..26cbc822 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -378,8 +378,8 @@ bool Config_RetrieveSettings(uint16_t offset, uint8_t level) EEPROM_READ_VAR(i, extruder_advance_k); EEPROM_READ_VAR(i, advance_ed_ratio); } - calculate_volumetric_multipliers(); #endif //LIN_ADVANCE + calculate_extruder_multipliers(); // Call updatePID (similar to when we have processed M301) updatePID(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 198a28be..60afe10a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7026,11 +7026,14 @@ void save_statistics(unsigned long _total_filament_used, unsigned long _total_pr } float calculate_extruder_multiplier(float diameter) { - bool enabled = volumetric_enabled && diameter > 0; - float area = enabled ? (M_PI * pow(diameter * .5, 2)) : 0; - return (extrudemultiply == 100) ? - (enabled ? (1.f / area) : 1.f) : - (enabled ? ((float(extrudemultiply) * 0.01f) / area) : 1.f); + float out = 1.f; + if (volumetric_enabled && diameter > 0.f) { + float area = M_PI * diameter * diameter * 0.25; + out = 1.f / area; + } + if (extrudemultiply != 100) + out *= float(extrudemultiply) * 0.01f; + return out; } void calculate_extruder_multipliers() {