Compare commits
3 Commits
c6fd5f8ad5
...
d1f22c78f7
Author | SHA1 | Date | |
---|---|---|---|
d1f22c78f7 | |||
3e1490cafc | |||
dc82c04a17 |
49
html/rfid.js
49
html/rfid.js
@ -112,9 +112,39 @@ function initWebSocket() {
|
||||
|
||||
if (bambuDot) {
|
||||
bambuDot.className = 'status-dot ' + (data.bambu_connected ? 'online' : 'offline');
|
||||
// Add click handler only when offline
|
||||
if (!data.bambu_connected) {
|
||||
bambuDot.style.cursor = 'pointer';
|
||||
bambuDot.onclick = function() {
|
||||
if (socket && socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(JSON.stringify({
|
||||
type: 'reconnect',
|
||||
payload: 'bambu'
|
||||
}));
|
||||
}
|
||||
};
|
||||
} else {
|
||||
bambuDot.style.cursor = 'default';
|
||||
bambuDot.onclick = null;
|
||||
}
|
||||
}
|
||||
if (spoolmanDot) {
|
||||
spoolmanDot.className = 'status-dot ' + (data.spoolman_connected ? 'online' : 'offline');
|
||||
// Add click handler only when offline
|
||||
if (!data.spoolman_connected) {
|
||||
spoolmanDot.style.cursor = 'pointer';
|
||||
spoolmanDot.onclick = function() {
|
||||
if (socket && socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(JSON.stringify({
|
||||
type: 'reconnect',
|
||||
payload: 'spoolman'
|
||||
}));
|
||||
}
|
||||
};
|
||||
} else {
|
||||
spoolmanDot.style.cursor = 'default';
|
||||
spoolmanDot.onclick = null;
|
||||
}
|
||||
}
|
||||
if (ramStatus) {
|
||||
ramStatus.textContent = `${data.freeHeap}k`;
|
||||
@ -305,7 +335,13 @@ function displayAmsData(amsData) {
|
||||
tray[prop.key] !== '' &&
|
||||
tray[prop.key] !== 'null'
|
||||
)
|
||||
.map(prop => `<p>${prop.label}: ${tray[prop.key]}</p>`)
|
||||
.map(prop => {
|
||||
// Spezielle Behandlung für setting_id
|
||||
if (prop.key === 'cali_idx' && tray[prop.key] === '-1') {
|
||||
return `<p>${prop.label}: not calibrated</p>`;
|
||||
}
|
||||
return `<p>${prop.label}: ${tray[prop.key]}</p>`;
|
||||
})
|
||||
.join('');
|
||||
|
||||
// Temperaturen nur anzeigen, wenn beide nicht 0 sind
|
||||
@ -418,13 +454,16 @@ function handleSpoolIn(amsId, trayId) {
|
||||
nozzle_temp_max: parseInt(maxTemp),
|
||||
type: selectedSpool.filament.material,
|
||||
brand: selectedSpool.filament.vendor.name,
|
||||
tray_info_idx: selectedSpool.filament.extra.bambu_idx.replace(/['"]+/g, '').trim(),
|
||||
cali_idx: selectedSpool.filament.extra.bambu_setting_id.replace(/['"]+/g, '').trim()
|
||||
tray_info_idx: selectedSpool.filament.extra.bambu_idx.replace(/['"]+/g, '').trim()
|
||||
}
|
||||
};
|
||||
|
||||
// Debug logging
|
||||
console.log("Sende WebSocket Nachricht:", payload);
|
||||
// Prüfe, ob der Key bambu_setting_id vorhanden ist
|
||||
if (selectedSpool.filament.extra.bambu_setting_id) {
|
||||
payload.payload.cali_idx = selectedSpool.filament.extra.bambu_setting_id.replace(/['"]+/g, '').trim();
|
||||
} else {
|
||||
payload.payload.cali_idx = "-1";
|
||||
}
|
||||
|
||||
try {
|
||||
socket.send(JSON.stringify(payload));
|
||||
|
@ -133,6 +133,15 @@ body {
|
||||
background-color: #dc2626;
|
||||
}
|
||||
|
||||
.status-dot.offline {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.status-dot.offline:hover {
|
||||
opacity: 0.8;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.ram-status {
|
||||
color: var(--inner-text-color);
|
||||
font-size: 0.9em;
|
||||
|
@ -193,7 +193,7 @@ bool setBambuSpool(String payload) {
|
||||
int maxTemp = doc["nozzle_temp_max"];
|
||||
String type = doc["type"].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>() != "-1") ? doc["tray_info_idx"].as<String>() : "";
|
||||
if (tray_info_idx == "") tray_info_idx = (brand != "" && type != "") ? findFilamentIdx(brand, type) : "";
|
||||
String setting_id = doc["cali_idx"].as<String>();
|
||||
|
||||
@ -223,6 +223,33 @@ bool setBambuSpool(String payload) {
|
||||
return false;
|
||||
}
|
||||
|
||||
doc.clear();
|
||||
|
||||
if (setting_id != "") {
|
||||
doc["print"]["sequence_id"] = 0;
|
||||
doc["print"]["command"] = "extrusion_cali_sel";
|
||||
doc["print"]["ams_id"] = amsId < 200 ? amsId : 255;
|
||||
doc["print"]["tray_id"] = trayId < 200 ? trayId : 254;
|
||||
doc["print"]["filament_id"] = tray_info_idx;
|
||||
doc["print"]["nozzle_diameter"] = "0.4";
|
||||
doc["print"]["cali_idx"] = setting_id.toInt();
|
||||
|
||||
// Serialize the JSON
|
||||
String output;
|
||||
serializeJson(doc, output);
|
||||
|
||||
if (sendMqttMessage(output)) {
|
||||
Serial.println("Setting ID successfully set");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Failed to set setting ID");
|
||||
return false;
|
||||
}
|
||||
|
||||
doc.clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -305,11 +332,6 @@ void mqtt_callback(char* topic, byte* payload, unsigned int length) {
|
||||
if (!foundExternal) hasChanges = true;
|
||||
}
|
||||
|
||||
// Wenn Bambu connection changed
|
||||
if (bambu_connected != doc["print"]["bambu_connected"].as<bool>()) {
|
||||
hasChanges = true;
|
||||
}
|
||||
|
||||
if (!hasChanges) return;
|
||||
|
||||
// Fortfahren mit der bestehenden Verarbeitung, da Änderungen gefunden wurden
|
||||
@ -512,4 +534,11 @@ bool setupMqtt() {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void bambu_restart() {
|
||||
if (BambuMqttTask) {
|
||||
vTaskDelete(BambuMqttTask);
|
||||
}
|
||||
setupMqtt();
|
||||
}
|
@ -33,5 +33,6 @@ bool saveBambuCredentials(const String& bambu_ip, const String& bambu_serialnr,
|
||||
bool setupMqtt();
|
||||
void mqtt_loop(void * parameter);
|
||||
bool setBambuSpool(String payload);
|
||||
void bambu_restart();
|
||||
|
||||
#endif
|
||||
|
@ -69,6 +69,16 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
|
||||
}
|
||||
}
|
||||
|
||||
else if (doc["type"] == "reconnect") {
|
||||
if (doc["payload"] == "bambu") {
|
||||
bambu_restart();
|
||||
}
|
||||
|
||||
if (doc["payload"] == "spoolman") {
|
||||
initSpoolman();
|
||||
}
|
||||
}
|
||||
|
||||
else if (doc["type"] == "setBambuSpool") {
|
||||
Serial.println(doc["payload"].as<String>());
|
||||
setBambuSpool(doc["payload"]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user