aboutsummaryrefslogtreecommitdiffstats
path: root/Java/com/phidgets/LEDPhidget.java
blob: 77a37e24aa115cad804a052b03ae6cc83f537693 (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
138
139
140
141
/*
 * Copyright 2006 Phidgets Inc.  All rights reserved.
 */

package com.phidgets;
import java.util.Iterator;
import java.util.LinkedList;
import com.phidgets.event.*;
/**
 * This class represents a Phidget LED. All methods
 * to control a Phidget LED are implemented in this class.
 <p>
 The Phidget LED is a board that is meant for driving LEDs. Currently, the
 only available version drives 64 LEDs, but other versions may become available
 so this number is not absolute.
 <p>
 LEDs can be controlled individually, at brightness levels from 0-100.
 * 
 * @author Phidgets Inc.
 */
public final class LEDPhidget extends Phidget
{
	public LEDPhidget () throws PhidgetException
	{
		super (create ());
	}
	private static native long create () throws PhidgetException;

	/**
	 * 20mA current limit. This is used with {@link #getCurrentLimit getCurrentLimit} and {@link #setCurrentLimit setCurrentLimit}
	 */
	public static final int PHIDGET_LED_CURRENT_LIMIT_20mA = 1;
	/**
	 * 40mA current limit. This is used with {@link #getCurrentLimit getCurrentLimit} and {@link #setCurrentLimit setCurrentLimit}
	 */
	public static final int PHIDGET_LED_CURRENT_LIMIT_40mA = 2;
	/**
	 * 60mA current limit. This is used with {@link #getCurrentLimit getCurrentLimit} and {@link #setCurrentLimit setCurrentLimit}
	 */
	public static final int PHIDGET_LED_CURRENT_LIMIT_60mA = 3;
	/**
	 * 80mA current limit. This is used with {@link #getCurrentLimit getCurrentLimit} and {@link #setCurrentLimit setCurrentLimit}
	 */
	public static final int PHIDGET_LED_CURRENT_LIMIT_80mA = 4;

	/**
	 * 1.7V Voltage output. This is used with {@link #getVoltage getVoltage} and {@link #setVoltage setVoltage}
	 */
	public static final int PHIDGET_LED_VOLTAGE_1_7V = 1;
	/**
	 * 2.75V Voltage output. This is used with {@link #getVoltage getVoltage} and {@link #setVoltage setVoltage}
	 */
	public static final int PHIDGET_LED_VOLTAGE_2_75V = 2;
	/**
	 * 3.9V Voltage output. This is used with {@link #getVoltage getVoltage} and {@link #setVoltage setVoltage}
	 */
	public static final int PHIDGET_LED_VOLTAGE_3_9V = 3;
	/**
	 * 5.0V Voltage output. This is used with {@link #getVoltage getVoltage} and {@link #setVoltage setVoltage}
	 */
	public static final int PHIDGET_LED_VOLTAGE_5_0V = 4;

	/**
	 * Returns the current limit for the all outputs. This is only supported by some PhidgetLEDs - see the product manual.
	 * The possible values for type are {@link #PHIDGET_LED_CURRENT_LIMIT_20mA PHIDGET_LED_CURRENT_LIMIT_20mA},
	 * {@link #PHIDGET_LED_CURRENT_LIMIT_40mA PHIDGET_LED_CURRENT_LIMIT_40mA}, {@link #PHIDGET_LED_CURRENT_LIMIT_60mA PHIDGET_LED_CURRENT_LIMIT_60mA} and
	 * {@link #PHIDGET_LED_CURRENT_LIMIT_80mA PHIDGET_LED_CURRENT_LIMIT_80mA}
	 * @return Current Limit
	 * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, or if unsupported by this board.
	 * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
	 */
	public native int getCurrentLimit () throws PhidgetException;
	/**
	 * Sets the current limit for all outputs. This is only supported by some PhidgetLEDs - see the product manual.
	 * <p>
	 * The possible values for type are {@link #PHIDGET_LED_CURRENT_LIMIT_20mA PHIDGET_LED_CURRENT_LIMIT_20mA},
	 * {@link #PHIDGET_LED_CURRENT_LIMIT_40mA PHIDGET_LED_CURRENT_LIMIT_40mA}, {@link #PHIDGET_LED_CURRENT_LIMIT_60mA PHIDGET_LED_CURRENT_LIMIT_60mA} and
	 * {@link #PHIDGET_LED_CURRENT_LIMIT_80mA PHIDGET_LED_CURRENT_LIMIT_80mA}
	 * <p>
	 * By default, currentLimit is set to {@link #PHIDGET_LED_CURRENT_LIMIT_20mA PHIDGET_LED_CURRENT_LIMIT_20mA}.
	 * @param currentLimit Current Limit
	 * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, or if unsupported by this board.
	 * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
	 */
	public native void setCurrentLimit (int currentLimit) throws PhidgetException;

	/**
	 * Returns the voltage output for the all outputs. This is only supported by some PhidgetLEDs - see the product manual.
	 * The possible values for type are {@link #PHIDGET_LED_VOLTAGE_1_7V PHIDGET_LED_VOLTAGE_1_7V},
	 * {@link #PHIDGET_LED_VOLTAGE_2_75V PHIDGET_LED_VOLTAGE_2_75V}, {@link #PHIDGET_LED_VOLTAGE_3_9V PHIDGET_LED_VOLTAGE_3_9V} and
	 * {@link #PHIDGET_LED_VOLTAGE_5_0V PHIDGET_LED_VOLTAGE_5_0V}
	 * @return Voltage
	 * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, or if unsupported by this board.
	 * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
	 */
	public native int getVoltage () throws PhidgetException;
	/**
	 * Sets the voltage output for all outputs. This is only supported by some PhidgetLEDs - see the product manual.
	 * <p>
	 * The possible values for type are {@link #PHIDGET_LED_VOLTAGE_1_7V PHIDGET_LED_VOLTAGE_1_7V},
	 * {@link #PHIDGET_LED_VOLTAGE_2_75V PHIDGET_LED_VOLTAGE_2_75V}, {@link #PHIDGET_LED_VOLTAGE_3_9V PHIDGET_LED_VOLTAGE_3_9V} and
	 * {@link #PHIDGET_LED_VOLTAGE_5_0V PHIDGET_LED_VOLTAGE_5_0V}
	 * <p>
	 * By default, voltage is set to {@link #PHIDGET_LED_VOLTAGE_2_75V PHIDGET_LED_VOLTAGE_2_75V}.
	 * @param voltage Voltage
	 * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, or if unsupported by this board.
	 * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
	 */
	public native void setVoltage (int voltage) throws PhidgetException;

	/**
	 * Returns the number of LEDs that this board can drive. This may not correspond to the actual number
	 of LEDs attached.
	 * @return number of LEDs
	 * @throws PhidgetException If this Phidget is not opened and attached. 
	 * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
	 */
	public native int getLEDCount () throws PhidgetException;
	/**
	 * Returns the brightness value of an LED. This value ranges from 0-100.
	 * @param index LED
	 * @return brightness
	 * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range. 
	 * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
	 */
	public native int getDiscreteLED (int index) throws PhidgetException;
	/**
	 * Sets the brightness of an LED.
	 * Valid values are 0-100, with 0 being off and 100 being the brightest. This 0-100 value is converted internally to a
	 6-bit value (0-63) so only 64 levels of brightness are actually possible.
	 * @param index index of the LED
	 * @param brightness desired brightness of this LED
	 * @throws PhidgetException If this Phidget is not opened and attached, or if the index of brightness value are out of range. 
	 * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
	 */
	public native void setDiscreteLED (int index, int brightness) throws PhidgetException;
	private final void enableDeviceSpecificEvents (boolean b)
	{
	}
}