Skip to content

Commit 2b716f7

Browse files
authored
Merge pull request #38 from raihei/main
Allow tags with filament color alpha channel value
2 parents 987e00c + d713752 commit 2b716f7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

firmware/bambu.h

+8-3
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ namespace bambulabs
120120
}
121121
}
122122

123-
if (doc_in["color_hex"].as<std::string>().length() != 6) {
124-
ESP_LOGE("bambu", "Invalid color_hex length (expected 6 characters)");
123+
if (doc_in["color_hex"].as<std::string>().length() != 6 && doc_in["color_hex"].as<std::string>().length() != 8) {
124+
ESP_LOGE("bambu", "Invalid color_hex length (expected 6 or 8 characters)");
125125
return {};
126126
}
127127

@@ -130,7 +130,12 @@ namespace bambulabs
130130
print["command"] = "ams_filament_setting";
131131
print["ams_id"] = ams_id;
132132
print["tray_id"] = ams_tray;
133-
print["tray_color"] = doc_in["color_hex"].as<std::string>() + "FF";
133+
if (doc_in["color_hex"].as<std::string>().length() == 6) {
134+
print["tray_color"] = doc_in["color_hex"].as<std::string>() + "FF";
135+
}
136+
else{
137+
print["tray_color"] = doc_in["color_hex"].as<std::string>();
138+
}
134139
print["nozzle_temp_min"] = uint16_t(doc_in["min_temp"]); // if not string or int, will fall back to 0
135140
print["nozzle_temp_max"] = uint16_t(doc_in["max_temp"]); // if not string or int, will fall back to 0
136141
print["tray_type"] = doc_in["type"];

0 commit comments

Comments
 (0)