Device::Chip::TCS3472x - chip driver for TCS3472x-family
Device::Chip::TCS3472x
use Device::Chip::TCS3472x; my $chip = Device::Chip::TCS3472x->new; $chip->mount( Device::Chip::Adapter::...->new )->get; # Power on and enable ADCs $chip->change_config( PON => 1, AEN => 1, )->get; # At default config, first sensor reading is available after # 620 msec sleep 0.620; my ( $clear, $red, $green, $blue ) = $chip->read_crgb->get; print "Red=$red Green=$green Blue=$blue\n";
This Device::Chip subclass provides specific communications to a TASOC Inc. TCS3472x-family RGB light sensor chip.
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.
Optional name of the GPIO line attached to the LED control pin common to many breakout boards. This is used by the "set_led" method.
The following methods documented in an await expression return Future instances.
await
$id = await $chip->read_id;
Returns a 2-character string from the ID register. The expected value will depend on the type of chip
"44" # TCS34721 or TCS34725 "4D" # TCS34723 or TCS34727
$config = await $chip->read_config;
Returns a hash reference containing the current chip configuration.
AEN => bool AIEN => bool AGAIN => 1 | 4 | 16 | 60 APERS => "EVERY" | int ATIME => int PON => bool WEN => bool WLONG => bool WTIME => int
The returned value also contains some lowercase-named synthesized fields, containing helper values derived from the chip config. These keys are not supported by "change_config".
atime_cycles => int # number of integration cycles implied by ATIME atime_msec => num # total integration time implied by ATIME wtime_cycles => int # number of wait cycles implied by WTIME wtime_msec => num # total wait time implied by WTIME and WLONG
await $chip->change_config( %changes )
Changes the configuration. Any field names not mentioned will be preserved at their existing values.
( $clear, $red, $green, $blue ) = await $chip->read_crgb
Returns the result of the most recent colour acquisition.
await $chip->set_led( $on );
If the led mount parameter was specified, this method acts as a proxy for the named GPIO line, setting it high or low to control the LED.
led
While not a feature of the TCS3472x sensor chip itself, this is common to many breakout boards, so is provided here as a convenience.
Paul Evans <leonerd@leonerd.org.uk>
To install Device::Chip::TCS3472x, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Device::Chip::TCS3472x
CPAN shell
perl -MCPAN -e shell install Device::Chip::TCS3472x
For more information on module installation, please visit the detailed CPAN module installation guide.