fix: round flush_volumes_matrix values to integers (#12672)

When flush_multiplier is applied to flush_volumes_matrix values, the
result can be a decimal (e.g., 272 * 1.3 = 353.6). Some printer firmware
metadata parsers (notably Creality K2) crash when parsing decimal values
in flush_volumes_matrix, causing prints to get stuck at "File selected".

This fix rounds the multiplied values to integers, ensuring compatibility
with firmware that expects integer values in this field.

Fixes compatibility with Creality K2 and potentially other Klipper-based
printers that parse the CONFIG_BLOCK metadata.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Olof Larsson
2026-03-09 13:35:56 +01:00
committed by GitHub
parent ac5c93ef2d
commit 3842511068

View File

@@ -5402,7 +5402,7 @@ void GCode::append_full_config(const Print &print, std::string &str)
size_t temp_begin_t = idx * matrix_value_count, temp_end_t = (idx + 1) * matrix_value_count;
std::transform(temp_flush_volumes_matrix.begin() + temp_begin_t, temp_flush_volumes_matrix.begin() + temp_end_t,
temp_flush_volumes_matrix.begin() + temp_begin_t,
[temp_cfg_flush_multiplier_idx](double inputx) { return inputx * temp_cfg_flush_multiplier_idx; });
[temp_cfg_flush_multiplier_idx](double inputx) { return std::round(inputx * temp_cfg_flush_multiplier_idx); });
}
cfg.option<ConfigOptionFloats>("flush_volumes_matrix")->values = temp_flush_volumes_matrix;
} else if (filament_count_tmp == 1) {