NAME
Device::Chip::TSL256x - chip driver for TSL256x
SYNOPSIS
use Device::Chip::TSL256x;
use Future::AsyncAwait;
my $chip = Device::Chip::TSL256x->new;
await $chip->mount( Device::Chip::Adapter::...->new );
await $chip->power(1);
sleep 1; # Wait for one integration cycle
printf "Current ambient light level is %.2f lux\n",
scalar await $chip->read_lux;
DESCRIPTION
This Device::Chip subclass provides specific communication to a TAOS
TSL2560 or TSL2561 attached to a computer via an I�C adapter.
The reader is presumed to be familiar with the general operation of
this chip; the documentation here will not attempt to explain or define
chip-specific concepts or features, only the use of this module to
access them.
ACCESSORS
The following methods documented in an await expression return Future
instances.
read_config
$config = await $chip->read_config;
Returns a HASH reference of the contents of timing control register,
using fields named from the data sheet.
GAIN => 1 | 16
INTEG => 13ms | 101ms | 420ms
change_config
await $chip->change_config( %changes );
Writes updates to the timing control register.
Note that these two methods use a cache of configuration bytes to make
subsequent modifications more efficient. This cache will not respect
the "one-shot" nature of the Manual bit.
read_id
$id = await $chip->read_id;
Returns the chip's ID register value.
read_data0
read_data1
$data0 = await $chip->read_data0;
$data1 = await $chip->read_data1;
Reads the current values of the ADC channels.
read_data
( $data0, $data1 ) = await $chip->read_data;
Read the current values of both ADC channels in a single I�C
transaction.
METHODS
power
await $chip->power( $on );
Enables or disables the main power control bits in the CONTROL
register.
read_lux
$lux = await $chip->read_lux;
( $lux, $data0, $data1 ) = await $chip->read_lux;
Reads the two data registers then performs the appropriate scaling
calculations to return a floating-point number that approximates the
light level in Lux.
Currently this conversion code presumes the contants for the T, FN and
CL chip types.
In list context, also returns the raw $data0 and $data1 channel values.
The controlling code may wish to use these to adjust the gain if
required.
AUTHOR
Paul Evans <
[email protected]>