Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
2e19bccfa9 | |||
859e89431e | |||
6dc26ca51f | |||
0becae7ed6 | |||
3d31833f50 | |||
599cc47443 | |||
b1f7923770 | |||
c78c20979d | |||
e79c522e46 | |||
cf8cce72a5 | |||
0b356609d1 | |||
01f1e123ac | |||
012f91851e | |||
9ed3c70c01 |
26
CHANGELOG.md
26
CHANGELOG.md
@ -1,5 +1,31 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.5.3] - 2025-04-25
|
||||||
|
### Changed
|
||||||
|
- update platformio.ini for version v1.5.3
|
||||||
|
- Affiliate Links
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- update spool weight conditionally based on NFC ID
|
||||||
|
|
||||||
|
|
||||||
|
## [1.5.2] - 2025-04-23
|
||||||
|
### Added
|
||||||
|
- implement multi-color filament display and styles for dropdown options
|
||||||
|
- add remaining weight logging for PUT requests and improve error reporting in sendToApi function
|
||||||
|
- add remaining weight logging and display after successful spool update
|
||||||
|
- add weight field to update payload in updateSpoolTagId function
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- update platformio.ini for version v1.5.2
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- update weight field in update payload to only include values greater than 10
|
||||||
|
- increase stack size for sendToApi task to improve stability
|
||||||
|
- adjust tare weight tolerance to ignore deviations of 2g
|
||||||
|
- improve weight stability check before sending to API
|
||||||
|
|
||||||
|
|
||||||
## [1.5.1] - 2025-03-30
|
## [1.5.1] - 2025-03-30
|
||||||
### Changed
|
### Changed
|
||||||
- update version to 1.5.1 and improve OTA update handling with task management
|
- update version to 1.5.1 and improve OTA update handling with task management
|
||||||
|
@ -54,7 +54,7 @@ Discord Server: [https://discord.gg/my7Gvaxj2v](https://discord.gg/my7Gvaxj2v)
|
|||||||
|
|
||||||
## Hardware-Anforderungen
|
## Hardware-Anforderungen
|
||||||
|
|
||||||
### Komponenten
|
### Komponenten (Affiliate Links)
|
||||||
- **ESP32 Development Board:** Any ESP32 variant.
|
- **ESP32 Development Board:** Any ESP32 variant.
|
||||||
[Amazon Link](https://amzn.to/3FHea6D)
|
[Amazon Link](https://amzn.to/3FHea6D)
|
||||||
- **HX711 5kg Load Cell Amplifier:** For weight measurement.
|
- **HX711 5kg Load Cell Amplifier:** For weight measurement.
|
||||||
|
@ -58,7 +58,7 @@ Discord Server: [https://discord.gg/my7Gvaxj2v](https://discord.gg/my7Gvaxj2v)
|
|||||||
|
|
||||||
## Hardware Requirements
|
## Hardware Requirements
|
||||||
|
|
||||||
### Components
|
### Components (Affiliate Links)
|
||||||
- **ESP32 Development Board:** Any ESP32 variant.
|
- **ESP32 Development Board:** Any ESP32 variant.
|
||||||
[Amazon Link](https://amzn.to/3FHea6D)
|
[Amazon Link](https://amzn.to/3FHea6D)
|
||||||
- **HX711 5kg Load Cell Amplifier:** For weight measurement.
|
- **HX711 5kg Load Cell Amplifier:** For weight measurement.
|
||||||
|
14
html/rfid.js
14
html/rfid.js
@ -215,20 +215,6 @@ document.addEventListener('filamentSelected', function (event) {
|
|||||||
updateSpoolButtons(selectedText !== "Please choose...");
|
updateSpoolButtons(selectedText !== "Please choose...");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hilfsfunktion für kontrastreiche Textfarbe
|
|
||||||
function getContrastColor(hexcolor) {
|
|
||||||
// Konvertiere Hex zu RGB
|
|
||||||
const r = parseInt(hexcolor.substr(0,2),16);
|
|
||||||
const g = parseInt(hexcolor.substr(2,2),16);
|
|
||||||
const b = parseInt(hexcolor.substr(4,2),16);
|
|
||||||
|
|
||||||
// Berechne Helligkeit (YIQ Formel)
|
|
||||||
const yiq = ((r*299)+(g*587)+(b*114))/1000;
|
|
||||||
|
|
||||||
// Return schwarz oder weiß basierend auf Helligkeit
|
|
||||||
return (yiq >= 128) ? '#000000' : '#FFFFFF';
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateNfcInfo() {
|
function updateNfcInfo() {
|
||||||
const selectedText = document.getElementById("selected-filament").textContent;
|
const selectedText = document.getElementById("selected-filament").textContent;
|
||||||
const nfcInfo = document.getElementById("nfcInfo");
|
const nfcInfo = document.getElementById("nfcInfo");
|
||||||
|
@ -169,9 +169,32 @@ function updateFilamentDropdown(selectedSmId = null) {
|
|||||||
option.setAttribute("data-value", spool.filament.id);
|
option.setAttribute("data-value", spool.filament.id);
|
||||||
option.setAttribute("data-nfc-id", spool.extra.nfc_id || "");
|
option.setAttribute("data-nfc-id", spool.extra.nfc_id || "");
|
||||||
|
|
||||||
|
|
||||||
|
// Generate color representation based on filament type (single or multi color)
|
||||||
|
let colorHTML = '';
|
||||||
|
|
||||||
|
// Check if this is a multicolor filament
|
||||||
|
if (spool.filament.multi_color_hexes) {
|
||||||
|
// Parse multi color hexes from comma-separated string
|
||||||
|
const colors = spool.filament.multi_color_hexes.replace(/#/g, '').split(',');
|
||||||
|
|
||||||
|
// Determine the display style based on direction
|
||||||
|
const direction = spool.filament.multi_color_direction || 'coaxial';
|
||||||
|
|
||||||
|
// Generate color circles for each color
|
||||||
|
colorHTML = '<div class="option-colors">';
|
||||||
|
colors.forEach(color => {
|
||||||
|
colorHTML += `<div class="option-color multi-color ${direction}" style="background-color: #${color}"></div>`;
|
||||||
|
});
|
||||||
|
colorHTML += '</div>';
|
||||||
|
} else {
|
||||||
|
// Single color filament
|
||||||
const colorHex = spool.filament.color_hex || 'FFFFFF';
|
const colorHex = spool.filament.color_hex || 'FFFFFF';
|
||||||
|
colorHTML = `<div class="option-color" style="background-color: #${colorHex}"></div>`;
|
||||||
|
}
|
||||||
|
|
||||||
option.innerHTML = `
|
option.innerHTML = `
|
||||||
<div class="option-color" style="background-color: #${colorHex}"></div>
|
${colorHTML}
|
||||||
<span>${spool.id} | ${spool.filament.name} (${spool.filament.material})</span>
|
<span>${spool.id} | ${spool.filament.name} (${spool.filament.material})</span>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -190,7 +213,29 @@ function selectFilament(spool) {
|
|||||||
const selectedText = document.getElementById("selected-filament");
|
const selectedText = document.getElementById("selected-filament");
|
||||||
const dropdownContent = document.getElementById("filament-dropdown-content");
|
const dropdownContent = document.getElementById("filament-dropdown-content");
|
||||||
|
|
||||||
|
// Update the selected color display
|
||||||
|
if (spool.filament.multi_color_hexes) {
|
||||||
|
// Handle multicolor filament display in the selection header
|
||||||
|
const colors = spool.filament.multi_color_hexes.replace(/#/g, '').split(',');
|
||||||
|
const direction = spool.filament.multi_color_direction || 'coaxial';
|
||||||
|
|
||||||
|
// Replace the single color div with multiple color divs
|
||||||
|
selectedColor.innerHTML = '';
|
||||||
|
colors.forEach(color => {
|
||||||
|
const colorDiv = document.createElement('div');
|
||||||
|
colorDiv.className = `color-segment multi-color ${direction}`;
|
||||||
|
colorDiv.style.backgroundColor = `#${color}`;
|
||||||
|
selectedColor.appendChild(colorDiv);
|
||||||
|
});
|
||||||
|
// Add multiple color class to the container
|
||||||
|
selectedColor.classList.add('multi-color-container');
|
||||||
|
} else {
|
||||||
|
// Single color filament - reset to default display
|
||||||
|
selectedColor.innerHTML = '';
|
||||||
|
selectedColor.classList.remove('multi-color-container');
|
||||||
selectedColor.style.backgroundColor = `#${spool.filament.color_hex || 'FFFFFF'}`;
|
selectedColor.style.backgroundColor = `#${spool.filament.color_hex || 'FFFFFF'}`;
|
||||||
|
}
|
||||||
|
|
||||||
selectedText.textContent = `${spool.id} | ${spool.filament.name} (${spool.filament.material})`;
|
selectedText.textContent = `${spool.id} | ${spool.filament.name} (${spool.filament.material})`;
|
||||||
dropdownContent.classList.remove("show");
|
dropdownContent.classList.remove("show");
|
||||||
|
|
||||||
|
@ -759,6 +759,50 @@ a:hover {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Multi-color filament styles */
|
||||||
|
.option-colors {
|
||||||
|
display: flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.multi-color {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 1px solid #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Coaxial pattern (horizontal stripes) */
|
||||||
|
.multi-color.coaxial {
|
||||||
|
border-radius: 50%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Longitudinal pattern (vertical stripes) */
|
||||||
|
.multi-color.longitudinal {
|
||||||
|
border-radius: 50%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Container for multiple colors in selected display */
|
||||||
|
.multi-color-container {
|
||||||
|
display: flex !important;
|
||||||
|
background: none !important;
|
||||||
|
border: none !important;
|
||||||
|
gap: 2px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
width: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-segment {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 1px solid #333;
|
||||||
|
}
|
||||||
|
|
||||||
.notification {
|
.notification {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
version = "1.5.1"
|
version = "1.5.3"
|
||||||
to_old_version = "1.5.0"
|
to_old_version = "1.5.0"
|
||||||
|
|
||||||
##
|
##
|
||||||
|
33
src/api.cpp
33
src/api.cpp
@ -109,8 +109,28 @@ void sendToApi(void *parameter) {
|
|||||||
|
|
||||||
if (httpCode == HTTP_CODE_OK) {
|
if (httpCode == HTTP_CODE_OK) {
|
||||||
Serial.println("Spoolman erfolgreich aktualisiert");
|
Serial.println("Spoolman erfolgreich aktualisiert");
|
||||||
|
|
||||||
|
// Restgewicht der Spule auslesen
|
||||||
|
String payload = http.getString();
|
||||||
|
JsonDocument doc;
|
||||||
|
DeserializationError error = deserializeJson(doc, payload);
|
||||||
|
if (error) {
|
||||||
|
Serial.print("Fehler beim Parsen der JSON-Antwort: ");
|
||||||
|
Serial.println(error.c_str());
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Fehler beim Senden an Spoolman!");
|
if (httpType == "PUT") {
|
||||||
|
uint16_t remaining_weight = doc["remaining_weight"].as<float>();
|
||||||
|
Serial.print("Aktuelles Gewicht: ");
|
||||||
|
Serial.println(remaining_weight);
|
||||||
|
oledShowMessage("Remaining: " + String(remaining_weight) + "g");
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelay(3000 / portTICK_PERIOD_MS);
|
||||||
|
doc.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Serial.println("Fehler beim Senden an Spoolman! HTTP Code: " + String(httpCode));
|
||||||
oledShowMessage("Spoolman update failed");
|
oledShowMessage("Spoolman update failed");
|
||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
@ -166,7 +186,7 @@ bool updateSpoolTagId(String uidString, const char* payload) {
|
|||||||
BaseType_t result = xTaskCreate(
|
BaseType_t result = xTaskCreate(
|
||||||
sendToApi, // Task-Funktion
|
sendToApi, // Task-Funktion
|
||||||
"SendToApiTask", // Task-Name
|
"SendToApiTask", // Task-Name
|
||||||
4096, // Stackgröße in Bytes
|
6144, // Stackgröße in Bytes
|
||||||
(void*)params, // Parameter
|
(void*)params, // Parameter
|
||||||
0, // Priorität
|
0, // Priorität
|
||||||
NULL // Task-Handle (nicht benötigt)
|
NULL // Task-Handle (nicht benötigt)
|
||||||
@ -174,6 +194,9 @@ bool updateSpoolTagId(String uidString, const char* payload) {
|
|||||||
|
|
||||||
updateDoc.clear();
|
updateDoc.clear();
|
||||||
|
|
||||||
|
// Update Spool weight
|
||||||
|
if (weight > 10) updateSpoolWeight(doc["sm_id"].as<String>(), weight);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +227,7 @@ uint8_t updateSpoolWeight(String spoolId, uint16_t weight) {
|
|||||||
BaseType_t result = xTaskCreate(
|
BaseType_t result = xTaskCreate(
|
||||||
sendToApi, // Task-Funktion
|
sendToApi, // Task-Funktion
|
||||||
"SendToApiTask", // Task-Name
|
"SendToApiTask", // Task-Name
|
||||||
4096, // Stackgröße in Bytes
|
6144, // Stackgröße in Bytes
|
||||||
(void*)params, // Parameter
|
(void*)params, // Parameter
|
||||||
0, // Priorität
|
0, // Priorität
|
||||||
NULL // Task-Handle (nicht benötigt)
|
NULL // Task-Handle (nicht benötigt)
|
||||||
@ -243,7 +266,7 @@ bool updateSpoolOcto(int spoolId) {
|
|||||||
BaseType_t result = xTaskCreate(
|
BaseType_t result = xTaskCreate(
|
||||||
sendToApi, // Task-Funktion
|
sendToApi, // Task-Funktion
|
||||||
"SendToApiTask", // Task-Name
|
"SendToApiTask", // Task-Name
|
||||||
4096, // Stackgröße in Bytes
|
6144, // Stackgröße in Bytes
|
||||||
(void*)params, // Parameter
|
(void*)params, // Parameter
|
||||||
0, // Priorität
|
0, // Priorität
|
||||||
NULL // Task-Handle (nicht benötigt)
|
NULL // Task-Handle (nicht benötigt)
|
||||||
@ -291,7 +314,7 @@ bool updateSpoolBambuData(String payload) {
|
|||||||
BaseType_t result = xTaskCreate(
|
BaseType_t result = xTaskCreate(
|
||||||
sendToApi, // Task-Funktion
|
sendToApi, // Task-Funktion
|
||||||
"SendToApiTask", // Task-Name
|
"SendToApiTask", // Task-Name
|
||||||
4096, // Stackgröße in Bytes
|
6144, // Stackgröße in Bytes
|
||||||
(void*)params, // Parameter
|
(void*)params, // Parameter
|
||||||
0, // Priorität
|
0, // Priorität
|
||||||
NULL // Task-Handle (nicht benötigt)
|
NULL // Task-Handle (nicht benötigt)
|
||||||
|
@ -674,6 +674,7 @@ bool setupMqtt() {
|
|||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
connected = false;
|
connected = false;
|
||||||
oledShowTopRow();
|
oledShowTopRow();
|
||||||
|
autoSetToBambuSpoolId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connected) return false;
|
if (!connected) return false;
|
||||||
@ -687,6 +688,8 @@ bool setupMqtt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void bambu_restart() {
|
void bambu_restart() {
|
||||||
|
Serial.println("Bambu restart");
|
||||||
|
|
||||||
if (BambuMqttTask) {
|
if (BambuMqttTask) {
|
||||||
vTaskDelete(BambuMqttTask);
|
vTaskDelete(BambuMqttTask);
|
||||||
delay(10);
|
delay(10);
|
||||||
|
@ -180,7 +180,8 @@ void loop() {
|
|||||||
lastWeightReadTime = currentMillis;
|
lastWeightReadTime = currentMillis;
|
||||||
|
|
||||||
// Prüfen ob die Waage korrekt genullt ist
|
// Prüfen ob die Waage korrekt genullt ist
|
||||||
if (autoTare && (weight > 0 && weight < 5) || weight < 0)
|
// Abweichung von 2g ignorieren
|
||||||
|
if (autoTare && (weight > 2 && weight < 7) || weight < -2)
|
||||||
{
|
{
|
||||||
scale_tare_counter++;
|
scale_tare_counter++;
|
||||||
}
|
}
|
||||||
@ -190,7 +191,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prüfen ob das Gewicht gleich bleibt und dann senden
|
// Prüfen ob das Gewicht gleich bleibt und dann senden
|
||||||
if (weight == lastWeight && weight > 5)
|
if (abs(weight - lastWeight) <= 2 && weight > 5)
|
||||||
{
|
{
|
||||||
weigthCouterToApi++;
|
weigthCouterToApi++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user