Device::Delcom::VSI

This class encapsulates access to one or more Delcom VSI devices.

NAME

Device::Delcom::VSI - Use Device::USB to access Delcom VSI devices.

VERSION

Version 0.06

SYNOPSIS

Device::Delcom::VSI provides a Perl object for accessing a Delcom VSI device using the Device::USB module.

use Device::Delcom::VSI;

my $vsi = Device::Delcom::VSI->new();

$vsi->color_set( red => 'on', blue => 'off' );
$vsi->led_duty_cycle( 'green', 200, 100 );
$vsi->color_set( green => 'flash' );

DESCRIPTION

This module defines a Perl object that represents the data and functionality associated with a USB device. The object interface provides read-only access to the important data associated with a device. It also provides methods for almost all of the functions supplied by libusb. Where necessary, the interfaces to these methods were changed to better match Perl usage. However, most of the methods are straight-forward wrappers around their libusb counterparts.

FUNCTIONS

new

Create an object for manipulating the first VSI device detected.

Returns a Device::Delcom::VSI object that supports manipulation of the device.

Croaks on error.

list

Generate a list of Device::Delcom::VSI objects, one for each VSI on the current system.

debug_mode

Enable or disable debugging based on the value of the supplied parameter. A true value enables the debug printing, while a false value disables it.

color_set

Turn the leds on, off, or make them flash.

The parameters to this function are expected in pairs: a color followed by a command. The expected colors are: red, blue, green. For convenience if using the red/green/yellow version of the VSI, yellow can be used instead of blue when issuing commands.

The command can be one of the following:

on

Turn on the named led.

1

The same as 'on'.

off

Turn off the named led.

0

The same as 'off'.

flash

Make the named led flash.

set_prescalar

Set the scaling value for the clock used in generating all frequencies. Legal values are from 1 to 255. Power on default is 10. Higher numbers means lower frequency.

led_duty_cycle

Set the duty cycle for a given led when it is flashing.

color

The name of the color to change: red, green, or blue.

highdur

The length of time the led is on in each cycle: 1 - 255.

lowdur

The length of time the led is off in each cycle: 1 - 255.

led_sync

Synchronize the LEDs when flashing.

The parameter list consists of a set of pairs of values. Each pair is a color and a state. Any colors not listed will not be synchronized.

The legal colors are: red, green, or blue

The legal states are: on (1) and off (0).

For example:

$vsi->led_sync( red => on, green => off, blue => on );

and

$vsi->led_sync( red => 1, green => 0, blue => 1 );

Have the same meaning, red and blue will come on at the same time that green is off. Then, they will swap. (Depending on phase delay and duty cycle, of course.)

led_phase_delay

Set the delay of the beginning of the cycle for the specified LED.

color

The color name of the LEDs to adjust: red, green, or blue.

offset

The offset of the beginning of the duty cycle. Legal values are 0 - 255. The units are 1.024ms times the prescalar value.

led_intensity

Set the brightness of a particular color of LED.

The parameter list consists of a set of pairs of values. Each pair is a color and an intensity. Any colors not listed will not be changed.

color

The color name of the LEDs to adjust: red, green, or blue.

intensity

Brightness as a percentage. Default value is 80. Setting all LEDs above 80 could potentially exceed the current limit of the USB port.

set_event_count

Enable or disable the button event counter.

A value of 'on' or 1 enables the counter. A value of 'off' or 0 disables it.

buzzer_off

Turn off the buzzer.

buzzer_on

Turn on the buzzer, setting its frequency and duty cycle.

The parameter list consists of a set of pairs of values. Each pair is optional, and a default value will be substituted if a parameter is missing.

freq

Frequency value in 256us increments. Legal values are from 1 to 255. Default is 10.

repeat

Number of cycles to repeat. Legal values are 1 - 254. Default is 3. There are also two special values: 0 (full) and 255 (forever)

A repeat value of 0 or 'full' causes the buzzer to run continuously at a 100% duty cycle (ignoring the duty_on and duty_off values).

A repeat value of 255 or 'forever' causes the buzzer to run with the given frequency and duty cycle continuously.

duty_on

The on time portion of the duty cycle. Default is 3.

duty_off

The off time portion of the duty cycle. Default is 3.

button_setup

Configure the button modes of operation.

The parameters to this method are pairs of values. The first item of each pair is a mode string and the second specifies whether the mode is 'on' (1) or 'off' (0). The defined modes are:

clear

Turn off the buzzer and all LEDs when the button is pressed.

beep

Generate an audible signal when the button is pressed.

Either or both modes can be turned on or off without effecting the other.

Although this method configures the modes. The button mode is not active until the button event counter is enabled. For example, to turn on both modes, use the following code:

$vsi->button_setup( clear => 'on', beep => 'on' );
$vsi->set_event_counter( 'on' );

Once the event counter is enabled, this method can be used to change the button mode without re-enabling the counter.

read_ports

Read ports 0 and 1 on the VSI and return the bytes as a two item list.

read_button

Read the current value of the button on the VSI. A value of 0 means the button is being pushed. A value of 1 means the button is not being pushed.

read_buzzer

Read the current value of the buzzer pin. Possible values are 0 and 1.

read_leds

Read the current values of the LED pins. The result is returned as a reference to a hash, containing the pin values. The keys to the hash are the color names red, green, and blue. A value of 0 means the LEDs on that color are on. A value of 1 means the LEDs of that color are off.

read_event_counter

Read the current value of the button event counter. This method returns the current value of the counter and resets the counter to 0.

The event counter is a 4 byte value. If the event counter exceeds the value that can be stored in 4 bytes, a special value of 'overflow' is returned.

read_system_variables

Read the system variables. The results are decoded and returned as a hash reference. The data stored in the hash reference is:

buzzer_running

True if the buzzer is currently running.

counter_overflow

True if the button event counter has overflowed.

auto_clear

True if the button is configured to clear when pressed.

auto_confirm

True if the button is configured to beep when pressed.

prescalar

The value of the closk generator pre-scalar.

address

The USB port address.

read_system_variables

Read the formware information. The results are decoded and returned as a hash reference. The data stored in the hash reference is:

serial_number

The 4-byte serial number.

version

The current firmware version.

year

The 2 digit year of the firmware date.

month

The month number of the firmware date.

day

The day number of the month of the firmware date.

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 72:

=over without closing =back

Around line 179:

Expected text after =item, not a number

Around line 187:

Expected text after =item, not a number