Compare commits

..

No commits in common. "a781743a458439410c621186d4be23ef66482f9b" and "c2d49bbdf01df2aec8cb9641342c20544310f060" have entirely different histories.

5 changed files with 29 additions and 56 deletions

View File

@ -13,8 +13,8 @@ v3.11.2
2. Execute `make` 2. Execute `make`
### Settings ### Settings
* Use without printer config to use linear moves. You should look at +10% Estimation. It's not reliable on prints with lots of infill. * 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 -12.5% Estimation * Alternatively copy `config_example.json` to `config.json` and edit based on your printer settings. You should look at -15% Estimation
### Usage ### Usage
`./gcode_time [file] ...` `./gcode_time [file] ...`
@ -26,4 +26,4 @@ v3.11.2
`+10% - 05:52:11` `+10% - 05:52:11`
`-12.5% - 04:40:09` `-15% - 04:32:09`

View File

@ -226,8 +226,7 @@ void TimeCalc::add_move(Point new_pos, double speed)
double vel; double vel;
double accel; double accel;
double prev_move_idx; double prev_move_idx;
double special_accel; bool is_print;
double de_sum;
static int counter = 0; static int counter = 0;
pos_new[0] = new_pos.x; pos_new[0] = new_pos.x;
@ -275,32 +274,34 @@ void TimeCalc::add_move(Point new_pos, double speed)
cout << "Vel - " << vel << endl; cout << "Vel - " << vel << endl;
#endif #endif
de_sum = 0.0; // Calculate acceleration
temp.clear();
// Is it a print move
is_print = false;
for (int i = 0; i < EXTRUDER_COUNT; ++i) for (int i = 0; i < EXTRUDER_COUNT; ++i)
{ {
de_sum += move_new.delta[3 + i]; if (0.0 != move_new.delta[3 + i])
{
is_print = true;
break;
}
} }
// Set max acceleration for specific move to be considered // Add max acceleration for specific move to be considered
special_accel = 0.0; if (is_print)
if (0.0 == de_sum)
{ {
special_accel = m_travel_accel_max; if (0.0 != m_print_accel_max)
{
temp.push_back(m_print_accel_max);
} }
else if (move_new.dist == de_sum)
{
special_accel = m_retract_accel_max;
} }
else else
{ {
special_accel = m_print_accel_max; if (0.0 != m_travel_accel_max)
}
// Calculate acceleration
temp.clear();
if (0.0 != special_accel)
{ {
temp.push_back(special_accel); temp.push_back(m_travel_accel_max);
}
} }
for (int i = 0 ; i < AXIS_COUNT; ++i) for (int i = 0 ; i < AXIS_COUNT; ++i)
@ -511,8 +512,3 @@ void TimeCalc::set_travel_accel(double value)
{ {
m_travel_accel_max = value; m_travel_accel_max = value;
} }
void TimeCalc::set_retract_accel(double value)
{
m_retract_accel_max = value;
}

View File

@ -35,7 +35,6 @@ private:
double m_print_accel_max; double m_print_accel_max;
double m_travel_accel_max; double m_travel_accel_max;
double m_retract_accel_max;
std::vector<PrinterMove> m_moves; std::vector<PrinterMove> m_moves;
@ -58,7 +57,6 @@ public:
void set_print_accel(double value); void set_print_accel(double value);
void set_travel_accel(double value); void set_travel_accel(double value);
void set_retract_accel(double value);
}; };
#endif // TIMECALC_H_ #endif // TIMECALC_H_

View File

@ -3,7 +3,6 @@
{ {
"print": 500, "print": 500,
"travel": 1000, "travel": 1000,
"retract": 1000,
"x": 500, "x": 500,
"y": 500, "y": 500,
"z": 100, "z": 100,

View File

@ -9,12 +9,6 @@
#include "gcode.h" #include "gcode.h"
#include "json.hpp" #include "json.hpp"
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#define FOLDER_DELIM '\\'
#else
#define FOLDER_DELIM '/'
#endif
using namespace std; using namespace std;
void usage(char *name) void usage(char *name)
@ -139,24 +133,18 @@ void print_time(double sec)
printf("%02d:%02d:%02.0f", hours, min, sec); printf("%02d:%02d:%02.0f", hours, min, sec);
} }
void init_calc(string arg0, TimeCalc& calc) void init_calc(TimeCalc& calc)
{ {
ifstream file; ifstream file("config.json");
size_t pos;
nlohmann::json conf; nlohmann::json conf;
vector<string> conf_keys_types = {"acceleration", "velocity", "jerk"}; vector<string> conf_keys_types = {"acceleration", "velocity", "jerk"};
vector<string> conf_keys_axes = {"x", "y", "z"}; vector<string> conf_keys_axes = {"x", "y", "z"};
pos = arg0.rfind(FOLDER_DELIM);
arg0.erase(pos + 1);
arg0 += "config.json";
file.open(arg0);
if (!file.is_open()) if (!file.is_open())
{ {
return; return;
} }
try try
{ {
file >> conf; file >> conf;
@ -237,14 +225,6 @@ void init_calc(string arg0, TimeCalc& calc)
{ {
calc.set_travel_accel(conf["acceleration"]["travel"]); 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"]);
}
} }
} }
@ -274,7 +254,7 @@ int main(int argc, char **argv)
for (string& fname : filenames) for (string& fname : filenames)
{ {
calc.reset(); calc.reset();
init_calc(argv[0], calc); init_calc(calc);
speed = 0; speed = 0;
file.open(fname); file.open(fname);
@ -315,8 +295,8 @@ int main(int argc, char **argv)
print_time(total_time * 1.1); print_time(total_time * 1.1);
cout << endl; cout << endl;
cout << "-12.5% - "; cout << "-15% - ";
print_time(total_time * 0.875); print_time(total_time * 0.85);
cout << endl; cout << endl;
} }
return 0; return 0;