belt: adapt BeltGCodeWriter to upstream's per-extruder speed options

Upstream retyped travel_speed and travel_speed_z to ConfigOptionFloatsNullable
and initial_layer_travel_speed to ConfigOptionFloatsOrPercentsNullable, so the
scalar .value / get_abs_value() accessors no longer compile. BeltGCodeWriter.cpp
is belt-only and merged without conflict, so this only surfaced at build time.

Index them the way the base GCodeWriter does -- .get_at(m_cached_extruder_idx)
and get_abs_value_at(..., m_cached_extruder_idx) -- keeping belt's per-point
first_layer_for_point test rather than the base class's m_is_first_layer.

m_cached_extruder_idx moves from private to the existing protected block that
already exposes writer state to subclasses, so the belt writer resolves the
per-extruder index identically to the base writer instead of guessing one.
This commit is contained in:
harrierpigeon
2026-08-02 16:20:22 -05:00
parent 175075fd08
commit b61ba98183
2 changed files with 13 additions and 9 deletions

View File

@@ -87,7 +87,8 @@ std::string BeltGCodeWriter::travel_to_xy(const Vec2d &point, const std::string
m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer, m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer,
Vec3d(point.x(), point.y(), m_pos.z())); Vec3d(point.x(), point.y(), m_pos.z()));
auto speed = first_layer_for_point auto speed = first_layer_for_point
? this->config.get_abs_value("initial_layer_travel_speed") : this->config.travel_speed.value; ? this->config.get_abs_value_at("initial_layer_travel_speed", m_cached_extruder_idx)
: this->config.travel_speed.get_at(m_cached_extruder_idx);
w.emit_f(speed * 60.0); w.emit_f(speed * 60.0);
w.emit_comment(GCodeWriter::full_gcode_comment, comment); w.emit_comment(GCodeWriter::full_gcode_comment, comment);
return w.string(); return w.string();
@@ -110,13 +111,13 @@ std::string BeltGCodeWriter::_travel_to_z(double z, const std::string &comment)
{ {
m_pos(2) = z; m_pos(2) = z;
double speed = this->config.travel_speed_z.value; double speed = this->config.travel_speed_z.get_at(m_cached_extruder_idx);
if (speed == 0.) { if (speed == 0.) {
const bool first_layer_for_point = belt_point_on_first_layer( const bool first_layer_for_point = belt_point_on_first_layer(
m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer, m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer,
Vec3d(m_pos.x(), m_pos.y(), z)); Vec3d(m_pos.x(), m_pos.y(), z));
speed = first_layer_for_point ? this->config.get_abs_value("initial_layer_travel_speed") speed = first_layer_for_point ? this->config.get_abs_value_at("initial_layer_travel_speed", m_cached_extruder_idx)
: this->config.travel_speed.value; : this->config.travel_speed.get_at(m_cached_extruder_idx);
} }
// Belt printer: a Z-only move in slicing frame needs to emit both Y and Z in machine coords. // Belt printer: a Z-only move in slicing frame needs to emit both Y and Z in machine coords.
@@ -182,8 +183,8 @@ std::string BeltGCodeWriter::travel_to_xyz(const Vec3d &point, const std::string
const bool first_layer_for_point = belt_point_on_first_layer( const bool first_layer_for_point = belt_point_on_first_layer(
m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer, point); m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer, point);
auto travel_speed = auto travel_speed =
first_layer_for_point ? this->config.get_abs_value("initial_layer_travel_speed") first_layer_for_point ? this->config.get_abs_value_at("initial_layer_travel_speed", m_cached_extruder_idx)
: this->config.travel_speed.value; : this->config.travel_speed.get_at(m_cached_extruder_idx);
// Handle pending z_hop // Handle pending z_hop
if (std::abs(m_to_lift) > EPSILON) { if (std::abs(m_to_lift) > EPSILON) {
@@ -253,7 +254,7 @@ std::string BeltGCodeWriter::travel_to_xyz(const Vec3d &point, const std::string
// Belt mode: always emit full XYZ // Belt mode: always emit full XYZ
GCodeG1Formatter w; GCodeG1Formatter w;
w.emit_xyz(point_on_plate); w.emit_xyz(point_on_plate);
w.emit_f(this->config.travel_speed.value * 60.0); w.emit_f(this->config.travel_speed.get_at(m_cached_extruder_idx) * 60.0);
w.emit_comment(GCodeWriter::full_gcode_comment, comment); w.emit_comment(GCodeWriter::full_gcode_comment, comment);
m_pos = dest_point; m_pos = dest_point;

View File

@@ -167,14 +167,17 @@ protected:
// Apply axis remap to a point. Returns pos unchanged if remap is identity. // Apply axis remap to a point. Returns pos unchanged if remap is identity.
Vec3d apply_axis_remap(const Vec3d &pos) const; Vec3d apply_axis_remap(const Vec3d &pos) const;
// Motion uses the global/base process variant until a filament becomes active.
// Protected so BeltGCodeWriter indexes the per-extruder speed options (travel_speed,
// travel_speed_z, initial_layer_travel_speed) exactly as the base writer does.
size_t m_cached_extruder_idx;
private: private:
// Extruders are sorted by their ID, so that binary search is possible. // Extruders are sorted by their ID, so that binary search is possible.
std::vector<Extruder> m_filament_extruders; std::vector<Extruder> m_filament_extruders;
bool m_single_extruder_multi_material; bool m_single_extruder_multi_material;
std::vector<Extruder*> m_curr_filament_extruder; std::vector<Extruder*> m_curr_filament_extruder;
int m_curr_extruder_id; int m_curr_extruder_id;
// Motion uses the global/base process variant until a filament becomes active.
size_t m_cached_extruder_idx;
unsigned int m_last_acceleration; unsigned int m_last_acceleration;
unsigned int m_last_travel_acceleration; unsigned int m_last_travel_acceleration;
std::vector<unsigned int> m_max_travel_acceleration; std::vector<unsigned int> m_max_travel_acceleration;