fix: add calibration index to tray properties and update related logic

This commit is contained in:
Manuel Weiser 2025-02-15 07:14:03 +01:00
parent d4348944fc
commit c21be92e98
3 changed files with 10 additions and 6 deletions

View File

@ -293,7 +293,8 @@ function displayAmsData(amsData) {
const trayProperties = [ const trayProperties = [
{ key: 'tray_sub_brands', label: 'Sub Brands' }, { key: 'tray_sub_brands', label: 'Sub Brands' },
{ key: 'tray_info_idx', label: 'Filament IDX' }, { key: 'tray_info_idx', label: 'Filament IDX' },
{ key: 'setting_id', label: 'Setting ID' } { key: 'setting_id', label: 'Setting ID' },
{ key: 'cali_idx', label: 'Calibration IDX' } // Add new property
]; ];
// Nur gültige Felder anzeigen // Nur gültige Felder anzeigen
@ -417,7 +418,8 @@ function handleSpoolIn(amsId, trayId) {
nozzle_temp_max: parseInt(maxTemp), nozzle_temp_max: parseInt(maxTemp),
type: selectedSpool.filament.material, type: selectedSpool.filament.material,
brand: selectedSpool.filament.vendor.name, brand: selectedSpool.filament.vendor.name,
tray_info_idx: selectedSpool.filament.extra.bambu_idx.replace(/['"]+/g, '').trim() tray_info_idx: selectedSpool.filament.extra.bambu_idx.replace(/['"]+/g, '').trim(),
cali_idx: selectedSpool.filament.extra.bambu_setting_id.replace(/['"]+/g, '').trim()
} }
}; };

View File

@ -86,6 +86,7 @@ function populateVendorDropdown(data, selectedSmId = null) {
}); });
// Nach der Schleife: Formatierung der Gesamtlänge // Nach der Schleife: Formatierung der Gesamtlänge
console.log("Total Lenght: ", totalLength);
const formattedLength = totalLength > 1000 const formattedLength = totalLength > 1000
? (totalLength / 1000).toFixed(2) + " km" ? (totalLength / 1000).toFixed(2) + " km"
: totalLength.toFixed(2) + " m"; : totalLength.toFixed(2) + " m";

View File

@ -195,6 +195,7 @@ bool setBambuSpool(String payload) {
String brand = doc["brand"].as<String>(); String brand = doc["brand"].as<String>();
String tray_info_idx = doc["tray_info_idx"].as<String>(); String tray_info_idx = doc["tray_info_idx"].as<String>();
if (tray_info_idx == "") tray_info_idx = (brand != "" && type != "") ? findFilamentIdx(brand, type) : ""; if (tray_info_idx == "") tray_info_idx = (brand != "" && type != "") ? findFilamentIdx(brand, type) : "";
String setting_id = doc["cali_idx"].as<String>();
doc.clear(); doc.clear();
@ -206,7 +207,7 @@ bool setBambuSpool(String payload) {
doc["print"]["nozzle_temp_min"] = minTemp; doc["print"]["nozzle_temp_min"] = minTemp;
doc["print"]["nozzle_temp_max"] = maxTemp; doc["print"]["nozzle_temp_max"] = maxTemp;
doc["print"]["tray_type"] = type; doc["print"]["tray_type"] = type;
doc["print"]["setting_id"] = ""; doc["print"]["setting_id"] = (setting_id != "") ? setting_id : "";
doc["print"]["tray_info_idx"] = tray_info_idx; doc["print"]["tray_info_idx"] = tray_info_idx;
// Serialize the JSON // Serialize the JSON
@ -330,7 +331,7 @@ void mqtt_callback(char* topic, byte* payload, unsigned int length) {
ams_data[i].trays[j].tray_color = trayObj["tray_color"].as<String>(); ams_data[i].trays[j].tray_color = trayObj["tray_color"].as<String>();
ams_data[i].trays[j].nozzle_temp_min = trayObj["nozzle_temp_min"].as<int>(); ams_data[i].trays[j].nozzle_temp_min = trayObj["nozzle_temp_min"].as<int>();
ams_data[i].trays[j].nozzle_temp_max = trayObj["nozzle_temp_max"].as<int>(); ams_data[i].trays[j].nozzle_temp_max = trayObj["nozzle_temp_max"].as<int>();
ams_data[i].trays[j].setting_id = trayObj["setting_id"].as<String>(); ams_data[i].trays[j].setting_id = trayObj["cali_idx"].as<String>();
} }
} }
//Serial.println("----------------"); //Serial.println("----------------");
@ -368,7 +369,7 @@ void mqtt_callback(char* topic, byte* payload, unsigned int length) {
ams_data[extIdx].trays[0].tray_color = vtTray["tray_color"].as<String>(); ams_data[extIdx].trays[0].tray_color = vtTray["tray_color"].as<String>();
ams_data[extIdx].trays[0].nozzle_temp_min = vtTray["nozzle_temp_min"].as<int>(); ams_data[extIdx].trays[0].nozzle_temp_min = vtTray["nozzle_temp_min"].as<int>();
ams_data[extIdx].trays[0].nozzle_temp_max = vtTray["nozzle_temp_max"].as<int>(); ams_data[extIdx].trays[0].nozzle_temp_max = vtTray["nozzle_temp_max"].as<int>();
ams_data[extIdx].trays[0].setting_id = vtTray["setting_id"].as<String>(); ams_data[extIdx].trays[0].setting_id = vtTray["cali_idx"].as<String>();
ams_count++; // Erhöhe ams_count für die externe Spule ams_count++; // Erhöhe ams_count für die externe Spule
} }
@ -395,7 +396,7 @@ void mqtt_callback(char* topic, byte* payload, unsigned int length) {
trayObj["tray_color"] = ams_data[i].trays[j].tray_color; trayObj["tray_color"] = ams_data[i].trays[j].tray_color;
trayObj["nozzle_temp_min"] = ams_data[i].trays[j].nozzle_temp_min; trayObj["nozzle_temp_min"] = ams_data[i].trays[j].nozzle_temp_min;
trayObj["nozzle_temp_max"] = ams_data[i].trays[j].nozzle_temp_max; trayObj["nozzle_temp_max"] = ams_data[i].trays[j].nozzle_temp_max;
trayObj["setting_id"] = ams_data[i].trays[j].setting_id; trayObj["cali_idx"] = ams_data[i].trays[j].setting_id;
} }
} }