diff --git a/html/own_filaments.json b/html/own_filaments.json new file mode 100644 index 0000000..cd3e43c --- /dev/null +++ b/html/own_filaments.json @@ -0,0 +1,31 @@ +{ + "TPU": "GFU99", + "PA": "GFN99", + "PA-CF": "GFN98", + "PLA": "GFL99", + "PLA Silk": "GFL96", + "PLA-CF": "GFL98", + "PLA High Speed": "GFL95", + "PETG": "GFG99", + "PETG-CF": "GFG98", + "PCTG": "GFG97", + "ABS": "GFB99", + "ABS+HS": "GFB99", + "PC": "GFC99", + "PC/ABS": "GFC99", + "ASA": "GFB98", + "PVA": "GFS99", + "HIPS": "GFS98", + "PPS-CF": "GFT98", + "PPS": "GFT97", + "PPA-CF": "GFN97", + "PPA-GF": "GFN96", + "PE": "GFP99", + "PE-CF": "GFP98", + "PP": "GFP97", + "PP-CF": "GFP96", + "PP-GF": "GFP95", + "EVA": "GFR99", + "PHA": "GFR98", + "BVOH": "GFS97" +} \ No newline at end of file diff --git a/src/bambu.cpp b/src/bambu.cpp index 8736f30..840d9f0 100644 --- a/src/bambu.cpp +++ b/src/bambu.cpp @@ -95,12 +95,37 @@ FilamentResult findFilamentIdx(String brand, String type) { // JSON-Dokument für die Filament-Daten erstellen JsonDocument doc; + // Laden der own_filaments.json + String ownFilament = ""; + if (!loadJsonValue("/own_filaments.json", doc)) + { + Serial.println("Fehler beim Laden der eigenen Filament-Daten"); + } + else + { + // Durchsuche direkt nach dem Type als Schlüssel + if (doc[type].is()) { + ownFilament = doc[type].as(); + } + doc.clear(); + } + // Laden der bambu_filaments.json - if (!loadJsonValue("/bambu_filaments.json", doc)) { + if (!loadJsonValue("/bambu_filaments.json", doc)) + { Serial.println("Fehler beim Laden der Filament-Daten"); return {"GFL99", "PLA"}; // Fallback auf Generic PLA } + // Wenn eigener Typ + if (ownFilament != "") + { + if (doc[ownFilament].is()) + { + return {ownFilament, doc[ownFilament].as()}; + } + } + // 1. Erst versuchen wir die exakte Brand + Type Kombination zu finden String searchKey; if (brand == "Bambu" || brand == "Bambulab") {