CrealityPrint: use spool holder print protocol when Ext selected

When the spool holder is selected for printing, use the opGcodeFile
command with enableSelfTest instead of colorMatch + multiColorPrint.
This matches the protocol used by CrealityPrint desktop for spool
holder prints.

- Detect spool holder mode: any colorMatch entry with box_id 0
- Spool holder: send opGcodeFile + enableSelfTest (single command)
- CFS: send colorMatch + multiColorPrint (existing behavior)

Signed-off-by: Igor Mammedov <niallain@gmail.com>
This commit is contained in:
Igor Mammedov
2026-05-09 15:37:24 +02:00
parent 1608af485f
commit 4e4dd708b9

View File

@@ -305,6 +305,7 @@ bool CrealityPrint::start_print(wxString &msg, const std::string &filename, cons
if (supports_multi_color_print()) { if (supports_multi_color_print()) {
// Build colorMatch list from the mapping provided by the dialog // Build colorMatch list from the mapping provided by the dialog
bool use_spool_holder = false;
json color_list = json::array(); json color_list = json::array();
for (int i = 0; ; i++) { for (int i = 0; ; i++) {
auto it = extended_info.find("colorMatch_" + std::to_string(i)); auto it = extended_info.find("colorMatch_" + std::to_string(i));
@@ -318,16 +319,36 @@ bool CrealityPrint::start_print(wxString &msg, const std::string &filename, cons
while (std::getline(iss, part, '\t')) while (std::getline(iss, part, '\t'))
parts.push_back(part); parts.push_back(part);
if (parts.size() >= 5) { if (parts.size() >= 5) {
int box_id = std::stoi(parts[3]);
if (box_id == 0)
use_spool_holder = true;
color_list.push_back({ color_list.push_back({
{"id", parts[0]}, {"id", parts[0]},
{"type", parts[1]}, {"type", parts[1]},
{"color", parts[2]}, {"color", parts[2]},
{"boxId", std::stoi(parts[3])}, {"boxId", box_id},
{"materialId", std::stoi(parts[4])} {"materialId", std::stoi(parts[4])}
}); });
} }
} }
int enable_self_test = 0;
{
auto it = extended_info.find("enableSelfTest");
if (it != extended_info.end())
enable_self_test = std::stoi(it->second);
}
if (use_spool_holder) {
json cmd = {
{"method", "set"},
{"params", {
{"opGcodeFile", "printprt:" + gcode_path},
{"enableSelfTest", enable_self_test}
}}
};
ws.write(net::buffer(to_string(cmd)));
} else {
json color_match = { json color_match = {
{"method", "set"}, {"method", "set"},
{"params", { {"params", {
@@ -339,12 +360,6 @@ bool CrealityPrint::start_print(wxString &msg, const std::string &filename, cons
}; };
ws.write(net::buffer(to_string(color_match))); ws.write(net::buffer(to_string(color_match)));
// Read enableSelfTest from extended_info, default to 0 (calibration off)
int enable_self_test = 0;
auto it = extended_info.find("enableSelfTest");
if (it != extended_info.end())
enable_self_test = std::stoi(it->second);
json multi_color_print = { json multi_color_print = {
{"method", "set"}, {"method", "set"},
{"params", { {"params", {
@@ -355,6 +370,7 @@ bool CrealityPrint::start_print(wxString &msg, const std::string &filename, cons
}} }}
}; };
ws.write(net::buffer(to_string(multi_color_print))); ws.write(net::buffer(to_string(multi_color_print)));
}
} else { } else {
json cmd = { json cmd = {
{"method", "set"}, {"method", "set"},