public class CANLight
extends java.lang.Object
Constructor and Description |
---|
CANLight(int deviceNumber)
An instance of this object represents a single CANLight device.
|
Modifier and Type | Method and Description |
---|---|
void |
blinkLED(int seconds)
Each CANLight has a build-in LED on the board itself.
|
void |
cycle(int fromIndex,
int toIndex)
Cycle through a sequence of stored color values.
|
void |
fade(int startIndex,
int endIndex)
Fade across a sequence of stored color values.
|
void |
flash(int index)
Flash a stored color.
|
void |
free() |
double |
getBatteryVoltage() |
java.lang.String |
getBootloaderVersion() |
int |
getDeviceID() |
java.lang.String |
getDeviceName() |
java.lang.String |
getFirmwareVersion() |
java.lang.String |
getHardwareVersion() |
static java.lang.String |
getLibraryVersion() |
java.lang.String |
getSerialNumber() |
void |
reset()
Restore the registers to power on default.
|
void |
showRegister(int index)
Display a stored color.
|
void |
showRGB(int red,
int green,
int blue)
Set a static color for the CANLight to display.
|
void |
writeRegister(int index,
double time,
int red,
int green,
int blue)
Write a value in the CANLight's internal memory.
|
public CANLight(int deviceNumber)
free()
first.
If a CANLight does not have a CAN connection to a roboRIO, its default
behavior of cycle(1,7)
will be used. If it does
find a CAN connection, it will execute showRegister(0)
. The CANLight will continue to execute its last command
until a new one is issued via one of the methods detailed below.
The CANLight can hold a sequence of up to eight colors and associated durations. Each register has a default value. The WriteRegister command can be used to change these. The CANLight will restore its default values when power is lost.
deviceNumber
- An integer between 1 and 60 (inclusive) for the ID of
this CANLight. CAN IDs can be modified through the mindsensors
configuration tool, available at
mindsensors.com/pages/311
. Devices will ship with a factory default CAN ID of 3. Please use a
unique ID for each device.public static java.lang.String getLibraryVersion()
major.minor
, for example: "1.1"public void free()
public int getDeviceID()
public java.lang.String getDeviceName()
public java.lang.String getFirmwareVersion()
public java.lang.String getHardwareVersion()
public java.lang.String getBootloaderVersion()
public java.lang.String getSerialNumber()
public void blinkLED(int seconds)
seconds
- The number of seconds to blink.public void showRGB(int red, int green, int blue)
red
- An integer between 0 and 255 (inclusive) for the red component
of the color to show.green
- An integer between 0 and 255 (inclusive) for the green
component of the color to show.blue
- An integer between 0 and 255 (inclusive) for the blue
component of the color to show.public void writeRegister(int index, double time, int red, int green, int blue)
cycle(int, int)
. The time value will determine how long a color
will display with flash(int)
or cycle(int, int)
, or how
long it will take to fade
from this color. They
have preset values, but this command allows for changing the stored
colors. The registers will return to their default values when the
CANLight loses power. A robot's initialization function can be a good
place to set up these values.index
- An integer between 0 and 7 (inclusive) for which register to
write to.time
- The duration, in seconds, to use in commands like
flash(int)
or cycle(int, int)
. Value less than 1 can be
used, such as 0.25 for a quarter of a second.red
- An integer between 0 and 255 (inclusive).green
- An integer between 0 and 255 (inclusive).blue
- An integer between 0 and 255 (inclusive).public void reset()
public void showRegister(int index)
showRGB(int, int, int)
this
color will be displayed until a new command is issued.index
- An integer between 0 and 7 (inclusive) for which register to
show.public void flash(int index)
index
- An integer between 0 and 7 (inclusive) for which register to
show.public void cycle(int fromIndex, int toIndex)
fromIndex
- An integer between 0 and 7 (inclusive) for which
register to begin the sequence at.toIndex
- An integer between 0 and 7 (inclusive) for which register
to use as the last color in the sequence.public void fade(int startIndex, int endIndex)
cycle(int, int)
, but fading between colors instead of jumping to
them. The duration value of each register specifies how long it will take
to fade from that color.startIndex
- An integer between 0 and 7 (inclusive) for which
register to begin at.endIndex
- An integer between 0 and 7 (inclusive) for which register
to end at.public double getBatteryVoltage()