Device-Delcom-VSI
view release on metacpan or search on metacpan
lib/Device/Delcom/VSI.pm view on Meta::CPAN
}
=item read_buzzer
Read the current value of the buzzer pin. Possible values are 0 and 1.
=cut
sub read_buzzer
{
my $self = shift;
return (($self->read_ports())[1] & 8)>>3;
}
=item 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.
=cut
sub read_leds
{
my $self = shift;
my $leds = ($self->read_ports())[1];
return {
green => ($leds & 1),
red => ($leds & 2)>>1,
blue => ($leds & 4)>>2,
};
}
=item 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.
=cut
sub read_event_counter
{
my $self = shift;
my ($count, $overflow) = $self->_read_event_counter();
return $overflow ? 'overflow' : $count;
}
=item 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:
=over 4
=item buzzer_running
True if the buzzer is currently running.
=item counter_overflow
True if the button event counter has overflowed.
=item auto_clear
True if the button is configured to clear when pressed.
=item auto_confirm
True if the button is configured to beep when pressed.
=item prescalar
The value of the closk generator pre-scalar.
=item address
The USB port address.
=back
=cut
sub read_system_variables
{
my $self = shift;
my @sysvars = $self->_read_system_variables();
return unless @sysvars;
return {
buzzer_running => ($sysvars[0] & 0b0001_0000) >> 4,
counter_overflow => ($sysvars[0] & 0b0010_0000) >> 5,
auto_clear => ($sysvars[0] & 0b0100_0000) >> 6,
auto_confirm => ($sysvars[0] & 0b1000_0000) >> 7,
prescalar => $sysvars[1],
address => $sysvars[2],
};
}
=item 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:
=over 4
=item serial_number
The 4-byte serial number.
=item version
The current firmware version.
=item year
The 2 digit year of the firmware date.
=item month
The month number of the firmware date.
=item day
The day number of the month of the firmware date.
=back
=cut
sub read_firmware
{
my $self = shift;
my @firmware = $self->_read_firmware();
return unless @firmware;
return {
serial_number => $firmware[0],
version => $firmware[1],
day => $firmware[2],
month => $firmware[3],
year => $firmware[4],
};
}
=begin COMMENT
sub color_set {
#my $self = shift;
#my $dev = $$self;
my $dev = ${(shift)};
my %args = @_;
foreach my $key (keys %args) {
my $color_name = $key;
my $color = $colors{$color_name};
print STDERR "bad color: $color_name in color_set\n" unless defined $color;
next unless defined $color;
my $cmd = $args{$key}; # should be on, off, flash
( run in 1.589 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )