Files
room_glitch/tests/gpio/test_feedback.py
T
Jeff Luke c1b2195834 Expand Glitch operations hub, cabinet authoring, deployment, and RFID support
Operator hub
- Introduce Escape Gallery branding and Glitch: the Dark Machine room views
- Add cabinet illustrations, Pac-Man marquee/gameplay artwork, and waiting states
- Add device feedback panels with RFID readings, input/output states, and stale status
- Add logged operator hardware interventions with request deduplication

Room and cabinet authoring
- Add a visual custom-PCB connection editor with per-cabinet device inventory
- Support device IDs, bindings, wiring notes, input polarity, and validation
- Add physical-room label/dimension toggles and editable doorway annotations
- Preserve doorway changes through undo, save, and revert
- Expand cabinet profiles, room layout, and Glitch scenario resources

Scenarios and gameplay
- Add per-assignment game configuration and runtime feature validation
- Add timed test wins and Frogger individual-home objectives
- Add the three-cabinet timed/score/Frogger test scenario
- Add Cabinet 1 Pac-Man RFID credits, credit sound, and CREDIT 0/1 display
- Require physical Start after an accepted scan and prevent duplicate credits

Pi hardware and deployment
- Add GPIO feedback sampling and a separate multiplexed RFID helper
- Validate reader pin ownership and input/output conflicts
- Add SSH cabinet startup and Pi desktop-session service support
- Add master packaging, site setup, SSH enrollment, and staged cabinet releases
- Verify deployment manifests and support explicit activation/status/log commands

Documentation and verification
- Consolidate the root README around the current architecture and setup workflow
- Add the complete master/Pi/RFID export and deployment walkthrough
- Document network isolation, credentials, card identification, and rollback
- Add PCB, room-editor, feedback, credit, deployment, and controller tests
- Isolate protocol tests from designer-edited cabinet configurations

Known limitations
- RFID helper compilation and physical Pi commissioning remain unverified
- Fleet provisioning does not yet configure RFID-only installations completely
- Broader Pac-Man tests retain a ghost-capture assertion failure
- Staged exports must be rebuilt and checked before deploying runtime 2.3
2026-10-17 14:53:54 -07:00

47 lines
2.6 KiB
Python

import importlib.util
import json
import tempfile
import unittest
from pathlib import Path
from test_bridge import bridge
source=Path(__file__).resolve().parents[2]/'tools/pi_gpio/device_feedback.py'
spec=importlib.util.spec_from_file_location('feedback',source)
feedback=importlib.util.module_from_spec(spec);spec.loader.exec_module(feedback)
class Pin:
def __init__(self,pin,**kwargs): self.value=False;self.closed=False
def on(self):self.value=True
def off(self):self.value=False
def close(self):self.closed=True
class FeedbackTests(unittest.TestCase):
def config(self,data,pins):
with tempfile.TemporaryDirectory() as folder:
path=Path(folder)/'devices.json';path.write_text(json.dumps(data))
return feedback.load_devices(path,pins)
def test_pin_ownership(self):
with self.assertRaises(ValueError):self.config([dict(id='r',port='J1',kind='rfid')],[17])
with self.assertRaises(ValueError):self.config([dict(id='b',port='J17',kind='input',pull_up=True)],[16])
with self.assertRaises(ValueError):self.config([dict(id='b',port='J17',kind='input')],[25])
with self.assertRaises(ValueError):self.config([dict(id='x',port='J22',kind='output')],[18])
result=self.config([dict(id='r',port='J2',kind='rfid'),dict(id='b',port='J17',kind='input',pull_up=True)],[25])
self.assertEqual(result[1]['pin'],16)
def test_live_values_transitions_age_and_cleanup(self):
now=[100]
definitions=self.config([dict(id='button',port='J17',kind='input',pull_up=True),dict(id='lamp',port='J22',kind='output')],[25])
outputs=bridge.Outputs(Pin,'test',[25],clock=lambda:now[0])
monitor=feedback.Feedback(definitions,Pin,outputs,clock=lambda:now[0])
monitor.tick();first=monitor.snapshot();monitor.tick()
self.assertEqual(len(first['events']),len(monitor.snapshot()['events']))
monitor.inputs[0][1].value=True
outputs.command(dict(controller='test',pin=25,mode='pulse',duration_ms=200,active_high=True))
monitor.tick()
self.assertTrue(all(d['value'] for d in monitor.snapshot()['devices']))
now[0]+=.3;outputs.tick();monitor.tick()
self.assertFalse(monitor.snapshot()['devices'][1]['value'])
now[0]+=7
self.assertGreater(monitor.snapshot()['devices'][0]['age_ms'],6000)
pin=monitor.inputs[0][1];monitor.close();outputs.close();self.assertTrue(pin.closed)
def test_rfid_requires_helper(self):
outputs=bridge.Outputs(Pin,'test',[25])
with self.assertRaises(ValueError):feedback.Feedback([dict(id='r',kind='rfid',port='J1')],Pin,outputs)
outputs.close()