Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a7d3318a2 | ||
|
|
9875e85e31 | ||
|
|
741a7d9262 | ||
|
|
8bad4fe256 | ||
|
|
185cb5b081 | ||
|
|
0d9132127a | ||
|
|
d39d481c65 | ||
|
|
1cae1e3ae1 | ||
|
|
f616d37463 | ||
|
|
5a3f6dc951 | ||
|
|
488b5ca6a2 | ||
|
|
9813bdc94f | ||
|
|
e06dcc398e | ||
|
|
251770398e |
No files matched your search
@@ -6,6 +6,15 @@ on:
|
||||
RELEASE_TOKEN:
|
||||
description: 'GitHub token for release creation'
|
||||
required: true
|
||||
FTP_PASSWORD:
|
||||
description: 'FTP Password'
|
||||
required: false
|
||||
FTP_USER:
|
||||
description: 'FTP User'
|
||||
required: false
|
||||
FTP_HOST:
|
||||
description: 'FTP Host'
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -163,13 +172,6 @@ jobs:
|
||||
FTP_HOST: ${{ secrets.FTP_HOST }}
|
||||
VERSION: ${{ steps.get_version.outputs.VERSION }}
|
||||
run: |
|
||||
echo "Environment variables:"
|
||||
env | grep -E '^FTP_' | while read -r line; do
|
||||
var_name=$(echo "$line" | cut -d= -f1)
|
||||
var_value=$(echo "$line" | cut -d= -f2-)
|
||||
echo "$var_name is $(if [ -n "$var_value" ]; then echo "set"; else echo "empty"; fi)"
|
||||
done
|
||||
|
||||
cd .pio/build/esp32dev
|
||||
if [ -n "$FTP_USER" ] && [ -n "$FTP_PASSWORD" ] && [ -n "$FTP_HOST" ]; then
|
||||
echo "All FTP credentials are present, attempting upload..."
|
||||
|
||||
@@ -32,6 +32,9 @@ jobs:
|
||||
uses: ./.github/workflows/github-release.yml
|
||||
secrets:
|
||||
RELEASE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
|
||||
FTP_USER: ${{ secrets.FTP_USER }}
|
||||
FTP_HOST: ${{ secrets.FTP_HOST }}
|
||||
|
||||
gitea-release:
|
||||
needs: detect-provider
|
||||
|
||||
@@ -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
|
||||
@@ -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.
@@ -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.
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
+104
@@ -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
File diff suppressed because it is too large.
Load diff
Binary file not shown.
@@ -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
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
Binary file not shown.
+1
-1
@@ -9,7 +9,7 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[common]
|
||||
version = "3.0.3"
|
||||
version = "3.0.8"
|
||||
to_old_version = "2.0.10"
|
||||
|
||||
##
|
||||
|
||||
+23
-1
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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
@@ -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...");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user