mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-09 07:56:24 -06:00
handle klipper set_velocity_limit
This commit is contained in:
parent
258f800b8b
commit
fdb4196ad5
3 changed files with 65 additions and 4 deletions
|
@ -906,6 +906,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("Will export G-code to %1% soon")%path;
|
BOOST_LOG_TRIVIAL(info) << boost::format("Will export G-code to %1% soon")%path;
|
||||||
|
GCodeProcessor::s_IsBBLPrinter = print->is_BBL_printer();
|
||||||
print->set_started(psGCodeExport);
|
print->set_started(psGCodeExport);
|
||||||
|
|
||||||
if (print->is_BBL_printer())
|
if (print->is_BBL_printer())
|
||||||
|
@ -913,7 +914,6 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
||||||
else
|
else
|
||||||
gcode_label_objects = true;
|
gcode_label_objects = true;
|
||||||
|
|
||||||
GCodeProcessor::s_IsBBLPrinter = print->is_BBL_printer();
|
|
||||||
|
|
||||||
// check if any custom gcode contains keywords used by the gcode processor to
|
// check if any custom gcode contains keywords used by the gcode processor to
|
||||||
// produce time estimation and gcode toolpaths
|
// produce time estimation and gcode toolpaths
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#if __has_include(<charconv>)
|
#if __has_include(<charconv>)
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
|
@ -910,7 +911,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
|
||||||
m_result.filament_vitrification_temperature[i] = static_cast<float>(config.temperature_vitrification.get_at(i));
|
m_result.filament_vitrification_temperature[i] = static_cast<float>(config.temperature_vitrification.get_at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) {
|
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfKlipper) {
|
||||||
m_time_processor.machine_limits = reinterpret_cast<const MachineEnvelopeConfig&>(config);
|
m_time_processor.machine_limits = reinterpret_cast<const MachineEnvelopeConfig&>(config);
|
||||||
if (m_flavor == gcfMarlinLegacy) {
|
if (m_flavor == gcfMarlinLegacy) {
|
||||||
// Legacy Marlin does not have separate travel acceleration, it uses the 'extruding' value instead.
|
// Legacy Marlin does not have separate travel acceleration, it uses the 'extruding' value instead.
|
||||||
|
@ -1086,7 +1087,7 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
|
||||||
if (machine_unload_filament_time != nullptr)
|
if (machine_unload_filament_time != nullptr)
|
||||||
m_time_processor.filament_unload_times = static_cast<float>(machine_unload_filament_time->value);
|
m_time_processor.filament_unload_times = static_cast<float>(machine_unload_filament_time->value);
|
||||||
|
|
||||||
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) {
|
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfKlipper) {
|
||||||
const ConfigOptionFloats* machine_max_acceleration_x = config.option<ConfigOptionFloats>("machine_max_acceleration_x");
|
const ConfigOptionFloats* machine_max_acceleration_x = config.option<ConfigOptionFloats>("machine_max_acceleration_x");
|
||||||
if (machine_max_acceleration_x != nullptr)
|
if (machine_max_acceleration_x != nullptr)
|
||||||
m_time_processor.machine_limits.machine_max_acceleration_x.values = machine_max_acceleration_x->values;
|
m_time_processor.machine_limits.machine_max_acceleration_x.values = machine_max_acceleration_x->values;
|
||||||
|
@ -1598,6 +1599,15 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line, bool
|
||||||
m_start_position = m_end_position;
|
m_start_position = m_end_position;
|
||||||
|
|
||||||
const std::string_view cmd = line.cmd();
|
const std::string_view cmd = line.cmd();
|
||||||
|
if (m_flavor == gcfKlipper)
|
||||||
|
{
|
||||||
|
if (boost::iequals(cmd, "SET_VELOCITY_LIMIT"))
|
||||||
|
{
|
||||||
|
process_SET_VELOCITY_LIMIT(line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd.length() > 1) {
|
if (cmd.length() > 1) {
|
||||||
// process command lines
|
// process command lines
|
||||||
switch (cmd[0])
|
switch (cmd[0])
|
||||||
|
@ -3524,7 +3534,7 @@ void GCodeProcessor::process_M203(const GCodeReader::GCodeLine& line)
|
||||||
|
|
||||||
// see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
|
// see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
|
||||||
// http://smoothieware.org/supported-g-codes
|
// http://smoothieware.org/supported-g-codes
|
||||||
float factor = (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfSmoothie) ? 1.0f : MMMIN_TO_MMSEC;
|
float factor = (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfSmoothie || m_flavor == gcfKlipper) ? 1.0f : MMMIN_TO_MMSEC;
|
||||||
|
|
||||||
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||||
if (static_cast<PrintEstimatedStatistics::ETimeMode>(i) == PrintEstimatedStatistics::ETimeMode::Normal ||
|
if (static_cast<PrintEstimatedStatistics::ETimeMode>(i) == PrintEstimatedStatistics::ETimeMode::Normal ||
|
||||||
|
@ -3603,6 +3613,54 @@ void GCodeProcessor::process_M205(const GCodeReader::GCodeLine& line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_SET_VELOCITY_LIMIT(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
// handle SQUARE_CORNER_VELOCITY
|
||||||
|
std::regex pattern("\\sSQUARE_CORNER_VELOCITY\\s*=\\s*([0-9]*\\.*[0-9]*)");
|
||||||
|
std::smatch matches;
|
||||||
|
if (std::regex_search(line.raw(), matches, pattern) && matches.size() == 2) {
|
||||||
|
float _jerk = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_jerk = std::stof(matches[1]);
|
||||||
|
}
|
||||||
|
catch (...){}
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_x, i, _jerk);
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_y, i, _jerk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern = std::regex("\\sACCEL\\s*=\\s*([0-9]*\\.*[0-9]*)");
|
||||||
|
if (std::regex_search(line.raw(), matches, pattern) && matches.size() == 2) {
|
||||||
|
float _accl = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_accl = std::stof(matches[1]);
|
||||||
|
}
|
||||||
|
catch (...) {}
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||||
|
set_acceleration(static_cast<PrintEstimatedStatistics::ETimeMode>(i), _accl);
|
||||||
|
set_travel_acceleration(static_cast<PrintEstimatedStatistics::ETimeMode>(i), _accl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern = std::regex("\\sVELOCITY\\s*=\\s*([0-9]*\\.*[0-9]*)");
|
||||||
|
if (std::regex_search(line.raw(), matches, pattern) && matches.size() == 2) {
|
||||||
|
float _speed = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_speed = std::stof(matches[1]);
|
||||||
|
}
|
||||||
|
catch (...) {}
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_speed_x, i, _speed);
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_speed_y, i, _speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_M221(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_M221(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
float value_s;
|
float value_s;
|
||||||
|
|
|
@ -794,6 +794,9 @@ namespace Slic3r {
|
||||||
// Advanced settings
|
// Advanced settings
|
||||||
void process_M205(const GCodeReader::GCodeLine& line);
|
void process_M205(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Klipper SET_VELOCITY_LIMIT
|
||||||
|
void process_SET_VELOCITY_LIMIT(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
// Set extrude factor override percentage
|
// Set extrude factor override percentage
|
||||||
void process_M221(const GCodeReader::GCodeLine& line);
|
void process_M221(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue