From 12fe0741b5c5d321bb35e7a419a254fc067ec900 Mon Sep 17 00:00:00 2001 From: maziggy Date: Tue, 24 Feb 2026 10:29:42 +0100 Subject: [PATCH] Increase scale moving average window to reduce weight bouncing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5 samples at 100ms (500ms window) wasn't enough to smooth NAU7802 ADC noise — the averaged value still varied by >2g between 1s report intervals, and the stability state kept flipping, triggering a report every cycle. Increased to 20 samples (2s window) so noise is smoothed before reaching the reporting layer. --- CHANGELOG.md | 2 +- spoolbuddy/daemon/scale_reader.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12511fb9e..c48f440a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ All notable changes to Bambuddy will be documented in this file. - **SpoolBuddy Daemon Can't Find Hardware Drivers** — The daemon's `nfc_reader.py` and `scale_reader.py` import `read_tag` and `scale_diag` as bare modules, but these files live in `spoolbuddy/scripts/` which isn't on Python's module search path. The systemd service sets `WorkingDirectory` to `spoolbuddy/` and runs `python -m daemon.main`, so only the `spoolbuddy/` and `daemon/` directories are on `sys.path`. Added `scripts/` to `sys.path` at daemon startup, resolved relative to the module file so it works regardless of install path. Also moved the `read_tag` import inside `NFCReader.__init__`'s try/except block — it was previously outside, so a missing module crashed the entire daemon instead of gracefully skipping NFC polling. Demoted hardware-not-available log messages from ERROR to INFO since missing modules are expected when hardware isn't connected. ### Improved -- **SpoolBuddy Scale Value Stabilization** — The SpoolBuddy daemon now suppresses redundant scale weight reports: only sends updates when the weight changes by ≥2g or the stability state flips (stable ↔ unstable). Previously every 1-second report interval sent a reading regardless of change, causing the dashboard weight display to bounce continuously. The frontend also applies a 3g display threshold as defense-in-depth. +- **SpoolBuddy Scale Value Stabilization** — The SpoolBuddy daemon now suppresses redundant scale weight reports: only sends updates when the weight changes by ≥2g or the stability state flips (stable ↔ unstable). Previously every 1-second report interval sent a reading regardless of change, causing the dashboard weight display to bounce continuously. Also increased the NAU7802 moving average window from 5 to 20 samples (500ms → 2s), which smooths ADC noise enough that the averaged value stays within the 2g report threshold between intervals and the stability state stops flipping. The frontend also applies a 3g display threshold as defense-in-depth. - **SpoolBuddy TopBar: Online Printer Selection** — The printer selector in the SpoolBuddy top bar now only shows online printers and auto-selects the first online printer. If the currently selected printer goes offline, it automatically switches to the next available online printer. Also replaced the placeholder icon with the SpoolBuddy logo. ## [0.2.1] - 2026-02-27 diff --git a/spoolbuddy/daemon/scale_reader.py b/spoolbuddy/daemon/scale_reader.py index 9579f8f8f..fa954beba 100644 --- a/spoolbuddy/daemon/scale_reader.py +++ b/spoolbuddy/daemon/scale_reader.py @@ -6,7 +6,7 @@ from collections import deque logger = logging.getLogger(__name__) -MOVING_AVG_SIZE = 5 +MOVING_AVG_SIZE = 20 class ScaleReader: