aboutsummaryrefslogtreecommitdiffstats
path: root/cphidgetled.h
blob: c6d7b4e36fc0bde47149384b72b1fda5c290bb7e (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#ifndef __CPHIDGETLED
#define __CPHIDGETLED
#include "cphidget.h"

/** \defgroup phidled Phidget LED 
 * \ingroup phidgets
 * Calls specific to the Phidget LED. See the product manual for more specific API details, supported functionality, units, etc.
 * @{
 */

DPHANDLE(LED)
CHDRSTANDARD(LED)

/**
 * The Phidget LED supports these current limits
 */
typedef enum {
	PHIDGET_LED_CURRENT_LIMIT_20mA = 1,	/**< 20mA */
	PHIDGET_LED_CURRENT_LIMIT_40mA,		/**< 40mA */
	PHIDGET_LED_CURRENT_LIMIT_60mA,		/**< 60mA */
	PHIDGET_LED_CURRENT_LIMIT_80mA		/**< 80mA */
}  CPhidgetLED_CurrentLimit;
/**
 * The Phidget LED supports these voltages
 */
typedef enum {
	PHIDGET_LED_VOLTAGE_1_7V = 1,	/**< 1.7V */
	PHIDGET_LED_VOLTAGE_2_75V,		/**< 2.75V */
	PHIDGET_LED_VOLTAGE_3_9V,		/**< 3.9V */
	PHIDGET_LED_VOLTAGE_5_0V		/**< 5.0V */
}  CPhidgetLED_Voltage;

/**
 * Gets the number of LEDs supported by this board.
 * @param phid An attached phidget LED handle.
 * @param count The led count.
 */
CHDRGET(LED,LEDCount,int *count)
/**
 * Gets the brightness of an LED.
 * @param phid An attached phidget LED handle.
 * @param index The LED index.
 * @param brightness The LED brightness (0-100).
 */
CHDRGETINDEX(LED,DiscreteLED,int *brightness)
/**
 * Sets the brightness of an LED.
 * @param phid An attached phidget LED handle.
 * @param index The LED index.
 * @param brightness The LED brightness (0-100).
 */
CHDRSETINDEX(LED,DiscreteLED,int brightness)
/**
 * Gets the current limit. This is for all ouputs.
 * @param phid An attached phidget LED handle.
 * @param currentLimit The Current Limit.
 */
CHDRGET(LED,CurrentLimit,CPhidgetLED_CurrentLimit *currentLimit)
/**
 * Sets the current limit. This is for all ouputs.
 * @param phid An attached phidget LED handle.
 * @param currentLimit The Current Limit.
 */
CHDRSET(LED,CurrentLimit,CPhidgetLED_CurrentLimit currentLimit)
/**
 * Gets the output voltate. This is for all ouputs.
 * @param phid An attached phidget LED handle.
 * @param voltage The Output Voltage.
 */
CHDRGET(LED,Voltage,CPhidgetLED_Voltage *voltage)
/**
 * Sets the output voltage. This is for all ouputs.
 * @param phid An attached phidget LED handle.
 * @param voltage The Output Voltage.
 */
CHDRSET(LED,Voltage,CPhidgetLED_Voltage voltage)

#ifndef REMOVE_DEPRECATED
DEP_CHDRGET("Deprecated - use CPhidgetLED_getLEDCount",LED,NumLEDs,int *)
#endif
	
#ifndef EXTERNALPROTO

#define LED_MAXLEDS 64

//OUT Packet Types
#define LED64_NORMAL_PACKET 0x00
#define LED64_CONTROL_PACKET 0x40
#define LED64_OUTLOW_PACKET 0x80
#define LED64_OUTHIGH_PACKET 0xc0

//IN Packet Types
#define LED64_IN_LOW_PACKET 0x00
#define LED64_IN_HIGH_PACKET 0x80

//Flags
#define LED64_PGOOD_FLAG 0x01
#define LED64_CURSELA_FLAG 0x02
#define LED64_CURSELB_FLAG 0x04
#define LED64_PWRSELA_FLAG 0x08
#define LED64_PWRSELB_FLAG 0x10
#define LED64_FAULT_FLAG 0x20
#define LED64_OE_FLAG 0x40

struct _CPhidgetLED 
{
	CPhidget phid;

	int LED_Power[LED_MAXLEDS];
	CPhidgetLED_Voltage voltage;
	CPhidgetLED_CurrentLimit currentLimit;

	int nextLED_Power[LED_MAXLEDS];
	int lastLED_Power[LED_MAXLEDS];
	unsigned char changedLED_Power[LED_MAXLEDS];
	unsigned char changeRequests;

	int LED_PowerEcho[LED_MAXLEDS];
	unsigned char outputEnabledEcho[LED_MAXLEDS];
	unsigned char ledOpenDetectEcho[LED_MAXLEDS];
	unsigned char powerGoodEcho;
	unsigned char outputEnableEcho;
	unsigned char faultEcho;
	CPhidgetLED_Voltage voltageEcho;
	CPhidgetLED_CurrentLimit currentLimitEcho;
	
	unsigned char TSDCount, TSDClearCount, PGoodErrState;
	
	unsigned char controlPacketWaiting;
	unsigned char lastOutputPacket;

} typedef CPhidgetLEDInfo;

#endif

/** @} */
#endif