mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-03 12:46:49 +02:00
fix(spoolbuddy): gate display wake on stable scale reading A noisy load cell that bounced ≥50 g around its midpoint kept the kiosk screen permanently lit. The wake threshold check ran against last_wake_grams which itself advanced to noisy values, so every bounce back across 50 g re-fired display.wake(), keeping the FIFO reader pumping wlopm --on faster than swayidle could trigger wlopm --off. The fix gates wake on the scale's `stable` flag — only readings that have settled within 2 g over a 1 s window count as a real spool placement / removal. Unstable noise can't fire wake and can't advance last_wake_grams, so the next genuine settled change is still measured against the right baseline. Three regression tests pin the contract: noisy ±60 g unstable readings never wake, a settled >50 g jump wakes, a noise burst between two settled readings doesn't poison last_wake_grams.