Compare commits

...
11 Commits
25 changed files with 1747 additions and 20 deletions

No files matched your search

-7
View File
@@ -13,13 +13,8 @@
**/.Trashes
**/.fseventsd
.AppleDouble
.aider.chat.history.md
.aider.input.history
.DS_Store
.gitignore
.aider.tags.cache.v3/cache.db
.aider.tags.cache.v3/cache.db-shm
.aider.tags.cache.v3/cache.db-wal
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
@@ -28,7 +23,6 @@
include/README
lib/README
test/README
.aider*
# important
html/bambu_credentials.json
@@ -36,5 +30,4 @@ html/spoolman_url.json
_local/*
website/*
release.sh
.github/copilot-instructions.md
wiki
+43
View File
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Filament Management Tool</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
<script>
fetch('/version.txt')
.then(response => response.text())
.then(version => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + version.trim();
}
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
Binary file not shown.
+90
View File
@@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Filament Management Tool</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
<script>
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>FilaMan</h1>
<p>Filament Management Tool</p>
<p>Your smart solution for <strong>Filament Management</strong> in 3D printing.</p>
<h2>About FilaMan</h2>
<p>
FilaMan is a tool designed to simplify filament spool management. It allows you to identify and weigh filament spools,
automatically syncing data with the FilaMan-System.
</p>
<p>Get more information at <a href="https://www.filaman.app" target="_blank">https://www.filaman.app</a>.</p>
<div class="features">
<div class="feature">
<h3>Spool Identification</h3>
<p>Easily identify filament spools using NFC tags.</p>
</div>
<div class="feature">
<h3>Automatic Syncing</h3>
<p>Seamlessly update spool data with the FilaMan API for accurate tracking.</p>
</div>
<div class="feature">
<h3>Scale Integration</h3>
<p>Built-in scale support for precise remaining weight calculation.</p>
</div>
</div>
</div>
<script>
let ws = null;
function connectWebSocket() {
ws = new WebSocket(`ws://${window.location.hostname}/ws`);
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'heartbeat') {
document.getElementById('filamanDot').style.backgroundColor = data.filaman_connected ? '#4caf50' : '#f44336';
document.getElementById('ramStatus').textContent = data.freeHeap + ' KB free';
}
};
ws.onclose = () => setTimeout(connectWebSocket, 2000);
}
connectWebSocket();
setInterval(() => { if(ws && ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({type:'heartbeat'})); }, 5000);
</script>
</body>
</html>
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
View File
Binary file not shown.
+104
View File
@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Setup</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
<script>
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>Device Setup</h1>
<div class="card">
<div class="card-body">
<h5 class="card-title">Registration</h5>
<p>Status: <strong>{{registered}}</strong></p>
<div class="form-group">
<label for="filamanUrl">FilaMan API URL:</label>
<input type="text" id="filamanUrl" class="form-control" value="{{filamanUrl}}" placeholder="http://192.168.1.10:8000">
</div>
<div class="form-group mt-2">
<label for="deviceCode">Registration Code (6 digits):</label>
<input type="text" id="deviceCode" class="form-control" maxlength="6" placeholder="123456">
</div>
<button id="registerBtn" class="btn btn-primary mt-3">Register Device</button>
<div id="statusMessage" class="mt-3"></div>
</div>
</div>
</div>
<script>
document.getElementById('registerBtn').addEventListener('click', () => {
const url = document.getElementById('filamanUrl').value;
const code = document.getElementById('deviceCode').value;
const statusMessage = document.getElementById('statusMessage');
if (!url || !code) {
statusMessage.innerHTML = 'Please provide both URL and Code';
statusMessage.className = 'alert alert-danger';
return;
}
statusMessage.innerHTML = 'Registering...';
statusMessage.className = 'alert alert-info';
fetch('/api/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url: url, code: code })
})
.then(response => response.json())
.then(data => {
if (data.success) {
statusMessage.innerHTML = 'Registration successful! Rebooting...';
statusMessage.className = 'alert alert-success';
setTimeout(() => fetch('/reboot'), 2000);
} else {
statusMessage.innerHTML = 'Registration failed. Check code and URL.';
statusMessage.className = 'alert alert-danger';
}
})
.catch(error => {
console.error('Error:', error);
statusMessage.innerHTML = 'Network error.';
statusMessage.className = 'alert alert-danger';
});
});
</script>
</body>
</html>
Binary file not shown.
+1207
View File
File diff suppressed because it is too large. Load diff
BIN
View File
Binary file not shown.
+151
View File
@@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Filament Management Tool</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
<script>
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>Firmware Upgrade</h1>
<div class="warning">
<strong>Warning:</strong> Do not power off the device during update.
</div>
<div class="update-options">
<div class="update-section">
<h2>1) Firmware Update</h2>
<p>Upload a new firmware file (upgrade_filaman_firmware_*.bin)</p>
<div class="update-form">
<form id="firmwareForm" enctype='multipart/form-data' data-type="firmware">
<input type='file' name='update' accept='.bin' required>
<input type='submit' value='Start Firmware Update' class="btn btn-primary">
</form>
</div>
</div>
<div class="update-section">
<h2>2) Webpage Update</h2>
<p>Upload a new webpage file (upgrade_filaman_website_*.bin)</p>
<div class="update-form">
<form id="webpageForm" enctype='multipart/form-data' data-type="webpage">
<input type='file' name='update' accept='.bin' required>
<input type='submit' value='Start Webpage Update' class="btn btn-primary">
</form>
</div>
</div>
</div>
<div class="progress-container" style="display: none;">
<div class="progress-bar">0%</div>
</div>
<div class="status"></div>
</div>
<script>
const progress = document.querySelector('.progress-bar');
const progressContainer = document.querySelector('.progress-container');
const status = document.querySelector('.status');
let updateInProgress = false;
let lastReceivedProgress = 0;
// WebSocket Handling
let ws = null;
function connectWebSocket() {
ws = new WebSocket('ws://' + window.location.host + '/ws');
ws.onmessage = function(event) {
const data = JSON.parse(event.data);
if (data.type === "heartbeat") {
document.getElementById('filamanDot').style.backgroundColor = data.filaman_connected ? '#4caf50' : '#f44336';
document.getElementById('ramStatus').textContent = data.freeHeap + ' KB free';
}
if (data.type === "updateProgress" && updateInProgress) {
progressContainer.style.display = 'block';
const newProgress = parseInt(data.progress);
if (!isNaN(newProgress) && newProgress >= lastReceivedProgress) {
progress.style.width = newProgress + '%';
progress.textContent = newProgress + '%';
lastReceivedProgress = newProgress;
}
if (data.message) {
status.textContent = data.message;
status.style.display = 'block';
}
}
};
ws.onclose = () => setTimeout(connectWebSocket, 2000);
}
connectWebSocket();
function handleUpdate(e) {
e.preventDefault();
const form = e.target;
const file = form.update.files[0];
const updateType = form.dataset.type;
if (!file) return;
updateInProgress = true;
progressContainer.style.display = 'block';
status.style.display = 'none';
progress.style.width = '0%';
document.querySelectorAll('form input[type=submit]').forEach(btn => btn.disabled = true);
const xhr = new XMLHttpRequest();
xhr.open('POST', '/update', true);
xhr.onload = function() {
if (xhr.status !== 200) {
status.textContent = "Update failed: " + xhr.responseText;
status.style.display = 'block';
updateInProgress = false;
document.querySelectorAll('form input[type=submit]').forEach(btn => btn.disabled = false);
}
};
const formData = new FormData();
formData.append('update', file);
xhr.send(formData);
}
document.getElementById('firmwareForm').addEventListener('submit', handleUpdate);
document.getElementById('webpageForm').addEventListener('submit', handleUpdate);
</script>
</body>
</html>
Binary file not shown.
+7 -2
View File
@@ -30,10 +30,15 @@
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/config">Config</a>
<a href="/about">About</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
+67
View File
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Filament Management Tool</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
<script>
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>WiFi Configuration</h1>
<p>Your device is connected to WiFi.</p>
<p>To change WiFi settings, you can reset the WiFi configuration by holding the hardware button (if available) or using the WiFi manager portal.</p>
</div>
<script>
let ws = null;
function connectWebSocket() {
ws = new WebSocket(`ws://${window.location.hostname}/ws`);
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'heartbeat') {
document.getElementById('filamanDot').style.backgroundColor = data.filaman_connected ? '#4caf50' : '#f44336';
document.getElementById('ramStatus').textContent = data.freeHeap + ' KB free';
}
};
ws.onclose = () => setTimeout(connectWebSocket, 2000);
}
connectWebSocket();
setInterval(() => { if(ws && ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({type:'heartbeat'})); }, 5000);
</script>
</body>
</html>
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html
[common]
version = "3.0.5"
version = "3.0.8"
to_old_version = "2.0.10"
##
+23 -1
View File
@@ -105,8 +105,30 @@ bool sendWeight(int spoolId, String tagUuid, float measuredWeight) {
String payload;
serializeJson(doc, payload);
int httpCode = http.POST(payload);
if (httpCode == 200) {
String response = http.getString();
JsonDocument responseDoc;
DeserializationError error = deserializeJson(responseDoc, response);
if (!error && responseDoc["remaining_weight_g"].is<float>()) {
int remaining = (int)responseDoc["remaining_weight_g"].as<float>();
pauseMainTask = 1;
oledShowRemainingWeight(remaining);
vTaskDelay(pdMS_TO_TICKS(3000));
pauseMainTask = 0;
}
http.end();
return true;
}
else {
pauseMainTask = 1;
oledShowProgressBar(1, 1, "Failure", "API Error");
vTaskDelay(pdMS_TO_TICKS(2000));
pauseMainTask = 0;
}
http.end();
return (httpCode == 200);
return false;
}
bool sendLocation(int spoolId, String spoolTagUuid, int locationId, String locationTagUuid) {
+15
View File
@@ -50,6 +50,21 @@ bool loadJsonValue(const char* filename, JsonDocument& doc) {
return true;
}
String readFile(const char* filename) {
File file = LittleFS.open(filename, "r");
if (!file) {
Serial.print("Fehler beim Öffnen der Datei: ");
Serial.println(filename);
return "";
}
String content = "";
while (file.available()) {
content += (char)file.read();
}
file.close();
return content;
}
void initializeFileSystem() {
if (!LittleFS.begin(true)) {
Serial.println("LittleFS Mount Failed");
+1
View File
@@ -8,6 +8,7 @@
bool removeJsonValue(const char* filename);
bool saveJsonValue(const char* filename, const JsonDocument& doc);
bool loadJsonValue(const char* filename, JsonDocument& doc);
String readFile(const char* filename);
void initializeFileSystem();
#endif
+13
View File
@@ -254,6 +254,19 @@ void oledShowWeight(uint16_t weight) {
display.display();
}
void oledShowRemainingWeight(uint16_t remainingWeight) {
oledcleardata();
display.setTextSize(1);
display.setCursor(oled_center_h("Weight sent, rest:"), OLED_DATA_START + 4);
display.print("Weight sent, rest:");
display.setTextSize(3);
String weightStr = String(remainingWeight) + " g";
display.setCursor(oled_center_h(weightStr), OLED_DATA_START + 22);
display.print(weightStr);
display.display();
}
void oledShowConnectionError(const char* error, const String& ip) {
oledcleardata();
display.setTextSize(1);
+1
View File
@@ -19,6 +19,7 @@ int oled_center_v(const String &text);
void oledShowProgressBar(const uint8_t step, const uint8_t numSteps, const char* largeText, const char* statusMessage);
void oledShowWeight(uint16_t weight);
void oledShowRemainingWeight(uint16_t remainingWeight);
void oledDisplayText(const String &message, uint8_t size = 2);
void oledShowConnectionError(const char* error, const String& ip);
void oledShowTopRow();
+9 -7
View File
@@ -162,7 +162,7 @@ void loop() {
{
// Use filtered weight for smooth display, but still check API weight for significant changes
int16_t displayWeight = getFilteredDisplayWeight();
if (mainTaskWasPaused || (weight != lastWeight && nfcReaderState == NFC_IDLE))
if (mainTaskWasPaused || (weight != lastWeight && (nfcReaderState == NFC_IDLE || tagProcessed)))
{
(displayWeight < 2) ? ((displayWeight < -2) ? oledDisplayText("!! -0") : oledShowWeight(0)) : oledShowWeight(displayWeight);
}
@@ -191,12 +191,6 @@ void loop() {
}
}
// reset weight counter after writing tag
if (currentMillis - lastWeightReadTime >= weightReadInterval && nfcReaderState != NFC_IDLE && nfcReaderState != NFC_READ_SUCCESS)
{
weightCounterToApi = 0;
}
lastWeight = weight;
// Wenn ein Tag erkannt wurde und das Gewicht stabil ist, an FilaMan senden
@@ -211,6 +205,10 @@ void loop() {
sendWeightAsync(sId, activeTagUuid, weight);
weightSend = 1;
Serial.println("Weight queued for FilaMan");
// Feedback to user
pauseMainTask = 1;
oledShowProgressBar(3, 4, "Spool Tag", "Sending...");
}
// Handle successful tag write
@@ -221,6 +219,10 @@ void loop() {
sendWeightAsync(sId, activeTagUuid, weight);
weightSend = 1;
Serial.println("Weight queued for FilaMan after tag write");
// Feedback to user
pauseMainTask = 1;
oledShowProgressBar(3, 4, "Tag written", "Sending...");
}
}
+2
View File
@@ -2025,6 +2025,7 @@ void scanRfidTask(void * parameter) {
nfcJsonData = "";
activeSpoolId = "";
activeTagUuid = "";
tagProcessed = false;
oledShowWeight(weight);
}
@@ -2032,6 +2033,7 @@ void scanRfidTask(void * parameter) {
else if (!success && nfcReaderState == NFC_READ_SUCCESS)
{
nfcReaderState = NFC_IDLE;
tagProcessed = false;
Serial.println("Tag nach erfolgreichem Lesen entfernt - bereit für nächsten Tag");
}
+13 -2
View File
@@ -128,14 +128,19 @@ void setupWebserver(AsyncWebServer &server) {
server.on("/waage", HTTP_GET, [](AsyncWebServerRequest *request){
Serial.println("Web: Request /waage");
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/waage.html", "text/html");
String html = readFile("/waage.html");
html.replace("{{autoTare}}", autoTare ? "checked" : "");
auto response = request->beginResponse(200, "text/html", html);
response->addHeader("Cache-Control", NO_CACHE);
request->send(response);
});
server.on("/setup", HTTP_GET, [](AsyncWebServerRequest *request){
Serial.println("Web: Request /setup");
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/setup.html", "text/html");
String html = readFile("/setup.html");
html.replace("{{registered}}", filamanRegistered ? "Registered" : "Not Registered");
html.replace("{{filamanUrl}}", filamanUrl);
auto response = request->beginResponse(200, "text/html", html);
response->addHeader("Cache-Control", NO_CACHE);
request->send(response);
});
@@ -154,6 +159,12 @@ void setupWebserver(AsyncWebServer &server) {
request->send(response);
});
server.on("/version.txt", HTTP_GET, [](AsyncWebServerRequest *request){
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/version.txt", "text/plain");
response->addHeader("Cache-Control", NO_CACHE);
request->send(response);
});
server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request){
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/style.css", "text/css");
response->addHeader("Cache-Control", NO_CACHE);