Skip to content

trial-params gain widen (int16) + controller-run duration (arena-fw #4)#154

Open
floesche wants to merge 1 commit into
reiserlab:mainfrom
floesche:gh4-trial-params-relayout
Open

trial-params gain widen (int16) + controller-run duration (arena-fw #4)#154
floesche wants to merge 1 commit into
reiserlab:mainfrom
floesche:gh4-trial-params-relayout

Conversation

@floesche

@floesche floesche commented Jul 7, 2026

Copy link
Copy Markdown
Member

Match the firmware's canonical trial_params (0x08) re-layout from reiserlab/LED-Display_G6_Firmware_Arena#4: gain widens from int8 to int16 and moves after init_pos, and a new duration field lets the controller auto-stop a trial on its own instead of relying on a host follow-up command.

  • encodeTrialParams: reordered params (init_pos @5-6, gain @7-8, duration @9-10), gain now uses the existing i16le helper (int8 helper dropped), duration stays in seconds at the JS API boundary and converts to 10 ms ticks on the wire (AC::constants::duration_tick_ms, matching the firmware)
  • buildTrialParams: carries duration through from the trialParams command, same convention as conditionDuration's wait/trialParams math
  • hostSideTrialEnd/ArenaRunner._timer/the setTimeout mechanism is untouched — host-side timing stays authoritative for now; the wire-side duration just unblocks that swap for later, it isn't made here (kept the blast radius small until this is bench-verified)
  • golden-vector tests rewritten for the new offsets and widened gain range, plus new duration vectors and range-throw cases

This is a breaking wire change — bytes 5-10 of the 0x08 payload are reinterpreted — and ships in lockstep with the companion Arena-Firmware PR. A stale pairing would silently misparse gain/init_pos/duration into garbage that still returns status == 0.

Verification

  • pixi run test: full suite passes, including the rewritten trial-params golden vectors in tests/test-arena-wire-g6.js and tests/test-arena-runner-g6.js
  • pixi run format-check
  • Bench-verified against the paired Arena-Firmware branch: fed encodeTrialParams()'s actual output bytes to a Teensy 4.1 over serial and confirmed Mode 2 (initPos=9, gain=-20, duration=1.5s) applies init_pos correctly and auto-stops to ALL_OFF on its own, and Mode 4 gain=2000 (past the old int8 ceiling) is accepted

Test plan

  • pixi run test
  • pixi run format-check
  • Hardware round-trip with Arena-Firmware gh4-trial-params-relayout
  • Merge together with the Arena-Firmware PR, not independently

This is part of the reiserlab/LED-Display_G6_Firmware_Arena#35 PR

…ration (arena-fw reiserlab#4)

Match the firmware's canonical trial-params re-layout: gain moves after
init_pos and widens to int16, and a new duration field (seconds at the JS
API boundary, encoded as 10ms ticks) lets the controller auto-stop a trial
on its own.

- encodeTrialParams: reordered params, gain now i16le, duration converts
  seconds -> ticks; dropped the now-dead int8Byte helper
- buildTrialParams: carries duration through from the trialParams command
  (same seconds convention as conditionDuration's wait/trialParams math)
- hostSideTrialEnd/SWAP POINT comment untouched — host-side timing stays
  authoritative for now; wire-side duration just unblocks the future swap
- tests: rewrote trial-params golden vectors + runner fixtures for the new
  offsets and widened gain range
@floesche floesche requested a review from mbreiser July 7, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant