Skip to content

Added Sunlu filament sub types #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion firmware/bambu.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace bambulabs
return ""; // Unknown type
}

// Function with three parameters (for Bambu PLA subtypes)
// Function with three parameters (for Bambu & Sunlu PLA subtypes)
inline std::string get_bambu_code(const std::string &type, const std::string &brand, const std::string &subtype)
{
if (type == "PLA" && brand == "Bambu")
Expand All @@ -89,6 +89,18 @@ namespace bambulabs
return "GFA03";
return "GFA00"; // Default to Basic for unknown subtypes
}
else if (type == "PLA" && brand == "Sunlu")
{
if (subtype == "Matte")
return "GFSNL02";
if (subtype == "Silk")
return "GFSNL05";
if (subtype == "Marble")
return "GFSNL06";
if (subtype == "Wood")
return "GFSNL06";
return "GFSNL03"; // Default to Basic for unknown subtypes
}
return get_bambu_code(type, brand);
}

Expand Down
71 changes: 63 additions & 8 deletions firmware/conf.d/automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ script:
StaticJsonDocument<256> doc;
JsonObject root = doc.to<JsonObject>();

root["protocol"] = "openspool";
root["version"] = "1.0";
root["brand"] = id(filament_brand).state.c_str();
root["protocol"] = "openspool";
if (id(filament_include_alpha).state == true){
root["color_hex"] = id(filament_color_hexaa).state.c_str();
}
else{
root["color_hex"] = id(filament_color_hex).state.c_str();
}
root["type"] = id(filament_type).state.c_str();
root["min_temp"] = id(filament_min_temp).state;
root["max_temp"] = id(filament_max_temp).state;
root["type"] = id(filament_type).state.c_str();
root["brand"] = id(filament_brand).state.c_str();

std::string output;
serializeJsonPretty(doc, output);
Expand Down Expand Up @@ -141,8 +141,27 @@ script:
} else if (id(filament_brand).state == "PolyLite") {
id(filament_brand_code).publish_state("GFL00");
id(filament_sub_brand).publish_state("PolyLite PLA");
} else if (id(filament_brand).state == "Sunlu") {
id(filament_brand_code).publish_state("GFSNL03");
} else if (id(filament_brand).state == "Sunlu") {
// Check for Sunlu PLA variants
if (id(filament_variant).state == "Basic") {
id(filament_brand_code).publish_state("GFSNL03");
id(filament_sub_brand).publish_state("PLA Basic");
} else if (id(filament_variant).state == "Marble") {
id(filament_brand_code).publish_state("GFSNL06");
id(filament_sub_brand).publish_state("PLA Marble");
} else if (id(filament_variant).state == "Matte") {
id(filament_brand_code).publish_state("GFSNL02");
id(filament_sub_brand).publish_state("PLA Matte");
} else if (id(filament_variant).state == "Silk") {
id(filament_brand_code).publish_state("GFSNL05");
id(filament_sub_brand).publish_state("PLA Silk");
} else if (id(filament_variant).state == "Wood") {
id(filament_brand_code).publish_state("GFSNL07");
id(filament_sub_brand).publish_state("PLA Wood");
} else { // Default to Basic if no variant specified
id(filament_brand_code).publish_state("GFSNL03");
id(filament_sub_brand).publish_state("PLA Basic");
}
} else if (id(filament_brand).state == "Bambu") {
// Check for Bambu PLA variants
if (id(filament_variant).state == "Basic") {
Expand All @@ -166,6 +185,12 @@ script:
id(filament_sub_brand).publish_state("PLA");
}
}
// PLA High Speed
else if (id(filament_type).state == "PLA High Speed") {
// Generic
id(filament_brand_code).publish_state("GFL95");
id(filament_sub_brand).publish_state("PLA High Speed");
}
// PETG
else if (id(filament_type).state == "PETG") {
if (id(filament_brand).state == "Overture") {
Expand Down Expand Up @@ -284,10 +309,32 @@ script:
id(filament_max_temp).publish_state(250);
}
}
else if (id(filament_type).state == "PLA") {
else if (id(filament_type).state == "PLA" || id(filament_type).state == "PLA High Speed") {
if (id(filament_brand).state == "Generic") {
id(filament_min_temp).publish_state(190);
id(filament_max_temp).publish_state(240);
} else if (id(filament_brand).state == "Sunlu") {
if (id(filament_variant).state == "Basic"){
id(filament_min_temp).publish_state(190);
id(filament_max_temp).publish_state(240);
} else if (id(filament_variant).state == "Matte"){
id(filament_min_temp).publish_state(205);
id(filament_max_temp).publish_state(245);
} else if (id(filament_variant).state == "Marble"){
id(filament_min_temp).publish_state(190);
id(filament_max_temp).publish_state(260);
} else if (id(filament_variant).state == "Silk"){
id(filament_min_temp).publish_state(190);
id(filament_max_temp).publish_state(240);
} else if (id(filament_variant).state == "Wood"){
id(filament_min_temp).publish_state(195);
id(filament_max_temp).publish_state(260);
} else {
ESP_LOGW("main", "Unknown temperatures for Variant: %s", id(filament_variant).state.c_str());
id(filament_min_temp).publish_state(190);
id(filament_max_temp).publish_state(240);
}

} else {
ESP_LOGW("main", "Unknown temperatures for PLA: %s", id(filament_brand).state.c_str());
id(filament_min_temp).publish_state(190);
Expand All @@ -306,9 +353,12 @@ script:
}
else if (id(filament_type).state == "ASA") {
if (id(filament_brand).state == "Generic") {
//TODO: find temps for ASA
id(filament_min_temp).publish_state(240);
id(filament_max_temp).publish_state(280);
} else {
ESP_LOGW("main", "Unknown temperatures for ASA: %s", id(filament_brand).state.c_str());
id(filament_min_temp).publish_state(240);
id(filament_max_temp).publish_state(280);
}
}
else if (id(filament_type).state == "ABS") {
Expand All @@ -317,6 +367,8 @@ script:
id(filament_max_temp).publish_state(280);
} else {
ESP_LOGW("main", "Unknown temperatures for ABS: %s", id(filament_brand).state.c_str());
id(filament_min_temp).publish_state(240);
id(filament_max_temp).publish_state(280);
}
}
else if (id(filament_type).state == "PVA") {
Expand All @@ -341,9 +393,12 @@ script:
}
else if (id(filament_type).state == "PC") {
if (id(filament_brand).state == "Generic") {
//TODO: find temps for PC
id(filament_min_temp).publish_state(260);
id(filament_max_temp).publish_state(290);
} else {
ESP_LOGW("main", "Unknown temperatures for PC: %s", id(filament_brand).state.c_str());
id(filament_min_temp).publish_state(260);
id(filament_max_temp).publish_state(290);
}
}
else if (id(filament_type).state == "PA") {
Expand Down
11 changes: 7 additions & 4 deletions firmware/conf.d/filament.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ select:
sorting_group_id: sorting_group_filament_settings
sorting_weight: 40
options:
- Basic
- Basic
- Impact
- Marble
- Matte
- Metal
- Impact
- G
- W
- Silk
- Wood
#- Support G -> Create own filament type? Theoretically not needed at all, because only available from Bambu
#- Support W -> Create own filament type? Theoretically not needed at all, because only available from Bambu
# TODO: add the rest of the options
on_value:
then:
Expand Down