Skip to content

Commit

Permalink
connect: Make distinction between slot / head
Browse files Browse the repository at this point in the history
As a result, don't ask for the 4th nozzle's diameter on MMU printer when
printing from the 4th filament slot.

BFW-5873.
  • Loading branch information
vorner committed Jul 29, 2024
1 parent f09ae5f commit 82fb3f3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/connect/marlin_printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Printer::Params MarlinPrinter::params() const {
params.time_to_pause = marlin_vars()->time_to_pause;
params.progress_percent = marlin_vars()->sd_percent_done;
params.filament_used = Odometer_s::instance().get_extruded_all();
params.nozzle_diameter = config_store().get_nozzle_diameter(params.preferred_slot());
params.nozzle_diameter = config_store().get_nozzle_diameter(params.preferred_head());
params.has_usb = marlin_vars()->media_inserted;
params.can_start_download = can_start_download;

Expand Down
8 changes: 8 additions & 0 deletions src/connect/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,12 @@ uint8_t Printer::Params::preferred_slot() const {
}
}

uint8_t Printer::Params::preferred_head() const {
#if HAS_TOOLCHANGER()
return preferred_slot();
#else
return 0;
#endif
}

} // namespace connect_client
7 changes: 7 additions & 0 deletions src/connect/printer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ class Printer {
}
// Either the active slot, if any, or the first available slot if no slot is active.
uint8_t preferred_slot() const;
// Either the active head, if any, or the first available one.
//
// This is the same as preferred_slot for XL (where tools and slots are
// the same thing), but always returns 0 on other printers, including
// ones with MMU (they have multiple filament slots, but just one head
// / nozzle / ...).
uint8_t preferred_head() const;
};

struct Config {
Expand Down
6 changes: 3 additions & 3 deletions src/connect/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace {
// need to coordinate with Connect, as these are probably
// "essential" fields right now.
if (telemetry.mode == SendTelemetry::Mode::Full) {
JSON_FIELD_FFIXED("temp_nozzle", params.slots[params.preferred_slot()].temp_nozzle, 1) JSON_COMMA;
JSON_FIELD_FFIXED("temp_nozzle", params.slots[params.preferred_head()].temp_nozzle, 1) JSON_COMMA;
JSON_FIELD_FFIXED("temp_bed", params.temp_bed, 1) JSON_COMMA;
JSON_FIELD_FFIXED("target_nozzle", params.target_nozzle, 1) JSON_COMMA;
JSON_FIELD_FFIXED("target_bed", params.target_bed, 1) JSON_COMMA;
Expand All @@ -148,8 +148,8 @@ namespace {
}
JSON_FIELD_FFIXED("axis_z", params.pos[Printer::Z_AXIS_POS], 2) JSON_COMMA;
if (params.has_job) {
JSON_FIELD_INT("fan_extruder", params.slots[params.preferred_slot()].heatbreak_fan_rpm) JSON_COMMA;
JSON_FIELD_INT("fan_print", params.slots[params.preferred_slot()].print_fan_rpm) JSON_COMMA;
JSON_FIELD_INT("fan_extruder", params.slots[params.preferred_head()].heatbreak_fan_rpm) JSON_COMMA;
JSON_FIELD_INT("fan_print", params.slots[params.preferred_head()].print_fan_rpm) JSON_COMMA;
JSON_FIELD_FFIXED("filament", params.filament_used, 1) JSON_COMMA;
}

Expand Down

0 comments on commit 82fb3f3

Please sign in to comment.