1 #ifndef SPYD2_H 2 3 /* 4 * Argyll Color Correction System 5 * 6 * ColorVision Spyder 2 & 3 related software. 7 * 8 * Author: Graeme W. Gill 9 * Date: 19/10/2006 10 * 11 * Copyright 2006 - 2013, Graeme W. Gill 12 * All rights reserved. 13 * 14 * (Based on i1disp.c) 15 * 16 * This material is licenced under the GNU GENERAL PUBLIC LICENSE Version 2 or later :- 17 * see the License2.txt file for licencing details. 18 */ 19 20 /* 21 If you make use of the instrument driver code here, please note 22 that it is the author(s) of the code who take responsibility 23 for its operation. Any problems or queries regarding driving 24 instruments with the Argyll drivers, should be directed to 25 the Argyll's author(s), and not to any other party. 26 27 If there is some instrument feature or function that you 28 would like supported here, it is recommended that you 29 contact Argyll's author(s) first, rather than attempt to 30 modify the software yourself, if you don't have firm knowledge 31 of the instrument communicate protocols. There is a chance 32 that an instrument could be damaged by an incautious command 33 sequence, and the instrument companies generally cannot and 34 will not support developers that they have not qualified 35 and agreed to support. 36 */ 37 38 #include "inst.h" 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Note: update spyd2_interp_error() and spyd2_interp_code() in spyd2.c */ 45 /* if anything of these #defines are added or subtracted */ 46 47 /* Fake Error codes */ 48 #define SPYD2_INTERNAL_ERROR 0x61 /* Internal software error */ 49 #define SPYD2_COMS_FAIL 0x62 /* Communication failure */ 50 #define SPYD2_UNKNOWN_MODEL 0x63 /* Not an spyd2lay */ 51 #define SPYD2_DATA_PARSE_ERROR 0x64 /* Read data parsing error */ 52 53 /* Real error code */ 54 #define SPYD2_OK 0x00 55 56 /* Sub codes for device specific reasoning */ 57 #define SPYD2_BADSTATUS 0x01 58 #define SPYD2_PLDLOAD_FAILED 0x02 59 #define SPYD2_BADREADSIZE 0x03 60 #define SPYD2_TRIGTIMEOUT 0x04 61 #define SPYD2_OVERALLTIMEOUT 0x05 62 #define SPYD2_BAD_EE_CRC 0x06 63 #define SPYD2_TOOBRIGHT 0x07 64 65 /* Internal software errors */ 66 #define SPYD2_BAD_EE_ADDRESS 0x21 67 #define SPYD2_BAD_EE_SIZE 0x22 68 #define SPYD2_NO_PLD_PATTERN 0x23 69 #define SPYD2_NO_COMS 0x24 70 #define SPYD2_NOT_INITED 0x25 71 #define SPYD2_NOCRTCAL 0x26 /* No CRT calibration data */ 72 #define SPYD2_NOLCDCAL 0x27 /* No LCD calibration data */ 73 #define SPYD2_MALLOC 0x28 74 #define SPYD2_OBS_SELECT 0x29 /* Observer */ 75 #define SPYD2_CAL_FAIL 0x2A 76 #define SPYD2_TOO_FEW_CALIBSAMP 0x2B 77 #define SPYD2_INT_CIECONVFAIL 0x2C 78 79 /* Configuration */ 80 #define SPYD2_DISP_SEL_RANGE 0x40 /* Calibration selection is out of range */ 81 82 /* User errors */ 83 #define SPYD2_NO_REFRESH_DET 0x50 /* Calibration selection is out of range */ 84 85 /* SPYD2/3 communication object */ 86 struct _spyd2 { 87 INST_OBJ_BASE 88 89 inst_mode mode; /* Currently selected mode (emis/ambient/etc.) */ 90 91 inst_opt_type trig; /* Reading trigger mode */ 92 93 /* Serial EEPROM registers */ 94 /* versioni & feature bits */ 95 /* Spyder2 = 0x0307 */ 96 /* Spyder3 Express = 0x040f */ 97 /* Spyder3 Pro = 0x0407 */ 98 /* Spyder3 Elite = 0x0407 */ 99 /* Spyder4 Pro = 0x070F */ 100 101 unsigned int hwver; /* 5:B Harware version number */ 102 /* Spyder2 = 3 */ 103 /* Spyder3 = 4 */ 104 /* Spyder4 = 7 */ 105 /* Spyder5 = 10 */ 106 107 unsigned int fbits; /* 6:B Feature bits 0,1,2,3 correspond to calibration types */ 108 /* CRT/UNK, LCD/NORM, TOK, CRT/UNK */ 109 110 char serno[9]; /* 8:8xB Serial number as zero terminated string */ 111 112 /* Spyder2: [0][][] = CRT, [1][][] = LCD */ 113 /* Spyder3: [0][][] = UNK, [1][][] = CRT & LCD */ 114 115 /* hwver 3..6 uses these calibrations */ 116 double cal_A[2][3][9]; /* HW3..6: 16, 256 CRT/LCD A calibration matrix */ 117 double cal_B[2][3][9]; /* HW3..6: 128, 384 CRT/LCD B calibration matrix */ 118 119 /* HW3 [0] = CRT/UNK, [1] = LCD/NORM */ 120 /* HW4..6 [0] = not used, [1] = LCD */ 121 122 /* HW7 [0] = No used */ 123 /* HW7: cal_A[1] computed from sensor spectral data. */ 124 /* HWy: cal_B[1] 60, 384 Linearity correction */ 125 126 /* The first (A) 3x9 is a sensor to XYZ transform. */ 127 /* cal[0] is an offset value, while the */ 128 /* remaining 8 entries are the sensor weightings. */ 129 /* Because there are only 7 real sensors, cal[1] */ 130 /* and sensor[0] are skipped. */ 131 132 /* The second (B) 3x9 is an additional non-linearity */ 133 /* correction matrix, applied to the XYZ created */ 134 /* from the first 3x9. The cooeficients consist */ 135 /* of the weights for each product, ie: */ 136 /* X, Y, Z, X*X, X*Z, Y*Z, X*X, Y*Y, Z*Z */ 137 /* for each corrected output XYZ */ 138 139 double cal_F[7]; /* 240:4, 364:3 F calibration vector */ 140 /* This might be Y only weightings for the 7 sensor values, */ 141 /* with no offset value (TOK type ?). */ 142 143 /* hwver 7 & 10 (Spyder 4/5) uses computed calibrations */ 144 xspect sens[7]; /* Sensor sensitivity curves in Hz per mW/nm/m^2 */ 145 146 /* Computed factors and state */ 147 inst_disptypesel *_dtlist; /* Base list */ 148 inst_disptypesel *dtlist; /* Display Type list */ 149 int ndtlist; /* Number of valid dtlist entries */ 150 151 int refrmode; /* 0 for constant, 1 for refresh display */ 152 int cbid; /* current calibration base ID, 0 if not a base */ 153 int ucbid; /* Underlying base ID if being used for matrix, 0 othewise */ 154 int icx; /* Bit 0: Cal table index, 0 = CRT, 1 = LCD/normal */ 155 /* Bits 31-1: Spyder 4 spectral cal index, 0..spyd4_nocals-1 */ 156 disptech dtech; /* Display technology enum */ 157 int rrset; /* Flag, nz if the refresh rate has been determined */ 158 double refrate; /* Current refresh rate. Set to DEFREFR if not measurable */ 159 int refrvalid; /* nz if refrate was measured */ 160 double gain; /* hwver == 5 gain value (default 4) */ 161 icxObserverType obType; /* ccss observer to use */ 162 xspect custObserver[3]; /* Custom ccss observer to use */ 163 double ccmat[3][3]; /* Colorimeter correction matrix, unity if none */ 164 xspect *samples; /* Copy of current calibration spectral samples, NULL if none */ 165 int nsamp; /* Number of samples, 0 if none */ 166 167 int prevraw[8]; /* Previous raw reading values */ 168 int prevrawinv; /* Previous raw readings invalid flag - after an abort */ 169 170 /* Other state */ 171 int led_state; /* Spyder 3: Current LED state */ 172 double led_period, led_on_time_prop, led_trans_time_prop; /* Spyder 3: Pulse state */ 173 174 }; typedef struct _spyd2 spyd2; 175 176 /* Constructor */ 177 extern spyd2 *new_spyd2(icoms *icom, instType itype); 178 179 /* PLD pattern loader */ 180 /* id = 0 for Spyder 1, 1 for Spyder 2 */ 181 /* Return 0 if Spyder firmware is not available */ 182 /* Return 1 if Spyder firmware is available */ 183 extern int setup_spyd2(int id); 184 185 #ifdef __cplusplus 186 } 187 #endif 188 189 #define SPYD2_H 190 #endif /* SPYD2_H */ 191