Feat : i1Pro 2 Visual LED Feedback in chartread #37
Notifications
Due Date
No due date set.
Blocks
Reference: gronod/argyllcms#37
Reference in New Issue
Block a user
Target Subsystem:
spectro/chartread.c,spectro/inst.h,spectro/i1pro.c,spectro/i1pro_imp.hSupported Hardware: X-Rite i1Pro 2 (Rev E)
Deliverable Format: Markdown Technical Implementation Specification
1. Executive Summary
This document specifies the technical architecture and code modifications required to implement real-time visual status feedback via the integrated ring LEDs on the X-Rite i1Pro 2 spectrophotometer within ArgyllCMS's
chartreadutility.The feature introduces a dedicated command-line flag to govern LED signaling across distinct stages of the chart-reading lifecycle:
If the command-line flag is omitted, or if an instrument lacking programmable RGB indicators (such as an i1Pro Rev A–D, ColorMunki, or third-party colorimeter) is connected, the operational behaviour degrades silently to default ArgyllCMS mechanics without throwing errors or halting execution.
2. Command-Line Switch Selection
2.1 Audit of Existing
chartreadOptionsAn audit of
spectro/chartread.cargument parsing confirms the following active options:-v[level]-cport-t-d-p-r-n-N-B-H-Ffilternone,pol,d65, etc.)-Tfactor-Afactor-ytype-Xfile.cal2.2 Selected Switch:
-LThe uppercase letter
-Lis unused inchartreadand serves as a mnemonic for LED status indicators.chartread -L [other_options] basename-Lis passed but the attached spectrophotometer does not expose theinst_stat_ledscapability, the flag is silently ignored.3. LED Functional State Matrix
The i1Pro 2 (Rev E) features two multi-colour LEDs flanking the optical button. Both LEDs are driven concurrently to ensure 360° visibility.
#FFFFFF)#0000FF)#FF0000)#00FF00)#000000)SIGINT.4. Architectural Design & Abstraction Layers
To maintain clean separation between Argyll's hardware-agnostic application layer (
chartread.c) and device-specific driver code, the implementation is divided across two architectural boundaries:5. Driver Layer Implementation (
spectro/)5.1 Interface Extensions:
spectro/inst.hAdd enumeration states and function pointer signatures to the generic instrument interface:
Default instruments initialize
set_led_statetoNULLininst.c.5.2 Hardware Control Implementation:
spectro/i1pro.c5.2.1 USB Command Format
The i1Pro 2 (Rev E) microcontroller interprets LED commands sent via Bulk OUT transfers to Endpoint
0x05. Commands comprise 5-byte sequences:Note on Rev E Firmware Revisions:
Depending on the internal microcontroller ROM revision, Byte 1 either specifies raw RGB channel levels directly or acts as an operating mode (
0x00= Off,0x01= Static,0x02= Flash/Pulse). The implementation must support a low-level static calli1pro2_raw_led(p, r, g, b)and execute timing/flashing through an internal worker thread to guarantee timing consistency across firmware revisions.5.2.2 Flashing Management Thread
To prevent blocking synchronous measurements during strip readings, LED pulsing must execute asynchronously:
5.2.3 Low-Level C Implementations in
spectro/i1pro.c5.2.4 Initialisation and Teardown Safety
To prevent crashes on device shutdown (such as the null-pointer dereference previously observed in
del_i1proimp):In
i1pro_init_inst():Initialise mutex and thread handles if
devtype == inst_i1pro2.In
i1pro_close_port()anddel_i1proimp():Stop the LED thread and join it before deallocating the underlying
icomsport pointers:6. Application Layer Integration (
spectro/chartread.c)6.1 CLI Flag Parsing
In
spectro/chartread.c, introduce the global configuration variable:Add
-Linto theargvparser loop:Update usage text:
6.2 Helper Dispatch Function
Add a safe execution wrapper in
chartread.c:6.3 Lifecycle Hook Points
Hook 1: Calibration Prompt
Locate the white tile calibration sequence in
chartread.c:Hook 2: Ready to Read Patch Row
At the beginning of each row cycle (strip read preparation):
Hook 3: Scan Evaluation (Success vs Failure)
Inspect the return code of
read_strip():Hook 4: Cleanup on Exit
Ensure all LEDs are extinguished when
chartreadexits cleanly or via error branches:7. Verification & Testing Matrix
Execute the following test cases to validate conformance:
chartread targetchartread -L target-Lswitch parsed; driver detects lack ofINST_CAP_LED_STATUS; runs normally with zero errors.chartread -L targetchartread -L targetchartread -L targetchartread -L targetSIGINT/ Esc)chartread -L target