summaryrefslogtreecommitdiff
path: root/spectro/colorhug.h
blob: a59160808761c9cc7ab83478a475632ecf8c7552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef COLORHUG_H

/*
 * Argyll Color Correction System
 *
 * Hughski ColorHug related defines
 *
 * Author: Richard Hughes
 * Date:   30/11/2011
 *
 * Copyright 2006 - 2013, Graeme W. Gill
 * Copyright 2011, Richard Hughes
 * All rights reserved.
 *
 * (Based on huey.h)
 *
 * This material is licenced under the GNU GENERAL PUBLIC LICENSE Version 2 or later :-
 * see the License2.txt file for licencing details.
 */

#include "inst.h"

/* Note: update colorhug_interp_error() and colorhug_interp_code() in colorhug.c */
/* if anything of these #defines are added or subtracted */

/* Fake Error codes */
#define COLORHUG_INTERNAL_ERROR			0x61		/* Internal software error */
#define COLORHUG_COMS_FAIL				0x62		/* Communication failure */
#define COLORHUG_UNKNOWN_MODEL			0x63		/* Not an colorhug */
#define COLORHUG_DATA_PARSE_ERROR 		0x64		/* Read data parsing error */

/* Real error codes */
#define COLORHUG_OK  					0x00
#define COLORHUG_UNKNOWN_CMD			0x01
#define COLORHUG_WRONG_UNLOCK_CODE		0x02
#define COLORHUG_NOT_IMPLEMENTED		0x03
#define COLORHUG_UNDERFLOW_SENSOR		0x04
#define COLORHUG_NO_SERIAL				0x05
#define COLORHUG_WATCHDOG				0x06
#define COLORHUG_INVALID_ADDRESS		0x07
#define COLORHUG_INVALID_LENGTH			0x08
#define COLORHUG_INVALID_CHECKSUM		0x09
#define COLORHUG_INVALID_VALUE			0x0a
#define COLORHUG_UNKNOWN_CMD_FOR_BOOTLOADER		0x0b
#define COLORHUG_NO_CALIBRATION			0x0c
#define COLORHUG_OVERFLOW_MULTIPLY		0x0d
#define COLORHUG_OVERFLOW_ADDITION		0x0e
#define COLORHUG_OVERFLOW_SENSOR		0x0f
#define COLORHUG_OVERFLOW_STACK			0x10
#define COLORHUG_DEVICE_DEACTIVATED		0x11
#define COLORHUG_INCOMPLETE_REQUEST		0x12

/* Internal errors */
#define COLORHUG_NO_COMS  				0x22
#define COLORHUG_NOT_INITED 			0x23
#define COLORHUG_BAD_WR_LENGTH			0x25
#define COLORHUG_BAD_RD_LENGTH			0x26
#define COLORHUG_BAD_RET_CMD			0x27
#define COLORHUG_BAD_RET_STAT			0x28


/* COLORHUG communication object */
struct _colorhug {
	INST_OBJ_BASE

	inst_mode mode;				/* Currently selected mode */

	inst_opt_type trig;			/* Reading trigger mode */

	int maj, min, uro;			/* Version number */
	int ser_no;					/* Serial number */

	inst_disptypesel *dtlist;	/* Display Type list */
	int ndtlist;				/* Number of valid dtlist entries */
	int icx;					/* Internal calibration matrix index, 11 = Raw */
	int cbid;					/* calibration base ID, 0 if not a base */
	int refrmode;				/* Refresh mode (always 0) */
	double postscale;			/* Post scale factor (for Raw) */
	double ccmat[3][3];			/* Colorimeter correction matrix */

	int	 led_state;				/* Current LED state */

}; typedef struct _colorhug colorhug;

/* Constructor */
extern colorhug *new_colorhug(icoms *icom, instType itype);


#define COLORHUG_H
#endif /* COLORHUG_H */