Skip to content

feat(console): analog-input calibration UI (two-point, deadband) + wire 0xA5/0xA6/0xA7 + ai_cal (S2) — Studio v0.75 - #191

Open
mbreiser wants to merge 2 commits into
feat/console-analog-infrom
feat/console-analog-cal
Open

feat(console): analog-input calibration UI (two-point, deadband) + wire 0xA5/0xA6/0xA7 + ai_cal (S2) — Studio v0.75#191
mbreiser wants to merge 2 commits into
feat/console-analog-infrom
feat/console-analog-cal

Conversation

@mbreiser

@mbreiser mbreiser commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Studio half S2 of docs/development/analog-input-plan.md § 4. Stacks on S1 (#190) — retarget to main as #190 merges. Pairs with firmware F2 (reiserlab/LED-Display_G6_Firmware_Arena branch feat/ai-calibration); without that firmware the panel says "needs ai_cal firmware" and the calibration controls do nothing.

What changed (Studio v0.75)

Analog In panel → calibrate row

  • Channel select · Read (GET_ANALOG_CAL 0xA7 + GET_ANALOG_IN_RAW 0xA5) → a table per channel: state (calibrated (both points) / +10 V point ✓ · 0 V point — / no points), the two raw points, mV per count and offset, deadband, and the live raw count evaluated on the calibrated and the nominal scale so the effect of the calibration is visible.
  • 1 · Sample +10 V (open) and 2 · Sample 0 V (ground cap) — the guided two steps (SET_ANALOG_CAL actions 1 and 0); the controller averages 256 reads and stores the point. A +10 V point reading low is called out (BNC not open, or an un-reworked LAB-209 board).
  • Deadband (default 20 mV) Set · Clear with confirmation.
  • Writes are advanced-mode only (added to SAFE_BLOCKED_CMDS; Read stays available), gated on the ai_cal capability, logged to the Console and to the bridge run log (event: 'analog_cal' with the returned record), and they refresh the panel's flags text.

Wire (js/arena-wire-g6.js): GET_ANALOG_IN_RAW 0xA5 / SET_ANALOG_CAL 0xA6 / GET_ANALOG_CAL 0xA7, ANALOG_CAL_ACTIONS, encodeSetAnalogCal(ch, action, mv) with range checks, decodeAnalogCal (18-byte record → channels with the implied line a/b), decodeAnalogInRaw, capability bit 6 ai_cal.

Module (js/studio-analog-in.js): nominalMv, calLine, calMv, calStepsText, describeCalSource, calTableRows.

Tests

  • tests/test-arena-wire-g6.js 186 → 204: encoders (names and codes, deadband bytes), rejections (ch 3, unknown action, deadband range/type), record decode (header, valid channel line a/b, invalid channel, short payload), raw decode, capability name.
  • tests/test-studio-analog-in.js 105 → 148: nominal/calibrated math, step text, source text, table rows with and without live raws; HTML wiring — element ids, all five handlers, the safe-mode set blocks the four writes and not the read, the ai_cal gate, the analog_cal log event, the clear confirmation, footer v0.75.
  • Full pixi run test passes; touched JS Prettier-clean; inline Studio scripts parse.
  • Not bench-tested (no hardware): the real two-point flow needs a board with the F2 firmware and a BNC ground cap — plan § 5.2 C1–C3.

🤖 Generated with Claude Code

mbreiser and others added 2 commits September 7, 2026 17:15
…o-point, deadband, clear, read) + wire 0xA5/0xA6/0xA7 + ai_cal capability (S2) — Studio v0.75

Studio half S2 of docs/development/analog-input-plan.md § 4. Stacked on S1
(feat/console-analog-in). Pairs with firmware F2 (feat/ai-calibration).

- js/arena-wire-g6.js: OPCODES SET_ANALOG_CAL 0xA5 / GET_ANALOG_CAL 0xA6 /
  GET_ANALOG_IN_RAW 0xA7; ANALOG_CAL_ACTIONS {sampleGround 0, sampleOpen 1,
  setDeadband 2, clear 0xFF}; encodeSetAnalogCal(ch, action, mv) with range
  checks, encodeGetAnalogCal, encodeGetAnalogInRaw; decodeAnalogCal (18-byte
  record -> {version, adcBits, source, sdMirrorOk, channels[{valid, rawOpen,
  rawGnd, deadbandMv, gainMvPerCount, offsetMv}]}), decodeAnalogInRaw;
  CAPABILITY_BITS bit 6 'ai_cal'. Tests 186 -> 204.
- js/studio-analog-in.js: nominalMv, calLine, calMv, calStepsText,
  describeCalSource, calTableRows.
- arena_studio.html: "calibrate" row in the Analog In panel — channel select,
  Read (0xA6 + 0xA7 -> table with both points, mV/count, offset, deadband, live
  raw on the calibrated and nominal scales), "1 · Sample +10 V (open)",
  "2 · Sample 0 V (ground cap)", deadband Set, Clear (confirm). Writes are
  advanced-only (SAFE_BLOCKED_CMDS) and gated on the ai_cal capability; every
  write is logged to the Console and to the bridge run log (event analog_cal),
  and refreshes the 0xA4 flags text. Warns when the +10 V point reads low
  (BNC not open / un-reworked board). HELP text updated; footer v0.75.
- tests/test-studio-analog-in.js 105 -> 148: calibration math + wiring incl.
  the safe-mode set (writes blocked, read allowed) and the ai_cal gate.
- Release notes v0.75.

Not bench-tested (no hardware). Browser check offline: panel renders, handlers
wired; the real two-point flow needs a board with ai_cal firmware.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… 0xA5 get-analog-in-raw, 0xA6 set-analog-cal, 0xA7 get-analog-cal (matches firmware feat/ai-calibration)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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