diff --git a/README.md b/README.md index de16644..6738963 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ v3.11.2 2. Execute `make` ### Settings -* Use without printer config to use linear moves. You should look at +10% Estimation -* Alternatively copy `config_example.json` to `config.json` and edit based on your printer settings. You should look at -15% Estimation +* Use without printer config to use linear moves. You should look at +10% Estimation. It's not reliable on prints with lots of infill. +* Alternatively copy `config_example.json` to `config.json` and edit based on your printer settings. You should look at -12.5% Estimation ### Usage `./gcode_time [file] ...` @@ -26,4 +26,4 @@ v3.11.2 `+10% - 05:52:11` -`-15% - 04:32:09` +`-12.5% - 04:40:09` diff --git a/TimeCalc.cpp b/TimeCalc.cpp index 9ee23f0..b278f55 100644 --- a/TimeCalc.cpp +++ b/TimeCalc.cpp @@ -226,7 +226,8 @@ void TimeCalc::add_move(Point new_pos, double speed) double vel; double accel; double prev_move_idx; - bool is_print; + double special_accel; + double de_sum; static int counter = 0; pos_new[0] = new_pos.x; @@ -274,34 +275,32 @@ void TimeCalc::add_move(Point new_pos, double speed) cout << "Vel - " << vel << endl; #endif - // Calculate acceleration - temp.clear(); - - // Is it a print move - is_print = false; + de_sum = 0.0; for (int i = 0; i < EXTRUDER_COUNT; ++i) { - if (0.0 != move_new.delta[3 + i]) - { - is_print = true; - break; - } + de_sum += move_new.delta[3 + i]; } - // Add max acceleration for specific move to be considered - if (is_print) + // Set max acceleration for specific move to be considered + special_accel = 0.0; + if (0.0 == de_sum) { - if (0.0 != m_print_accel_max) - { - temp.push_back(m_print_accel_max); - } + special_accel = m_travel_accel_max; + } + else if (move_new.dist == de_sum) + { + special_accel = m_retract_accel_max; } else { - if (0.0 != m_travel_accel_max) - { - temp.push_back(m_travel_accel_max); - } + special_accel = m_print_accel_max; + } + + // Calculate acceleration + temp.clear(); + if (0.0 != special_accel) + { + temp.push_back(special_accel); } for (int i = 0 ; i < AXIS_COUNT; ++i) @@ -512,3 +511,8 @@ void TimeCalc::set_travel_accel(double value) { m_travel_accel_max = value; } + +void TimeCalc::set_retract_accel(double value) +{ + m_retract_accel_max = value; +} diff --git a/TimeCalc.h b/TimeCalc.h index 96f8398..e41d95f 100644 --- a/TimeCalc.h +++ b/TimeCalc.h @@ -35,6 +35,7 @@ private: double m_print_accel_max; double m_travel_accel_max; + double m_retract_accel_max; std::vector m_moves; @@ -57,6 +58,7 @@ public: void set_print_accel(double value); void set_travel_accel(double value); + void set_retract_accel(double value); }; #endif // TIMECALC_H_ diff --git a/config_example.json b/config_example.json index 8f1c543..9dcd840 100644 --- a/config_example.json +++ b/config_example.json @@ -3,6 +3,7 @@ { "print": 500, "travel": 1000, + "retract": 1000, "x": 500, "y": 500, "z": 100, diff --git a/main.cpp b/main.cpp index c60d775..76c600a 100644 --- a/main.cpp +++ b/main.cpp @@ -225,6 +225,14 @@ void init_calc(TimeCalc& calc) { calc.set_travel_accel(conf["acceleration"]["travel"]); } + + // Set Retract Acceleration + if (conf.contains("acceleration") && + conf["acceleration"].contains("retract") && + conf["acceleration"]["retract"].is_number()) + { + calc.set_retract_accel(conf["acceleration"]["retract"]); + } } } @@ -295,8 +303,8 @@ int main(int argc, char **argv) print_time(total_time * 1.1); cout << endl; - cout << "-15% - "; - print_time(total_time * 0.85); + cout << "-12.5% - "; + print_time(total_time * 0.875); cout << endl; } return 0;