Browse Source

Increase scale moving average window to reduce weight bouncing

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.
maziggy 3 months ago
parent
commit
12fe0741b5
2 changed files with 2 additions and 2 deletions
  1. 1 1
      CHANGELOG.md
  2. 1 1
      spoolbuddy/daemon/scale_reader.py

+ 1 - 1
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

+ 1 - 1
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: